I'm running into a funny issue when testing with SQLite3 (Python 2.5).
I have a model with the following (simplified):
class Event(models.Model):
event_title = models.CharField()
event_from_date = models.DateField()
I create an event on 2008-01-01 (January 1st) and on 2008-01-02
(January 2nd).
I run the following in the shell:
In [10]: Event.objects.filter(event_from_date__year=2008)
Out[10]: [<Event: Event on 2nd.>]
In [11]: Event.objects.filter(event_from_date__month=1)
Out[11]: [<Event: Event On 1st.>, <Event: Event on 2nd.>]
In [12]: Event.objects.filter(event_from_date__year=2008,
event_from_date__month=1)
Out[12]: [<Event: Event on 2nd.>]
Here are the queries (I edited out a bunch of other fields from the
select clause, but nothing from the where clause, so they're not
exactly as output from django):
In [18]: connection.queries
Out[18]:
[{'sql': u'SELECT
"app_event"."id","app_event"."event_from_date","app_event"."title"
FROM "app_event" WHERE ("app_event"."event_from_date" BETWEEN
2008-01-01 00:00:00 AND 2008-12-31 23:59:59.999999) ORDER BY
"app_event"."event_from_date" ASC, "app_event"."title" ASC',
'time': '0.001'},
{'sql': u'SELECT
"app_event"."id","app_event"."event_from_date","app_event"."title"
FROM "app_event" WHERE (django_extract("month",
"app_event"."event_from_date") = 1) ORDER BY
"app_event"."event_from_date" ASC, "app_event"."title" ASC',
'time': '0.001'},
{'sql': u'SELECT
"app_event"."id","app_event"."event_from_date","app_event"."title"
FROM "app_event" WHERE (django_extract("month",
"app_event"."event_from_date") = 1 AND "app_event"."event_from_date"
BETWEEN 2008-01-01 00:00:00 AND 2008-12-31 23:59:59.999999) ORDER BY
"app_event"."event_from_date" ASC, "app_event"."title" ASC',
'time': '0.001'}]
Could it be that the 'year' predicate is missing the 'django_extract'
function?
Thanks for any help...
Doug Van Horn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---