diff options
| author | Jason Pellerin <jpellerin@gmail.com> | 2006-12-04 19:58:49 +0000 |
|---|---|---|
| committer | Jason Pellerin <jpellerin@gmail.com> | 2006-12-04 19:58:49 +0000 |
| commit | 040f2272e0aec724a36e7abda445b61ee065a8f1 (patch) | |
| tree | 8ae714be4e513663470eaf1d3d8026a92a5cd2f8 /django/db | |
| parent | 2a58209ff2b7c47245c9d12985ac7581e97988d1 (diff) | |
[multi-db] Merged trunk to 3950. Some tests still failing.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@4155 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/models/fields/related.py | 2 | ||||
| -rw-r--r-- | django/db/models/manipulators.py | 2 | ||||
| -rw-r--r-- | django/db/models/query.py | 49 |
3 files changed, 29 insertions, 24 deletions
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index dc2ae69fa7..7c18f4f3c0 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -2,7 +2,7 @@ from django.db import transaction from django.db.models import signals, get_model from django.db.models.fields import AutoField, Field, IntegerField, get_ul_class from django.db.models.related import RelatedObject -from django.utils.translation import gettext_lazy, string_concat +from django.utils.translation import gettext_lazy, string_concat, ngettext from django.utils.functional import curry from django.core import validators from django import forms diff --git a/django/db/models/manipulators.py b/django/db/models/manipulators.py index 83ddda844e..9a898e217f 100644 --- a/django/db/models/manipulators.py +++ b/django/db/models/manipulators.py @@ -303,7 +303,7 @@ def manipulator_validator_unique_together(field_name_list, opts, self, field_dat pass else: raise validators.ValidationError, _("%(object)s with this %(type)s already exists for the given %(field)s.") % \ - {'object': capfirst(opts.verbose_name), 'type': field_list[0].verbose_name, 'field': get_text_list([f.verbose_name for f in field_list[1:]], 'and')} + {'object': capfirst(opts.verbose_name), 'type': field_list[0].verbose_name, 'field': get_text_list([f.verbose_name for f in field_list[1:]], _('and'))} def manipulator_validator_unique_for_date(from_field, date_field, opts, lookup_type, self, field_data, all_data): from django.db.models.fields.related import ManyToOneRel diff --git a/django/db/models/query.py b/django/db/models/query.py index f16e6869e3..3aa1241d1a 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -727,30 +727,35 @@ def parse_lookup(kwarg_items, opts): joins, where, params = SortedDict(), [], [] for kwarg, value in kwarg_items: - if value is not None: - path = kwarg.split(LOOKUP_SEPARATOR) - # Extract the last elements of the kwarg. - # The very-last is the lookup_type (equals, like, etc). - # The second-last is the table column on which the lookup_type is - # to be performed. If this name is 'pk', it will be substituted with - # the name of the primary key. - # If there is only one part, or the last part is not a query - # term, assume that the query is an __exact - lookup_type = path.pop() - if lookup_type == 'pk': - lookup_type = 'exact' - path.append(None) - elif len(path) == 0 or lookup_type not in QUERY_TERMS: - path.append(lookup_type) - lookup_type = 'exact' + path = kwarg.split(LOOKUP_SEPARATOR) + # Extract the last elements of the kwarg. + # The very-last is the lookup_type (equals, like, etc). + # The second-last is the table column on which the lookup_type is + # to be performed. If this name is 'pk', it will be substituted with + # the name of the primary key. + # If there is only one part, or the last part is not a query + # term, assume that the query is an __exact + lookup_type = path.pop() + if lookup_type == 'pk': + lookup_type = 'exact' + path.append(None) + elif len(path) == 0 or lookup_type not in QUERY_TERMS: + path.append(lookup_type) + lookup_type = 'exact' - if len(path) < 1: - raise TypeError, "Cannot parse keyword query %r" % kwarg + if len(path) < 1: + raise TypeError, "Cannot parse keyword query %r" % kwarg + + if value is None: + # Interpret '__exact=None' as the sql '= NULL'; otherwise, reject + # all uses of None as a query value. + if lookup_type != 'exact': + raise ValueError, "Cannot use None as a query value" - joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) - joins.update(joins2) - where.extend(where2) - params.extend(params2) + joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) + joins.update(joins2) + where.extend(where2) + params.extend(params2) return joins, where, params class FieldFound(Exception): |
