Code

Ticket #7155: dates-qsrf-7155.diff

File dates-qsrf-7155.diff, 2.1 KB (added by jdunck, 6 years ago)

Updated patch with regression test included.

Line 
1Index: django-gis-7543/django/db/models/query.py
2===================================================================
3--- django-gis-7543.orig/django/db/models/query.py      2008-05-29 19:00:19.000000000 -0500
4+++ django-gis-7543/django/db/models/query.py   2008-05-29 19:01:50.000000000 -0500
5@@ -598,7 +598,7 @@
6         self.query.select = []
7         self.query.add_date_select(self._field.column, self._kind, self._order)
8         if self._field.null:
9-            self.query.add_filter(('%s__isnull' % self._field.name, True))
10+            self.query.add_filter(('%s__isnull' % self._field.name, False))
11 
12     def _clone(self, klass=None, setup=False, **kwargs):
13         c = super(DateQuerySet, self)._clone(klass, False, **kwargs)
14Index: django-gis-7543/tests/regressiontests/queries/models.py
15===================================================================
16--- django-gis-7543.orig/tests/regressiontests/queries/models.py        2008-05-29 19:00:15.000000000 -0500
17+++ django-gis-7543/tests/regressiontests/queries/models.py     2008-05-29 19:01:36.000000000 -0500
18@@ -45,6 +45,7 @@
19 class Item(models.Model):
20     name = models.CharField(max_length=10)
21     created = models.DateTimeField()
22+    modified = models.DateTimeField(blank=True, null=True)
23     tags = models.ManyToManyField(Tag, blank=True, null=True)
24     creator = models.ForeignKey(Author)
25     note = models.ForeignKey(Note)
26@@ -174,7 +175,7 @@
27 >>> time2 = datetime.datetime(2007, 12, 19, 21, 0, 0)
28 >>> time3 = datetime.datetime(2007, 12, 20, 22, 25, 0)
29 >>> time4 = datetime.datetime(2007, 12, 20, 21, 0, 0)
30->>> i1 = Item(name='one', created=time1, creator=a1, note=n3)
31+>>> i1 = Item(name='one', created=time1, modified=time1, creator=a1, note=n3)
32 >>> i1.save()
33 >>> i1.tags = [t1, t2]
34 >>> i2 = Item(name='two', created=time2, creator=a2, note=n2)
35@@ -620,6 +621,10 @@
36 >>> Item.objects.dates('created', 'day').extra(select={'a': 1})
37 [datetime.datetime(2007, 12, 19, 0, 0), datetime.datetime(2007, 12, 20, 0, 0)]
38 
39+Bug #7155 -- nullable dates
40+>>> Item.objects.dates('modified', 'day')
41+[datetime.datetime(2007, 12, 19, 0, 0)]
42+
43 Test that parallel iterators work.
44 
45 >>> qs = Tag.objects.all()