Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 7db770b013f26b81bef878541c1016a3eb291011 1 parent a10f390
@aaugustin aaugustin authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 django/db/models/sql/where.py
View
4 django/db/models/sql/where.py
@@ -225,8 +225,8 @@ def make_atom(self, child, qn, connection):
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'):
Please sign in to comment.
Something went wrong with that request. Please try again.