Skip to content

Commit

Permalink
Changed the handling of as_sql() versus _as_sql() in Query/QuerySet f…
Browse files Browse the repository at this point in the history
…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
malcolmt committed Mar 4, 2009
1 parent f506391 commit c7a1a9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions django/db/models/fields/__init__.py
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions django/db/models/fields/related.py
Expand Up @@ -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)

Expand Down

0 comments on commit c7a1a9f

Please sign in to comment.