diff options
| author | Aaron Linville <aaron@linville.org> | 2023-08-17 18:06:25 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-02-16 12:59:19 +0100 |
| commit | 7a05b8a2fac57e32a61726893d4601352c1d1c8d (patch) | |
| tree | 186513f0f28bad17ced097853358e72609415ac5 /tests/backends/sqlite | |
| parent | 66e47ac69a7e71cf32eee312d05668d8f1ba24bb (diff) | |
Fixed #24018 -- Allowed setting pragma options on SQLite.
Diffstat (limited to 'tests/backends/sqlite')
| -rw-r--r-- | tests/backends/sqlite/tests.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py index 42fee432f9..91dd83f134 100644 --- a/tests/backends/sqlite/tests.py +++ b/tests/backends/sqlite/tests.py @@ -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") |
