| | 1 | = Test suite failures = |
| | 2 | |
| | 3 | [[TOC]] |
| | 4 | |
| | 5 | As Django 1.0, the test suite is showing the following failure(s) when run under Windows (XP 32 bits) + official Python 2.5.2: |
| | 6 | |
| | 7 | * Ticket #7570 when using the sqlite3 Django DB backend (official Python 2.5.2 Windows distribution which includes SQLite 3.3.4). |
| | 8 | |
| | 9 | == ticket #7570 == |
| | 10 | |
| | 11 | This test (and other two similar tests) fails: |
| | 12 | |
| | 13 | {{{ |
| | 14 | #!python |
| | 15 | Bug #7087 -- dates with extra select columns |
| | 16 | >>> Item.objects.dates('created', 'day').extra(select={'a': 1}) |
| | 17 | [datetime.datetime(2007, 12, 19, 0, 0), datetime.datetime(2007, 12, 20, 0, 0)] |
| | 18 | }}} |
| | 19 | |
| | 20 | Error is: |
| | 21 | |
| | 22 | {{{ |
| | 23 | ====================================================================== |
| | 24 | FAIL: Doctest: regressiontests.queries.models.__test__.API_TESTS |
| | 25 | ---------------------------------------------------------------------- |
| | 26 | Traceback (most recent call last): |
| | 27 | File "C:\ramiro\django-trunk\django\test\_doctest.py", line 2180, in runTest |
| | 28 | raise self.failureException(self.format_failure(new.getvalue())) |
| | 29 | AssertionError: Failed doctest test for regressiontests.queries.models.__test__.API_TESTS |
| | 30 | File "C:\ramiro\django-trunk\tests\regressiontests\queries\models.py", line unknown line number, in API_TESTS |
| | 31 | |
| | 32 | ---------------------------------------------------------------------- |
| | 33 | File "C:\ramiro\django-trunk\tests\regressiontests\queries\models.py", line ?, in regressiontests.queries.models.__test__.API_TESTS |
| | 34 | Failed example: |
| | 35 | Item.objects.dates('created', 'day').extra(select={'a': 1}) |
| | 36 | Exception raised: |
| | 37 | Traceback (most recent call last): |
| | 38 | File "C:\ramiro\django-trunk\django\test\_doctest.py", line 1267, in __run |
| | 39 | compileflags, 1) in test.globs |
| | 40 | File "<doctest regressiontests.queries.models.__test__.API_TESTS[169]>", line 1, in <module> |
| | 41 | Item.objects.dates('created', 'day').extra(select={'a': 1}) |
| | 42 | File "c:\ramiro\django-trunk\django\db\models\query.py", line 129, in __repr__ |
| | 43 | return repr(list(self)) |
| | 44 | File "c:\ramiro\django-trunk\django\db\models\query.py", line 141, in __len__ |
| | 45 | self._result_cache.extend(list(self._iter)) |
| | 46 | File "c:\ramiro\django-trunk\django\db\models\sql\subqueries.py", line 351, in results_iter |
| | 47 | for rows in self.execute_sql(MULTI): |
| | 48 | File "c:\ramiro\django-trunk\django\db\models\sql\query.py", line 1607, in execute_sql |
| | 49 | cursor.execute(sql, params) |
| | 50 | File "c:\ramiro\django-trunk\django\db\backends\sqlite3\base.py", line 136, in execute |
| | 51 | return Database.Cursor.execute(self, query, params) |
| | 52 | OperationalError: ORDER BY terms must not be non-integer constants |
| | 53 | |
| | 54 | |
| | 55 | ---------------------------------------------------------------------- |
| | 56 | Ran 253 tests in 433.032s |
| | 57 | |
| | 58 | FAILED (failures=1) |
| | 59 | }}} |
| | 60 | |
| | 61 | The SQL being generated by Django is correct: |
| | 62 | |
| | 63 | {{{ |
| | 64 | #!python |
| | 65 | >>> Item.objects.dates('created', 'day').extra(select={'a': 1}).query.as_sql() |
| | 66 | ('SELECT DISTINCT (1) AS "a", django_date_trunc("day", "sqlite3_dates_item"."created") FROM "sqlite3_dates_item" ORDER BY 1 ASC', ()) |
| | 67 | }}} |
| | 68 | |
| | 69 | The problem has been tracked down to a bug in SQLite in version older than 3.3.6. |
| | 70 | |
| | 71 | === Solution === |
| | 72 | |
| | 73 | See http://docs.djangoproject.com/en/dev/ref/databases/#id5 |