mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #24018 -- Allowed setting pragma options on SQLite.
This commit is contained in:
committed by
Mariusz Felisiak
parent
66e47ac69a
commit
7a05b8a2fa
@@ -116,6 +116,29 @@ class Tests(TestCase):
|
||||
connection.check_database_version_supported()
|
||||
self.assertTrue(mocked_get_database_version.called)
|
||||
|
||||
def test_init_command(self):
|
||||
settings_dict = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": ":memory:",
|
||||
"OPTIONS": {
|
||||
"init_command": "PRAGMA synchronous=3; PRAGMA cache_size=2000;",
|
||||
},
|
||||
}
|
||||
}
|
||||
connections = ConnectionHandler(settings_dict)
|
||||
connections["default"].ensure_connection()
|
||||
try:
|
||||
with connections["default"].cursor() as cursor:
|
||||
cursor.execute("PRAGMA synchronous")
|
||||
value = cursor.fetchone()[0]
|
||||
self.assertEqual(value, 3)
|
||||
cursor.execute("PRAGMA cache_size")
|
||||
value = cursor.fetchone()[0]
|
||||
self.assertEqual(value, 2000)
|
||||
finally:
|
||||
connections["default"].close()
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests")
|
||||
@isolate_apps("backends")
|
||||
|
||||
Reference in New Issue
Block a user