Closed GoogleCodeExporter closed 8 years ago
The error is in sql_server/pyodbc/operations.py:
20: from django.db import connection
here's where connection is defined:
django/db/__init__.py
74: connection = connections[DEFAULT_DB_ALIAS]
So, the connection will *always* be whatever was set as the default alias.
I'm a relative newbie with python so I'm leery of writing a patch myself. It
also
looks like operations.py currently depends on the existence of the global
settings
variable, and I have no idea how it would get the desired connection object
without
rewriting DatabaseOperations to take (self) in the init function (although, to
be
fair, it looks like that is what has had to happen for all of the other similar
objects).
Original comment by jordanth...@gmail.com
on 27 Jan 2010 at 7:25
Okay, patch attached. This is the FIRST TIME I have ever done a patch, and
again I'm
not a Python whiz, so please check it.
Basically, I changed the call to DatabaseOperations so that it sends the alias
name,
and then in DatabaseOperations instead of just pulling in
db.backends.connection, I
pull in db.backends.connections and set connection to
db.backends.connections[alias name]
I feel like sending the alias name is a bit odd and awkward, but due to when the
actual connection object is created, I can't actually send the connection
object to
DatabaseOperations (as is done in the PostGres implementation). The connection
object
has to be grabbed after the fact from db.backends.
Original comment by jordanth...@gmail.com
on 27 Jan 2010 at 8:48
Attachments:
Fixed in r177.
Original comment by vcc.ch...@gmail.com
on 27 Jan 2010 at 1:50
The r177 didn't correct the problem for me. That is because Django API obtains
the version using the "sql_server_ver" property, not the function call and when
that happens it gets the wrong connection.
I used the patch proposed here and THAT worked just fine.
Original comment by Kani...@gmail.com
on 10 Jan 2011 at 9:56
Attachments:
r186 should fixed it.
Original comment by vcc.ch...@gmail.com
on 17 Apr 2011 at 4:03
Original issue reported on code.google.com by
jordanth...@gmail.com
on 27 Jan 2010 at 6:53