Permalink
Browse files

Changed the handling of as_sql() versus _as_sql() in Query/QuerySet f…

…rom r9928.

This avoids inadvertently hiding AttributeError that is raised for other
reasons.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9965 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent f506391 commit c7a1a9f3807c07b42952293e8bd03275a6651442 @malcolmt malcolmt committed Mar 4, 2009
Showing with 4 additions and 4 deletions.
  1. +2 −2 django/db/models/fields/__init__.py
  2. +2 −2 django/db/models/fields/related.py
View
4 django/db/models/fields/__init__.py
@@ -198,9 +198,9 @@ def get_db_prep_lookup(self, lookup_type, value):
# be invoked before the final SQL is evaluated
if hasattr(value, 'relabel_aliases'):
return value
- try:
+ if hasattr(value, 'as_sql'):
sql, params = value.as_sql()
- except AttributeError:
+ else:
sql, params = value._as_sql()
return QueryWrapper(('(%s)' % sql), params)
View
4 django/db/models/fields/related.py
@@ -145,9 +145,9 @@ def pk_trace(value):
# be invoked before the final SQL is evaluated
if hasattr(value, 'relabel_aliases'):
return value
- try:
+ if hasattr(value, 'as_sql'):
sql, params = value.as_sql()
- except AttributeError:
+ else:
sql, params = value._as_sql()
return QueryWrapper(('(%s)' % sql), params)

0 comments on commit c7a1a9f

Please sign in to comment.