mirror of https://github.com/django/django.git
[2.2.x] Refs #30055 -- Added a helpful error when SQLite is too old.
Backport of 7444f32527
from master.
This commit is contained in:
parent
e8cb0dcc19
commit
d3b4f4b962
|
@ -58,6 +58,13 @@ def list_aggregate(function):
|
|||
return type('ListAggregate', (list,), {'finalize': function, 'step': list.append})
|
||||
|
||||
|
||||
def check_sqlite_version():
|
||||
if Database.sqlite_version_info < (3, 8, 3):
|
||||
raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' % Database.sqlite_version)
|
||||
|
||||
|
||||
check_sqlite_version()
|
||||
|
||||
Database.register_converter("bool", b'1'.__eq__)
|
||||
Database.register_converter("time", decoder(parse_time))
|
||||
Database.register_converter("datetime", decoder(parse_datetime))
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
import re
|
||||
import threading
|
||||
import unittest
|
||||
from sqlite3 import dbapi2
|
||||
from unittest import mock
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import connection, transaction
|
||||
from django.db.backends.sqlite3.base import check_sqlite_version
|
||||
from django.db.models import Avg, StdDev, Sum, Variance
|
||||
from django.db.models.aggregates import Aggregate
|
||||
from django.db.models.fields import CharField
|
||||
|
@ -19,6 +23,13 @@ from ..models import Author, Item, Object, Square
|
|||
class Tests(TestCase):
|
||||
longMessage = True
|
||||
|
||||
def test_check_sqlite_version(self):
|
||||
msg = 'SQLite 3.8.3 or later is required (found 3.8.2).'
|
||||
with mock.patch.object(dbapi2, 'sqlite_version_info', (3, 8, 2)), \
|
||||
mock.patch.object(dbapi2, 'sqlite_version', '3.8.2'), \
|
||||
self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
check_sqlite_version()
|
||||
|
||||
def test_aggregation(self):
|
||||
"""
|
||||
Raise NotImplementedError when aggregating on date/time fields (#19360).
|
||||
|
|
Loading…
Reference in New Issue