From c7a1a9f3807c07b42952293e8bd03275a6651442 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Wed, 4 Mar 2009 04:56:20 +0000 Subject: [PATCH] Changed the handling of as_sql() versus _as_sql() in Query/QuerySet from 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 --- django/db/models/fields/__init__.py | 4 ++-- django/db/models/fields/related.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index b7438e02b25..273416559cd 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -198,9 +198,9 @@ class Field(object): # 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) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 8f874bc7e0d..9aa2421f034 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -145,9 +145,9 @@ class RelatedField(object): # 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)