You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This program fails with AssertionError: '\x00\x00\x00' but it should succeed.
import turbodbc
import pyodbc
cstring = 'DRIVER={SQL Server};SERVER=<redacted>;PORT=1433;DATABASE=<redacted>;UID=<redacted>;PWD=<redacted>;TDS_Version=7.1'
conn = turbodbc.connect(connection_string=cstring, turbodbc_options=turbodbc.make_options(prefer_unicode=True, autocommit=True)) # A
#conn = turbodbc.connect(connection_string=cstring, turbodbc_options=turbodbc.make_options(prefer_unicode=False, autocommit=True)) # B
#conn = pyodbc.connect(cstring) # C
cursor = conn.cursor()
cursor.execute('create table ##temp (foo text collate SQL_Latin1_General_CP1_CI_AS)')
try:
cursor.execute("insert into ##temp (foo) values ('bar')")
(x,), = cursor.execute('select foo from ##temp')
assert x == 'bar', repr(x)
finally:
cursor.execute('drop table ##temp')
Uncommenting line A and replacing with B doesn't change anything. Using pyodbc instead (C) does fix it. You can also fix it by changing the final SQL statement to select cast(foo as varchar(100)) from ##temp.
VARCHAR(MAX) behaves the same way as TEXT. I originally observed the problem with a non-temporary table so it's nothing to do with that -- it was just easier to demonstrate the issue with a temp table. Getting rid of the TDS_Version param also doesn't change anything.
Observed with turbodbc 3.3.0.
The text was updated successfully, but these errors were encountered:
This program fails with
AssertionError: '\x00\x00\x00'
but it should succeed.Uncommenting line
A
and replacing withB
doesn't change anything. Using pyodbc instead (C
) does fix it. You can also fix it by changing the final SQL statement toselect cast(foo as varchar(100)) from ##temp
.VARCHAR(MAX)
behaves the same way asTEXT
. I originally observed the problem with a non-temporary table so it's nothing to do with that -- it was just easier to demonstrate the issue with a temp table. Getting rid of theTDS_Version
param also doesn't change anything.Observed with turbodbc 3.3.0.
The text was updated successfully, but these errors were encountered: