Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Allow Query objects to be values in query filters. This already exist…

…ed 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
  • Loading branch information...
commit 1bb8260084e6a44308d4707c3568a4daa143dacd 1 parent e07a457
Malcolm Tredinnick authored April 28, 2008

Showing 1 changed file with 4 additions and 0 deletions. Show diff stats Hide diff stats

  1. 4  django/db/models/fields/__init__.py
4  django/db/models/fields/__init__.py
@@ -9,6 +9,7 @@
9 9
 
10 10
 from django.db import get_creation_module
11 11
 from django.db.models import signals
  12
+from django.db.models.query_utils import QueryWrapper
12 13
 from django.dispatch import dispatcher
13 14
 from django.conf import settings
14 15
 from django.core import validators
@@ -226,6 +227,9 @@ def get_db_prep_save(self, value):
226 227
 
227 228
     def get_db_prep_lookup(self, lookup_type, value):
228 229
         "Returns field's value prepared for database lookup."
  230
+        if hasattr(value, 'as_sql'):
  231
+            sql, params = value.as_sql()
  232
+            return QueryWrapper(('(%s)' % sql), params)
229 233
         if lookup_type in ('exact', 'regex', 'iregex', 'gt', 'gte', 'lt', 'lte', 'month', 'day', 'search'):
230 234
             return [value]
231 235
         elif lookup_type in ('range', 'in'):

0 notes on commit 1bb8260

Please sign in to comment.
Something went wrong with that request. Please try again.