mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #24018 -- Allowed setting pragma options on SQLite.
This commit is contained in:
committed by
Mariusz Felisiak
parent
66e47ac69a
commit
7a05b8a2fa
@@ -187,6 +187,9 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
f"{allowed_transaction_modes}, or None."
|
||||
)
|
||||
self.transaction_mode = transaction_mode.upper() if transaction_mode else None
|
||||
|
||||
init_command = kwargs.pop("init_command", "")
|
||||
self.init_commands = init_command.split(";")
|
||||
return kwargs
|
||||
|
||||
def get_database_version(self):
|
||||
@@ -201,6 +204,9 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
# The macOS bundled SQLite defaults legacy_alter_table ON, which
|
||||
# prevents atomic table renames.
|
||||
conn.execute("PRAGMA legacy_alter_table = OFF")
|
||||
for init_command in self.init_commands:
|
||||
if init_command := init_command.strip():
|
||||
conn.execute(init_command)
|
||||
return conn
|
||||
|
||||
def create_cursor(self, name=None):
|
||||
|
||||
Reference in New Issue
Block a user