#7707 closed (duplicate)
DateField/DateTimeField `in` lookup support
Reported by: | Alexander Koshelev | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | DateField DateTimeField lookup | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
ORM doesn't support 'in' lookups for DateField/DateTimeField fields.
Example from test:
class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateTimeField() class Meta: ordering = ('-pub_date', 'headline') def __unicode__(self): return self.headline Article.objects.filter(pub_date__in=[datetime(2005, 7, 26), datetime(2005, 7, 28)])
And it produces wrong SQL:
('SELECT `lookup_article`.`id`, `lookup_article`.`headline`, `lookup_article`.`pub_date` FROM `lookup_article` WHERE `lookup_article`.`pub_date` IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) ORDER BY `lookup_article`.`pub_date` DESC, `lookup_article`.`headline` ASC', (u'[', u'd', u'a', u't', u'e',u't', u'i', u'm', u'e', u'.', u'd', u'a', u't', u'e', u't', u'i', u'm', u'e', u'(', u'2', u'0', u'0', u'5', u',', u' ', u'7', u',', u' ', u'2', u'6', u',', u' ', u'0', u',', u' ', u'0', u')', u',', u' ', u'd', u'a', u't', u'e', u't', u'i', u'm', u'e', u'.', u'd', u'a', u't', u'e', u't', u'i', u'm', u'e', u'(', u'2', u'0', u'0', u'5', u',', u' ', u'7', u',', u' ', u'2', u'8', u',', u' ', u'0', u',', u' ', u'0', u')', u']'))
Attachments (1)
Change History (7)
by , 16 years ago
comment:1 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
#7448 already covers this, I believe.
comment:2 by , 16 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
My solution is better and has test case.
comment:3 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
comment:5 by , 16 years ago
Note:
See TracTickets
for help on using tickets.
path