diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-03-24 22:59:44 +0200 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-03-26 14:19:54 +0200 |
| commit | e17fa9e877e84e93b699c2bd13ea48dbbb86e451 (patch) | |
| tree | 1481fb6e113e01d014634e4c84d264fa8fd40b83 /django/db/models/sql | |
| parent | a4b8a4b632dbb6d9fed1a8654aed99a9c53560d4 (diff) | |
Fixed #20091 -- Oracle null promotion for empty strings
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/query.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index fb42cfc5db..acb9f248d6 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1078,6 +1078,14 @@ class Query(object): elif isinstance(value, ExpressionNode): # If value is a query expression, evaluate it value = SQLEvaluator(value, self, reuse=can_reuse) + # For Oracle '' is equivalent to null. The check needs to be done + # at this stage because join promotion can't be done at compiler + # stage. Using DEFAULT_DB_ALIAS isn't nice, but it is the best we + # can do here. Similar thing is done in is_nullable(), too. + if (connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls and + lookup_type == 'exact' and value == ''): + value = True + lookup_type = 'isnull' for alias, aggregate in self.aggregates.items(): if alias in (parts[0], LOOKUP_SEP.join(parts)): |
