diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-04-28 07:07:17 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-04-28 07:07:17 +0000 |
| commit | 1bb8260084e6a44308d4707c3568a4daa143dacd (patch) | |
| tree | 368928b75273294ca21d58edddef4389c568e4ba | |
| parent | e07a457c0054fa20dcbbf5bf41bc07191bdaa895 (diff) | |
Allow Query objects to be values in query filters. This already existed for
relations, but not for normal fields. The latter comes up naturally in some
update statements.
Refs #7095
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7494 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/db/models/fields/__init__.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 7778117fb3..88033756ee 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -9,6 +9,7 @@ except ImportError: from django.db import get_creation_module from django.db.models import signals +from django.db.models.query_utils import QueryWrapper from django.dispatch import dispatcher from django.conf import settings from django.core import validators @@ -226,6 +227,9 @@ class Field(object): def get_db_prep_lookup(self, lookup_type, value): "Returns field's value prepared for database lookup." + if hasattr(value, 'as_sql'): + sql, params = value.as_sql() + return QueryWrapper(('(%s)' % sql), params) if lookup_type in ('exact', 'regex', 'iregex', 'gt', 'gte', 'lt', 'lte', 'month', 'day', 'search'): return [value] elif lookup_type in ('range', 'in'): |
