Django

Code

Changeset 7883

Show
Ignore:
Timestamp:
07/11/08 04:00:35 (4 months ago)
Author:
mtredinnick
Message:

Fixed #7448 -- Convert "in" filters to pass in the correct values for datetimes
and similar complex objects.

Based on patches from cgrady and alexkosholev. Refs #7707.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/fields/__init__.py

    r7882 r7883  
    555555 
    556556    def get_db_prep_lookup(self, lookup_type, value): 
    557         if lookup_type == 'range'
     557        if lookup_type in ('range', 'in')
    558558            value = [smart_unicode(v) for v in value] 
    559559        elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte') and hasattr(value, 'strftime'): 
     
    642642 
    643643    def get_db_prep_lookup(self, lookup_type, value): 
    644         if lookup_type == 'range'
     644        if lookup_type in ('range', 'in')
    645645            value = [smart_unicode(v) for v in value] 
    646646        else: 
     
    721721 
    722722    def get_db_prep_lookup(self, lookup_type, value): 
    723         if lookup_type == 'range'
     723        if lookup_type in ('range', 'in')
    724724            value = [self._format(v) for v in value] 
    725725        else: 
     
    10981098        else: 
    10991099            prep = smart_unicode 
    1100         if lookup_type == 'range'
     1100        if lookup_type in ('range', 'in')
    11011101            value = [prep(v) for v in value] 
    11021102        else: 
  • django/trunk/tests/regressiontests/queries/models.py

    r7787 r7883  
    806806[] 
    807807 
     808Bug #7448, #7707 -- Complex objects should be converted to strings before being 
     809used in lookups. 
     810>>> Item.objects.filter(created__in=[time1, time2]) 
     811[<Item: one>, <Item: two>] 
     812 
    808813"""} 
    809814