1
0
mirror of https://github.com/django/django.git synced 2025-06-12 15:09:12 +00:00

assume OPTIONS is always in DATABASES[alias]

This commit is contained in:
Ben Cail 2024-02-23 08:57:08 -05:00
parent cd5bb1ea4a
commit aa93853c5d
2 changed files with 9 additions and 11 deletions

View File

@ -291,10 +291,8 @@ class BaseDatabaseSchemaEditor:
),
}
db_tablespace = None
if (
settings.DATABASES[self.connection.alias]
.get("OPTIONS", {})
.get("DEFAULT_TABLESPACE")
if settings.DATABASES[self.connection.alias]["OPTIONS"].get(
"DEFAULT_TABLESPACE"
):
db_tablespace = settings.DATABASES[self.connection.alias]["OPTIONS"][
"DEFAULT_TABLESPACE"
@ -370,9 +368,9 @@ class BaseDatabaseSchemaEditor:
# Optionally add the tablespace if it's an implicitly indexed column.
tablespace = (
field.db_tablespace
or settings.DATABASES[self.connection.alias]
.get("OPTIONS", {})
.get("DEFAULT_TABLESPACE")
or settings.DATABASES[self.connection.alias]["OPTIONS"].get(
"DEFAULT_TABLESPACE"
)
or model._meta.db_tablespace
)
if (
@ -1532,7 +1530,7 @@ class BaseDatabaseSchemaEditor:
def _get_index_tablespace_sql(self, model, fields, db_tablespace=None):
if db_tablespace is None:
db_options = settings.DATABASES[self.connection.alias].get("OPTIONS", {})
db_options = settings.DATABASES[self.connection.alias]["OPTIONS"]
if len(fields) == 1 and fields[0].db_tablespace:
db_tablespace = fields[0].db_tablespace
elif db_options.get("DEFAULT_INDEX_TABLESPACE"):

View File

@ -924,9 +924,9 @@ class Field(RegisterLookupMixin):
def db_tablespace(self):
return (
self._db_tablespace
or settings.DATABASES[connection.alias]
.get("OPTIONS", {})
.get("DEFAULT_INDEX_TABLESPACE")
or settings.DATABASES[connection.alias]["OPTIONS"].get(
"DEFAULT_INDEX_TABLESPACE"
)
or settings.DEFAULT_INDEX_TABLESPACE
)