(self)
| 133 | |
| 134 | @skipUnless(connection.vendor == "mysql", "Test checks MySQL query syntax") |
| 135 | def test_dates_avoid_datetime_cast(self): |
| 136 | Article.objects.create(pub_date=datetime.date(2015, 10, 21)) |
| 137 | for kind in ["day", "month", "year"]: |
| 138 | qs = Article.objects.dates("pub_date", kind) |
| 139 | if kind == "day": |
| 140 | self.assertIn("DATE(", str(qs.query)) |
| 141 | else: |
| 142 | self.assertIn(" AS DATE)", str(qs.query)) |