Opened 17 years ago
Closed 16 years ago
#6922 closed (duplicate)
querying DateTimeFields using the "in" query fails under sqlite
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | DateTimeField, in, SQLite | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When using the "in" query with a DateTimeField (in this case, DateField) with the SQLite backend, Django throws a TypeError. It doesn't matter whether the argument is a string or a datetime object. The same field can successfully be queried with the "range" query.
I didn't have time to look at the offending library code completely, but the problem appears to be a tuple vs. string/string character bug.
Traceback (most recent call last): File "querytst.py", line 14, in <module> print Complaint.objects.filter(incident_date__in=[datetime(2008, 2, 14)]).count() File "/Library/Python/2.5/site-packages/django/db/models/query.py", line 243, in count cursor.execute("SELECT COUNT(*)" + sql, params) File "/Library/Python/2.5/site-packages/django/db/backends/util.py", line 21, in execute sql = self.db.ops.last_executed_query(self.cursor, sql, params) File "/Library/Python/2.5/site-packages/django/db/backends/__init__.py", line 150, in last_executed_query return smart_unicode(sql) % u_params TypeError: not all arguments converted during string formatting
Change History (3)
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 17 years ago
Triage Stage: | Accepted → Unreviewed |
---|
sorry, this appears to be completely different, as its happening in mysql also
the bug in this ticket may be fixed due to qsrf
comment:3 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
in r7631, I'm not getting an exception doing this in sqlite, but it does seem to be failing silently:
so there definitely seems to be something wrong