Single space character returned on model fields from django-pyodbc instead of empty string

205 views Asked by At

I have some models that are stored on a SQLServer and are accessed using django-pyodbc. On the server our code is working fine but on our development machines we've started to see models get returned with a single space character on fields that ought to be an empty string.

When I use the isql command here's the output I get:

Development:

SQL> SELECT MyField FROM MyTable WHERE MyField = ' '
SQLRowCount returns 62
SQL> SELECT MyField FROM MyTable WHERE MyField = ''
SQLRowCount returns 0

Server:

SQL> SELECT MyField FROM MyTable WHERE MyField = ' '
SQLRowCount returns 62
SQL> SELECT MyField FROM MyTable WHERE MyField = ''
SQLRowCount returns 62

It doesn't matter how much whitespace I add to the query on the server, I always get the same number of results returned.

Our development machines are reading from the same database and have the same version of django-pyodbc, but they're connecting with different DB users. Our desktops are running Ubuntu 11.10 with python-odbc 2.1.7-1build1 and our server has Gentoo (not my decision) with pyodbc-2.1.8.

Has anyone come across this error before? Any idea what the cause could be?

0

There are 0 answers