diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-02-23 00:00:41 +0200 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-02-23 00:05:31 +0200 |
| commit | 09fcb70c804b76fccc8fc0ac545873e5ab30c00a (patch) | |
| tree | 56c319b8f2b374ec40ded24b2f69027559e77208 /django | |
| parent | 60fff6fc9496c7c851182dd6ebac10bb011be2ba (diff) | |
Fixed empty strings + to_field regression on Oracle
Querying the reverse side of nullable to_field relation, where both
sides can contain null values resulted in incorrect results. The reason
was not detecting '' as NULL.
Refs #17541
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/fields/related.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 804dda5817..bea88ba337 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -1,6 +1,6 @@ from operator import attrgetter -from django.db import connection, router +from django.db import connection, connections, router from django.db.backends import util from django.db.models import signals, get_model from django.db.models.fields import (AutoField, Field, IntegerField, @@ -496,7 +496,8 @@ class ForeignRelatedObjectsDescriptor(object): except (AttributeError, KeyError): db = self._db or router.db_for_read(self.model, instance=self.instance) qs = super(RelatedManager, self).get_query_set().using(db).filter(**self.core_filters) - if getattr(self.instance, attname) is None: + val = getattr(self.instance, attname) + if val is None or val == '' and connections[db].features.interprets_empty_strings_as_nulls: return qs.none() qs._known_related_objects = {rel_field: {self.instance.pk: self.instance}} return qs |
