My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 48 attachment: sql_ss_xml_20090428.patch (4.1 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
diff --git a/.gitignore b/.gitignore
index fb32ac1..bb69e66 100644
diff --git a/LICENSE.txt b/LICENSE.txt
index f41936f..26905aa 100644
diff --git a/MANIFEST.in b/MANIFEST.in
index 6b027fe..18df743 100644
diff --git a/src/cnxninfo.cpp b/src/cnxninfo.cpp
index 7ff01d0..88e63a7 100644
diff --git a/src/cnxninfo.h b/src/cnxninfo.h
index 0633fc0..cac867d 100644
diff --git a/src/cursor.cpp b/src/cursor.cpp
index 03a4519..e8de0b8 100644
--- a/src/cursor.cpp
+++ b/src/cursor.cpp
@@ -148,6 +148,7 @@ PythonTypeFromSqlType(const SQLCHAR* name, SQLSMALLINT type, bool unicode_result
case SQL_VARCHAR:
case SQL_LONGVARCHAR:
case SQL_GUID:
+ case SQL_SS_XML:
if (unicode_results)
pytype = (PyObject*)&PyUnicode_Type;
else
diff --git a/src/dbspecific.h b/src/dbspecific.h
index bfaa27d..95c6b60 100644
--- a/src/dbspecific.h
+++ b/src/dbspecific.h
@@ -11,6 +11,12 @@
// ---------------------------------------------------------------------------------------------------------------------
// SQL Server

+
+// SQL Server 2005 xml type
+
+#define SQL_SS_XML -152
+
+
// SQL Server 2008 time type

#define SQL_SS_TIME2 -154
diff --git a/src/errors.h b/src/errors.h
index 7fab29b..3ba6eee 100644
diff --git a/src/getdata.cpp b/src/getdata.cpp
index 027ba90..6259beb 100644
--- a/src/getdata.cpp
+++ b/src/getdata.cpp
@@ -252,6 +252,7 @@ GetDataString(Cursor* cur, int iCol)
case SQL_VARCHAR:
case SQL_LONGVARCHAR:
case SQL_GUID:
+ case SQL_SS_XML:
if (cur->cnxn->unicode_results)
nTargetType = SQL_C_WCHAR;
else
@@ -580,6 +581,7 @@ GetData(Cursor* cur, Py_ssize_t iCol)
case SQL_VARCHAR:
case SQL_LONGVARCHAR:
case SQL_GUID:
+ case SQL_SS_XML:
return GetDataString(cur, iCol);

case SQL_BINARY:
diff --git a/src/getdata.h b/src/getdata.h
index 99dfe8f..3f94dfe 100644
diff --git a/src/params.cpp b/src/params.cpp
index 0bfadca..7db8568 100644
--- a/src/params.cpp
+++ b/src/params.cpp
@@ -320,6 +320,7 @@ static const char* SqlTypeName(SQLSMALLINT n)
_MAKESTR(SQL_TYPE_TIME);
_MAKESTR(SQL_TYPE_TIMESTAMP);
_MAKESTR(SQL_SS_TIME2);
+ _MAKESTR(SQL_SS_XML);
}
return "unknown";
}
diff --git a/src/params.h b/src/params.h
index d8869ff..fb7cd01 100644
diff --git a/src/pyodbc.rc b/src/pyodbc.rc
index 1d346af..49d6bf5 100644
diff --git a/src/pyodbcmodule.cpp b/src/pyodbcmodule.cpp
index 56b10e3..d354fb3 100644
--- a/src/pyodbcmodule.cpp
+++ b/src/pyodbcmodule.cpp
@@ -628,6 +628,7 @@ static const ConstantDef aConstants[] = {
MAKECONST(SQL_TYPE_TIME),
MAKECONST(SQL_TYPE_TIMESTAMP),
MAKECONST(SQL_SS_TIME2),
+ MAKECONST(SQL_SS_XML),
MAKECONST(SQL_INTERVAL_MONTH),
MAKECONST(SQL_INTERVAL_YEAR),
MAKECONST(SQL_INTERVAL_YEAR_TO_MONTH),
diff --git a/src/wrapper.h b/src/wrapper.h
index ce7119b..c202d89 100644
diff --git a/tests/dbapitests.py b/tests/dbapitests.py
index c69c2e3..e378587 100755
diff --git a/tests/sqlservertests.py b/tests/sqlservertests.py
index 45d9326..186bfc8 100755
--- a/tests/sqlservertests.py
+++ b/tests/sqlservertests.py
@@ -534,6 +534,26 @@ class SqlServerTestCase(unittest.TestCase):
result = self.cursor.execute("select n from t1").fetchone()[0]
self.assertEqual(value, result)

+ #
+ # xml
+ #
+
+ def test_xml(self):
+ """ Test populated xml field """
+ value = "<root><foo>Hello world!</foo></root>"
+ self.cursor.execute("create table t1(x xml)")
+ self.cursor.execute("insert into t1 values (?)", value)
+ result = self.cursor.execute("select x from t1").fetchone()[0]
+ self.assertEqual(value, result)
+
+ def test_xml_null(self):
+ """ Test null xml field """
+ value = None
+ self.cursor.execute("create table t1(x xml)")
+ self.cursor.execute("insert into t1 values (?)", value)
+ result = self.cursor.execute("select x from t1").fetchone()[0]
+ self.assertEqual(value, result)
+

#
# stored procedures
diff --git a/tests/testutils.py b/tests/testutils.py
index ea7d4fa..511bfa2 100755
Powered by Google Project Hosting