As raised in Issue 72, if the default database isn't MSSQL then a call to
django.db.connection is going to cause an error when determining SQL Server
version.
Because DatabaseOperations does not store the db alias anywhere, when
field_cast_sql is called, it references self.sql_server_ver *without* sending
in a value for connection.
This will cause an error.
I may be incorrect here, but I don't see any way this can be resolved without
either:
a) Sending in the connection when calling field_cast_sql OR
b) Sending in the connection alias when creating the DatabaseOperations object
My patch (included in issue #72) resolved it using option b. The patch is here:
http://code.google.com/p/django-pyodbc/issues/attachmentText?id=72&aid=-86646640
63618338815&name=connectiondiff.patch&token=4427a5a8e6880b18f46185a0a08db1ee
As you can see, self.ops is initialized with the value from self.alias defined
in DatabaseWrapper.
Can someone please come up with a more elegant solution to this? This is a hard
error. Unless I'm missing something, the code in its current state will
*always* break on any config where the default database isn't MSSQL.
For the time being I'm not using the current version and using my (admittedly
messy) patch.
Original issue reported on code.google.com by jordanth...@gmail.com on 5 Jul 2010 at 3:08
Original issue reported on code.google.com by
jordanth...@gmail.com
on 5 Jul 2010 at 3:08