When calling the dates() method on a queryset with extra selection columns, we can (and should) ignore those columns. They don't change the result and cause incorrect SQL to be produced otherwise.
(self)
| 173 | ) |
| 174 | |
| 175 | def test_dates_query(self): |
| 176 | """ |
| 177 | When calling the dates() method on a queryset with extra selection |
| 178 | columns, we can (and should) ignore those columns. They don't change |
| 179 | the result and cause incorrect SQL to be produced otherwise. |
| 180 | """ |
| 181 | RevisionableModel.objects.create( |
| 182 | title="First Revision", when=datetime.datetime(2008, 9, 28, 10, 30, 0) |
| 183 | ) |
| 184 | |
| 185 | self.assertSequenceEqual( |
| 186 | RevisionableModel.objects.extra(select={"the_answer": "id"}).datetimes( |
| 187 | "when", "month" |
| 188 | ), |
| 189 | [datetime.datetime(2008, 9, 1, 0, 0)], |
| 190 | ) |
| 191 | |
| 192 | def test_values_with_extra(self): |
| 193 | """ |