Author: jpellerin
Date: 2006-07-19 09:58:46 -0500 (Wed, 19 Jul 2006)
New Revision: 3380

Modified:
   django/branches/multiple-db-support/django/db/models/query.py
Log:
[multi-db] Updated query builder functions to use 
opts.get_default_manager() to access db connection where only options 
are available.


Modified: django/branches/multiple-db-support/django/db/models/query.py
===================================================================
--- django/branches/multiple-db-support/django/db/models/query.py       
2006-07-19 14:57:42 UTC (rev 3379)
+++ django/branches/multiple-db-support/django/db/models/query.py       
2006-07-19 14:58:46 UTC (rev 3380)
@@ -258,7 +258,7 @@
         Returns a dictionary mapping each of the given IDs to the object with
         that ID.
         """
-        backend = self.model._meta.connection_info.backend
+        backend = self.model._default_manager.db.backend
         assert self._limit is None and self._offset is None, \
                 "Cannot use 'limit' or 'offset' with in_bulk"
         assert isinstance(id_list, (tuple,  list)), "in_bulk() must be 
provided with a list of IDs."
@@ -649,11 +649,12 @@
         return joins, where2, params
 
 def get_where_clause(opts, lookup_type, table_prefix, field_name, value):
-    backend = opts.connection_info.backend
+    backend = opts.get_default_manager().db.backend
+    qn = backend.quote_name
     
     if table_prefix.endswith('.'):
-        table_prefix = backend.quote_name(table_prefix[:-1])+'.'
-    field_name = backend.quote_name(field_name)
+        table_prefix = qn(table_prefix[:-1])+'.'
+    field_name = qn(field_name)
     try:
         return '%s%s %s' % (table_prefix, field_name, 
(backend.OPERATOR_MAPPING[lookup_type] % '%s'))
     except KeyError:
@@ -685,8 +686,8 @@
     Helper function that recursively populates the select, tables and where (in
     place) for select_related queries.
     """
-    backend = opts.connection_info.backend
-    qn = backend.quote_name
+    qn = opts.get_default_manager().db.backend.quote_name
+
     for f in opts.fields:
         if f.rel and not f.null:
             db_table = f.rel.to._meta.db_table
@@ -780,9 +781,9 @@
     current_column = column
     intermediate_table = None
     join_required = False
-    info = current_opts.connection_info
-    backend = info.backend
-    connection = info.connection
+    db = current_opts.get_default_manager().db
+    backend = db.backend
+    connection = db.connection
     qn = backend.quote_name
 
     name = path.pop(0)
@@ -935,9 +936,9 @@
     ordered_classes.reverse()
 
     for cls in ordered_classes:
-        info = cls._meta.connection_info
-        backend = info.backend
-        connection = info.connection
+        db = cls._default_manager.db
+        backend = db.backend
+        connection = db.connection
         cursor = connection.cursor()
         qn = backend.quote_name
         
@@ -974,9 +975,9 @@
     dirty_conns = []
     for cls in ordered_classes:
 
-        info = cls._meta.connection_info
-        backend = info.backend
-        connection = info.connection
+        db = cls._default_manager.db
+        backend = db.backend
+        connection = db.connection
         qn = backend.quote_name
         cursor = connection.cursor()
         if connection not in dirty_conns:


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to