Opened 18 years ago
Closed 17 years ago
#3689 closed (fixed)
__year search trouble on 1st of january
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | ||
Cc: | nesh@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I detected in a data_hierarchy filter a strange behavior of dates at 1.1. of a year. I have a field birthday defined as a models.DateField(...). I'm working with a sqlite3 database, python2.5 and django-trunk.
Selecting in the admin view the year say 1990 all dates above 1.1.1990 are selected but not the 1.1.1990 himself.
Maybe this was introduced by the [4505] patch!?
Regards,
Dirk
Attachments (4)
Change History (15)
by , 18 years ago
Attachment: | year-search.patch added |
---|
comment:1 by , 18 years ago
Has patch: | set |
---|---|
Needs tests: | set |
follow-up: 4 comment:2 by , 18 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
I'm pretty sure this is SQLite-specific and we've had similar bugs in the past. The problem is the SQLite does not treat "2007-01-01 00:00:00" the same as "2007-01-01" and we really need to be querying with the latter. Ticket #1460 shows the previous occurrence.
I think the change in this patch should not restrict the change just to the start date. That feels a bit asymmetrical. Shouldn't the final test also be "< (year+1)-01-01" ?
comment:3 by , 17 years ago
Cc: | added |
---|
comment:4 by , 17 years ago
Component: | Admin interface → Database wrapper |
---|
This is not just a admin problem any foo__year
query is affected. I hit it today in my non-admin related code.
Replying to mtredinnick:
I think the change in this patch should not restrict the change just to the start date. That feels a bit asymmetrical. Shouldn't the final test also be "< (year+1)-01-01" ?
Here is my stab at this, patch now checks <(year+1)-01-01
and I added some tests also (in tests/regressiontests/datatypes/models.py
hope that's OK)
Also, I found another place with 00:00:00
in _sqlite_date_trunc -- should we change this also?
(btw. should I change any of the triage fields after submitting patch?)
comment:5 by , 17 years ago
Strange, now I got:
File "/Users/nesh/Documents/workspace/django/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS Failed example: Article.objects.filter(pub_date__year=2004) Expected: [] Got: [<Article: Area woman programs in Python>]
Looking into it ...
comment:6 by , 17 years ago
Strange, now is OK, maybe probem was with %s-1-1
??
I added some future/past checks just to be sure.
comment:10 by , 17 years ago
Keywords: | qs-rf removed |
---|
comment:11 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
this would fix my problem