#8416: Using Sqlite as database backend causes list_filter and date_hierarchy
misbehave in Admin pages
--------------------------------------+-------------------------------------
Reporter: amiroff | Owner: nobody
Status: new | Milestone: 1.0
Component: django-admin.py | Version: SVN
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------+-------------------------------------
Comment (by haakeyar):
Ok, I promised some details.
I am running SQLite 3.5.6, Django trunk r8467, Python 2.5.1.
As I said, the same query appears to be run both when using a string and
when using an integer for {{{__month}}}:
{{{
class DateModel(models.Model):
date_field = models.DateTimeField()
}}}
{{{
In [1]: from myapp.models import DateModel
In [2]: from datetime import datetime
In [3]: DateModel(date_field=datetime(2008,8,22)).save()
In [4]: DateModel.objects.all()
Out[4]: [<DateModel: DateModel object>]
In [5]: DateModel.objects.filter(date_field__month=8)
Out[5]: [<DateModel: DateModel object>]
In [6]: DateModel.objects.filter(date_field__month='8')
Out[6]: []
In [7]: from django.db import connection
In [8]: connection.queries
Out[8]:
[{'sql': u'INSERT INTO "myapp_datemodel" ("date_field") VALUES (2008-08-22
00:00:00)',
'time': '0.003'},
{'sql': u'SELECT "myapp_datemodel"."id", "myapp_datemodel"."date_field"
FROM "myapp_datemodel"',
'time': '0.001'},
{'sql': u'SELECT "myapp_datemodel"."id", "myapp_datemodel"."date_field"
FROM "myapp_datemodel" WHERE django_extract("month",
"myapp_datemodel"."date_field") = 8',
'time': '0.001'},
{'sql': u'SELECT "myapp_datemodel"."id", "myapp_datemodel"."date_field"
FROM "myapp_datemodel" WHERE django_extract("month",
"myapp_datemodel"."date_field") = 8',
'time': '0.000'}]
}}}
I said that each time I used an interactive debugger (the one in Pydev for
Eclipse), I got the correct result even when using a string for
{{{__month}}}. I managed to repeat it today. Each time I follow the
execution quite deeply step by step, I get the correct result
({{{__date}}} as string returns the item). If I run the code through the
debugger without any breakpoints, or with a breakpoint, but continuing
instead of following the execution step by step, I get the wrong result
({{{__date}}} as string doesn't return any items).
These symptoms sound a lot like a race condition, don't they? I didn't
expect to find any threading code in the ORM, but a simple grep proved me
wrong. I haven't looked at the threading code, so I don't know what it
does, but maybe this is a race condition after all?
I will attach a simple test case, which passes in MySQL, but not in
SQLite. I haven't testet it with other DB backends.
--
Ticket URL: <http://code.djangoproject.com/ticket/8416#comment:2>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---