Skip to content

Commit b425e84

Browse files
author
Ramiro Morales
committed
Changed T-SQL in two tests to be SQL Server 2005 compatible.
This allow the full suite to run successfully.
1 parent 83e0637 commit b425e84

1 file changed

Lines changed: 40 additions & 2 deletions

File tree

tests/helpers.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,57 @@ def test_as_dict(self):
303303
def test_as_dict_no_column_name(self):
304304
cur = self.conn.cursor(as_dict=True)
305305
try:
306+
# SQL Server >= 2008:
307+
#
308+
# SELECT MAX(x), MIN(x) AS [MIN(x)]
309+
# FROM (VALUES (1), (2), (3))
310+
# AS foo(x)
311+
#
312+
# SQL Server = 2005 (remove when we drop suport for it):
313+
#
314+
# SELECT MAX(x), MIN(x) AS [MIN(x)]
315+
# FROM (SELECT 1
316+
# UNION ALL
317+
# SELECT 2
318+
# UNION ALL
319+
# SELECT 3)
320+
# AS foo(x)
306321
cur.execute(
307322
"SELECT MAX(x), MIN(x) AS [MIN(x)] "
308-
"FROM (VALUES (1), (2), (3)) AS foo(x)")
323+
"FROM (SELECT 1"
324+
" UNION ALL"
325+
" SELECT 2"
326+
" UNION ALL"
327+
" SELECT 3) AS foo(x)")
309328
assert False, "Didn't raise InterfaceError"
310329
except pymssql.ColumnsWithoutNamesError as exc:
311330
eq_(exc.columns_without_names, [0])
312331

313332
def test_as_dict_no_column_name_2(self):
314333
cur = self.conn.cursor(as_dict=True)
315334
try:
335+
# SQL Server >= 2008:
336+
#
337+
# SELECT MAX(x), MAX(y) AS [MAX(y)], MIN(y)
338+
# FROM (VALUES (1, 2), (2, 3), (3, 4))
339+
# AS foo(x, y)
340+
#
341+
# SQL Server = 2005 (remove when we drop suport for it):
342+
#
343+
# SELECT MAX(x), MAX(y) AS [MAX(y)], MIN(y)
344+
# FROM (SELECT (1, 2)
345+
# UNION ALL
346+
# SELECT (2, 3)
347+
# UNION ALL
348+
# SELECT (3, 4))
349+
# AS foo(x, y)
316350
cur.execute(
317351
"SELECT MAX(x), MAX(y) AS [MAX(y)], MIN(y) "
318-
"FROM (VALUES (1, 2), (2, 3), (3, 4)) AS foo(x, y)")
352+
"FROM (SELECT 1, 2"
353+
" UNION ALL"
354+
" SELECT 2, 3"
355+
" UNION ALL"
356+
" SELECT 3, 4) AS foo(x, y)")
319357
assert False, "Didn't raise InterfaceError"
320358
except pymssql.ColumnsWithoutNamesError as exc:
321359
eq_(exc.columns_without_names, [0, 2])

0 commit comments

Comments
 (0)