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.
This commit is contained in:
parent
a10f390804
commit
7db770b013
|
@ -225,8 +225,8 @@ class WhereNode(tree.Node):
|
||||||
return ('%s = %%s' % connection.ops.date_extract_sql(lookup_type, field_sql),
|
return ('%s = %%s' % connection.ops.date_extract_sql(lookup_type, field_sql),
|
||||||
params)
|
params)
|
||||||
elif lookup_type == 'isnull':
|
elif lookup_type == 'isnull':
|
||||||
return ('%s IS %sNULL' % (field_sql,
|
assert value_annotation in (True, False), "Invalid value_annotation for isnull"
|
||||||
(not value_annotation and 'NOT ' or '')), ())
|
return ('%s IS %sNULL' % (field_sql, ('' if value_annotation else 'NOT ')), ())
|
||||||
elif lookup_type == 'search':
|
elif lookup_type == 'search':
|
||||||
return (connection.ops.fulltext_search_sql(field_sql), params)
|
return (connection.ops.fulltext_search_sql(field_sql), params)
|
||||||
elif lookup_type in ('regex', 'iregex'):
|
elif lookup_type in ('regex', 'iregex'):
|
||||||
|
|
Loading…
Reference in New Issue