Ticket #10071: 10071-month_day_weekday_lookups_as_ints-r10454.diff

File 10071-month_day_weekday_lookups_as_ints-r10454.diff, 1.5 KB (added by Ramiro Morales, 16 years ago)

Updated Leo's patch to post-week_day lookup adition (r9818)

  • django/db/backends/sqlite3/base.py

    diff -r dbeb834dc792 django/db/backends/sqlite3/base.py
    a b  
    211211    except (ValueError, TypeError):
    212212        return None
    213213    if lookup_type == 'week_day':
    214         return unicode((dt.isoweekday() % 7) + 1)
     214        return (dt.isoweekday() % 7) + 1
    215215    else:
    216         return unicode(getattr(dt, lookup_type))
     216        return getattr(dt, lookup_type)
    217217
    218218def _sqlite_date_trunc(lookup_type, dt):
    219219    try:
  • django/db/models/fields/__init__.py

    diff -r dbeb834dc792 django/db/models/fields/__init__.py
    a b  
    493493                curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=False))
    494494
    495495    def get_db_prep_lookup(self, lookup_type, value):
    496         # For "__month", "__day", and "__week_day" lookups, convert the value 
    497         # to a string so the database backend always sees a consistent type.
     496        # For "__month", "__day", and "__week_day" lookups, convert the value
     497        # to an int so the database backend always sees a consistent type.
    498498        if lookup_type in ('month', 'day', 'week_day'):
    499             return [force_unicode(value)]
     499            return [int(value)]
    500500        return super(DateField, self).get_db_prep_lookup(lookup_type, value)
    501501
    502502    def get_db_prep_value(self, value):
Back to Top