Refs #30055 -- Added a helpful error when SQLite is too old.

This commit is contained in:
Tim Graham 2019-01-28 11:14:45 -05:00 committed by GitHub
parent fcfb730658
commit 7444f32527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -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))

View File

@ -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).