mirror of
https://github.com/django/django.git
synced 2025-12-04 00:55:36 +00:00
Fixed #24018 -- Allowed setting pragma options on SQLite.
This commit is contained in:
parent
66e47ac69a
commit
7a05b8a2fa
6 changed files with 62 additions and 0 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue