diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-11 10:28:46 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-11 10:38:39 +0100 |
| commit | 7db770b013f26b81bef878541c1016a3eb291011 (patch) | |
| tree | e7fab2ecbd182e4795d51209967b5c533091464b /django/db/models/sql/where.py | |
| parent | a10f3908042a71ec5ef81bf76f0f278ca5e7a596 (diff) | |
Added a check in the creation of IS NULL clauses.
value_annotation isn't very well defined. Before this change, setting it
to datetime.datetime could silently reverse the behavior of isnull
lookups. This commit doesn't have any consequences on the current code.
It's just a safeguard for future ORM hackers.
Diffstat (limited to 'django/db/models/sql/where.py')
| -rw-r--r-- | django/db/models/sql/where.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index 3e4b352f10..cbb0546d6a 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -225,8 +225,8 @@ class WhereNode(tree.Node): return ('%s = %%s' % connection.ops.date_extract_sql(lookup_type, field_sql), params) elif lookup_type == 'isnull': - return ('%s IS %sNULL' % (field_sql, - (not value_annotation and 'NOT ' or '')), ()) + assert value_annotation in (True, False), "Invalid value_annotation for isnull" + return ('%s IS %sNULL' % (field_sql, ('' if value_annotation else 'NOT ')), ()) elif lookup_type == 'search': return (connection.ops.fulltext_search_sql(field_sql), params) elif lookup_type in ('regex', 'iregex'): |
