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 15:05:37 +0200 |
| commit | 207117ae731096d8148c17c6ca16f06ebf18537c (patch) | |
| tree | 4ba8c6e3f60f7824185a90e7d76ad9bb869289d6 /django/db/models/sql | |
| parent | 5e2bb1223c4e622113cef0edb6d7df53fab0367c (diff) | |
[1.5.x] Fixed #20091 -- Oracle null promotion for empty strings
Backpatch of e17fa9e877e84e93b699c2bd13ea48dbbb86e451
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/query.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index e7c8d6caaf..7368fed24c 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1106,7 +1106,14 @@ class Query(object): # If value is a query expression, evaluate it value = SQLEvaluator(value, self, reuse=can_reuse) having_clause = value.contains_aggregate - + # 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)): entry = self.where_class() |
