mirror of
https://github.com/django/django.git
synced 2025-10-25 22:56:12 +00:00
[soc2009/multidb] Removed several instances of unnescary usage of the global connection object, where instead we should be using the connection object for the given Query
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@10896 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -67,10 +67,10 @@ class BaseQuery(object):
|
||||
# SQL-related attributes
|
||||
self.select = []
|
||||
self.tables = [] # Aliases in the order they are created.
|
||||
self.where = where()
|
||||
self.where = where(connection=self.connection)
|
||||
self.where_class = where
|
||||
self.group_by = None
|
||||
self.having = where()
|
||||
self.having = where(connection=self.connection)
|
||||
self.order_by = []
|
||||
self.low_mark, self.high_mark = 0, None # Used for offset/limit
|
||||
self.distinct = False
|
||||
@@ -151,6 +151,8 @@ class BaseQuery(object):
|
||||
# supported. It's the only class-reference to the module-level
|
||||
# connection variable.
|
||||
self.connection = connection
|
||||
self.where.update_connection(self.connection)
|
||||
self.having.update_connection(self.connection)
|
||||
|
||||
def get_meta(self):
|
||||
"""
|
||||
@@ -243,6 +245,8 @@ class BaseQuery(object):
|
||||
obj.used_aliases = set()
|
||||
obj.filter_is_sticky = False
|
||||
obj.__dict__.update(kwargs)
|
||||
obj.where.update_connection(obj.connection) # where and having track their own connection
|
||||
obj.having.update_connection(obj.connection)# we need to keep this up to date
|
||||
if hasattr(obj, '_setup_query'):
|
||||
obj._setup_query()
|
||||
return obj
|
||||
@@ -530,10 +534,10 @@ class BaseQuery(object):
|
||||
self.where.add(EverythingNode(), AND)
|
||||
elif self.where:
|
||||
# rhs has an empty where clause.
|
||||
w = self.where_class()
|
||||
w = self.where_class(connection=self.connection)
|
||||
w.add(EverythingNode(), AND)
|
||||
else:
|
||||
w = self.where_class()
|
||||
w = self.where_class(connection=self.connection)
|
||||
self.where.add(w, connector)
|
||||
|
||||
# Selection columns and extra extensions are those provided by 'rhs'.
|
||||
@@ -1534,7 +1538,7 @@ class BaseQuery(object):
|
||||
lookup_type = 'isnull'
|
||||
value = True
|
||||
elif (value == '' and lookup_type == 'exact' and
|
||||
connection.features.interprets_empty_strings_as_nulls):
|
||||
self.connection.features.interprets_empty_strings_as_nulls):
|
||||
lookup_type = 'isnull'
|
||||
value = True
|
||||
elif callable(value):
|
||||
@@ -1546,7 +1550,7 @@ class BaseQuery(object):
|
||||
|
||||
for alias, aggregate in self.aggregates.items():
|
||||
if alias == parts[0]:
|
||||
entry = self.where_class()
|
||||
entry = self.where_class(connection=self.connection)
|
||||
entry.add((aggregate, lookup_type, value), AND)
|
||||
if negate:
|
||||
entry.negate()
|
||||
@@ -1614,7 +1618,7 @@ class BaseQuery(object):
|
||||
for alias in join_list:
|
||||
if self.alias_map[alias][JOIN_TYPE] == self.LOUTER:
|
||||
j_col = self.alias_map[alias][RHS_JOIN_COL]
|
||||
entry = self.where_class()
|
||||
entry = self.where_class(connection=self.connection)
|
||||
entry.add((Constraint(alias, j_col, None), 'isnull', True), AND)
|
||||
entry.negate()
|
||||
self.where.add(entry, AND)
|
||||
@@ -1623,7 +1627,7 @@ class BaseQuery(object):
|
||||
# Leaky abstraction artifact: We have to specifically
|
||||
# exclude the "foo__in=[]" case from this handling, because
|
||||
# it's short-circuited in the Where class.
|
||||
entry = self.where_class()
|
||||
entry = self.where_class(connection=self.connection)
|
||||
entry.add((Constraint(alias, col, None), 'isnull', True), AND)
|
||||
entry.negate()
|
||||
self.where.add(entry, AND)
|
||||
|
||||
Reference in New Issue
Block a user