mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
[soc2009/multidb] Removed the as_sql_takes_connection option from various classes, it was originally just to allow the tests to pass while the code base was being migrated, it was not meant to remain
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11075 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
99fdf66600
commit
64eec4a120
@ -132,7 +132,7 @@ class QueryWrapper(object):
|
||||
def __init__(self, sql, params):
|
||||
self.data = sql, params
|
||||
|
||||
def as_sql(self, qn=None):
|
||||
def as_sql(self, qn=None, connection=None):
|
||||
return self.data
|
||||
|
||||
class Q(tree.Node):
|
||||
|
@ -21,7 +21,6 @@ class Aggregate(object):
|
||||
is_ordinal = False
|
||||
is_computed = False
|
||||
sql_template = '%(function)s(%(field)s)'
|
||||
as_sql_takes_connection = True
|
||||
|
||||
def __init__(self, col, source=None, is_summary=False, **extra):
|
||||
"""Instantiate an SQL aggregate
|
||||
@ -77,10 +76,7 @@ class Aggregate(object):
|
||||
"Return the aggregate, rendered as SQL."
|
||||
|
||||
if hasattr(self.col, 'as_sql'):
|
||||
if getattr(self.col, 'as_sql_takes_connection', False):
|
||||
field_name = self.col.as_sql(qn, connection)
|
||||
else:
|
||||
field_name = self.col.as_sql(qn)
|
||||
elif isinstance(self.col, (list, tuple)):
|
||||
field_name = '.'.join([qn(c) for c in self.col])
|
||||
else:
|
||||
|
@ -29,8 +29,6 @@ class Date(object):
|
||||
"""
|
||||
Add a date selection column.
|
||||
"""
|
||||
as_sql_takes_connection = True
|
||||
|
||||
def __init__(self, col, lookup_type):
|
||||
self.col = col
|
||||
self.lookup_type = lookup_type
|
||||
|
@ -3,8 +3,6 @@ from django.db.models.fields import FieldDoesNotExist
|
||||
from django.db.models.sql.constants import LOOKUP_SEP
|
||||
|
||||
class SQLEvaluator(object):
|
||||
as_sql_takes_connection = True
|
||||
|
||||
def __init__(self, expression, query, allow_joins=True):
|
||||
self.expression = expression
|
||||
self.opts = query.get_meta()
|
||||
@ -78,9 +76,6 @@ class SQLEvaluator(object):
|
||||
def evaluate_leaf(self, node, qn, connection):
|
||||
col = self.cols[node]
|
||||
if hasattr(col, 'as_sql'):
|
||||
if getattr(col, 'as_sql_takes_connection', False):
|
||||
return col.as_sql(qn, connection), ()
|
||||
else:
|
||||
return col.as_sql(qn)
|
||||
else:
|
||||
return '%s.%s' % (qn(col[0]), qn(col[1])), ()
|
||||
|
@ -729,10 +729,7 @@ class BaseQuery(object):
|
||||
aliases.add(r)
|
||||
col_aliases.add(col[1])
|
||||
else:
|
||||
if getattr(col, 'as_sql_takes_connection', False):
|
||||
result.append(col.as_sql(qn, self.connection))
|
||||
else:
|
||||
result.append(col.as_sql(qn))
|
||||
|
||||
if hasattr(col, 'alias'):
|
||||
aliases.add(col.alias)
|
||||
|
@ -144,10 +144,7 @@ class UpdateQuery(Query):
|
||||
values, update_params = [], []
|
||||
for name, val, placeholder in self.values:
|
||||
if hasattr(val, 'as_sql'):
|
||||
if getattr(val, 'as_sql_takes_connection', False):
|
||||
sql, params = val.as_sql(qn, self.connection)
|
||||
else:
|
||||
sql, params = val.as_sql(qn)
|
||||
values.append('%s = %s' % (qn(name), sql))
|
||||
update_params.extend(params)
|
||||
elif val is not None:
|
||||
@ -421,7 +418,6 @@ class AggregateQuery(Query):
|
||||
An AggregateQuery takes another query as a parameter to the FROM
|
||||
clause and only selects the elements in the provided list.
|
||||
"""
|
||||
as_sql_takes_connection = True
|
||||
|
||||
def add_subquery(self, query):
|
||||
self.subquery, self.sub_params = query.as_sql(with_col_aliases=True)
|
||||
|
@ -32,7 +32,6 @@ class WhereNode(tree.Node):
|
||||
relabel_aliases() methods.
|
||||
"""
|
||||
default = AND
|
||||
as_sql_takes_connection = True
|
||||
|
||||
def add(self, data, connector):
|
||||
"""
|
||||
@ -89,10 +88,7 @@ class WhereNode(tree.Node):
|
||||
for child in self.children:
|
||||
try:
|
||||
if hasattr(child, 'as_sql'):
|
||||
if getattr(child, 'as_sql_takes_connection', False):
|
||||
sql, params = child.as_sql(qn=qn, connection=connection)
|
||||
else:
|
||||
sql, params = child.as_sql(qn=qn)
|
||||
else:
|
||||
# A leaf node in the tree.
|
||||
sql, params = self.make_atom(child, qn, connection)
|
||||
@ -152,11 +148,7 @@ class WhereNode(tree.Node):
|
||||
field_sql = self.sql_for_columns(lvalue, qn, connection)
|
||||
else:
|
||||
# A smart object with an as_sql() method.
|
||||
if getattr(lvalue, 'as_sql_takes_connection', False):
|
||||
field_sql = lvalue.as_sql(qn, connection)
|
||||
else:
|
||||
field_sql = lvalue.as_sql(qn)
|
||||
|
||||
|
||||
if value_annot is datetime.datetime:
|
||||
cast_sql = connection.ops.datetime_cast_sql()
|
||||
@ -164,10 +156,7 @@ class WhereNode(tree.Node):
|
||||
cast_sql = '%s'
|
||||
|
||||
if hasattr(params, 'as_sql'):
|
||||
if getattr(params, 'as_sql_takes_connection', False):
|
||||
extra, params = params.as_sql(qn, connection)
|
||||
else:
|
||||
extra, params = params.as_sql(qn)
|
||||
cast_sql = ''
|
||||
else:
|
||||
extra = ''
|
||||
@ -242,7 +231,8 @@ class EverythingNode(object):
|
||||
"""
|
||||
A node that matches everything.
|
||||
"""
|
||||
def as_sql(self, qn=None):
|
||||
|
||||
def as_sql(self, qn=None, connection=None):
|
||||
raise FullResultSet
|
||||
|
||||
def relabel_aliases(self, change_map, node=None):
|
||||
@ -252,7 +242,7 @@ class NothingNode(object):
|
||||
"""
|
||||
A node that matches nothing.
|
||||
"""
|
||||
def as_sql(self, qn=None):
|
||||
def as_sql(self, qn=None, connection=None):
|
||||
raise EmptyResultSet
|
||||
|
||||
def relabel_aliases(self, change_map, node=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user