mirror of
https://github.com/django/django.git
synced 2025-04-04 13:36:42 +00:00
move settings out of OPTIONS
This commit is contained in:
parent
0df7a40d51
commit
df723f1a16
@ -291,10 +291,8 @@ class BaseDatabaseSchemaEditor:
|
||||
),
|
||||
}
|
||||
db_tablespace = None
|
||||
if settings.DATABASES[self.connection.alias]["OPTIONS"].get(
|
||||
"DEFAULT_TABLESPACE"
|
||||
):
|
||||
db_tablespace = settings.DATABASES[self.connection.alias]["OPTIONS"][
|
||||
if settings.DATABASES[self.connection.alias].get("DEFAULT_TABLESPACE"):
|
||||
db_tablespace = settings.DATABASES[self.connection.alias][
|
||||
"DEFAULT_TABLESPACE"
|
||||
]
|
||||
elif model._meta.db_tablespace:
|
||||
@ -368,9 +366,7 @@ class BaseDatabaseSchemaEditor:
|
||||
# Optionally add the tablespace if it's an implicitly indexed column.
|
||||
tablespace = (
|
||||
field.db_tablespace
|
||||
or settings.DATABASES[self.connection.alias]["OPTIONS"].get(
|
||||
"DEFAULT_TABLESPACE"
|
||||
)
|
||||
or settings.DATABASES[self.connection.alias].get("DEFAULT_TABLESPACE")
|
||||
or model._meta.db_tablespace
|
||||
)
|
||||
if (
|
||||
@ -1530,15 +1526,15 @@ 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]["OPTIONS"]
|
||||
db_settings = settings.DATABASES[self.connection.alias]
|
||||
if len(fields) == 1 and fields[0].db_tablespace:
|
||||
db_tablespace = fields[0].db_tablespace
|
||||
elif db_options.get("DEFAULT_INDEX_TABLESPACE"):
|
||||
db_tablespace = db_options["DEFAULT_INDEX_TABLESPACE"]
|
||||
elif db_settings.get("DEFAULT_INDEX_TABLESPACE"):
|
||||
db_tablespace = db_settings["DEFAULT_INDEX_TABLESPACE"]
|
||||
elif settings.DEFAULT_INDEX_TABLESPACE:
|
||||
db_tablespace = settings.DEFAULT_INDEX_TABLESPACE
|
||||
elif db_options.get("DEFAULT_TABLESPACE"):
|
||||
db_tablespace = db_options["DEFAULT_TABLESPACE"]
|
||||
elif db_settings.get("DEFAULT_TABLESPACE"):
|
||||
db_tablespace = db_settings["DEFAULT_TABLESPACE"]
|
||||
elif model._meta.db_tablespace:
|
||||
db_tablespace = model._meta.db_tablespace
|
||||
if db_tablespace is not None:
|
||||
|
@ -924,9 +924,7 @@ class Field(RegisterLookupMixin):
|
||||
def db_tablespace(self):
|
||||
return (
|
||||
self._db_tablespace
|
||||
or settings.DATABASES[connection.alias]["OPTIONS"].get(
|
||||
"DEFAULT_INDEX_TABLESPACE"
|
||||
)
|
||||
or settings.DATABASES[connection.alias].get("DEFAULT_INDEX_TABLESPACE")
|
||||
or settings.DEFAULT_INDEX_TABLESPACE
|
||||
)
|
||||
|
||||
|
@ -433,8 +433,8 @@ Miscellaneous
|
||||
* Overriding existing converters with ``django.urls.register_converter()`` is
|
||||
deprecated.
|
||||
* The :setting:`DEFAULT_TABLESPACE` and :setting:`DEFAULT_INDEX_TABLESPACE`
|
||||
settings are deprecated. Set them in the :setting:`OPTIONS` part of your
|
||||
database configuration in :setting:`DATABASES` instead.
|
||||
settings are deprecated. Set them in your database configuration in
|
||||
:setting:`DATABASES` instead.
|
||||
|
||||
* The ``check`` keyword argument of ``CheckConstraint`` is deprecated in favor
|
||||
of ``condition``.
|
||||
|
@ -21,8 +21,8 @@ the :attr:`~django.db.models.Options.db_tablespace` option inside the model's
|
||||
``class Meta``. This option also affects tables automatically created for
|
||||
:class:`~django.db.models.ManyToManyField`\ s in the model.
|
||||
|
||||
You can use ``DEFAULT_TABLESPACE`` in the :setting:`OPTIONS` part of your
|
||||
database configuration in :setting:`DATABASES` to specify a default value for
|
||||
You can use ``DEFAULT_TABLESPACE`` in your database configuration in
|
||||
:setting:`DATABASES` to specify a default value for
|
||||
:attr:`~django.db.models.Options.db_tablespace`. This is useful for setting a
|
||||
tablespace for the built-in Django apps and other applications whose code you
|
||||
cannot control.
|
||||
@ -41,8 +41,8 @@ For single field indexes, you can pass the
|
||||
to specify an alternate tablespace for the field's column index. If the column
|
||||
doesn't have an index, the option is ignored.
|
||||
|
||||
You can use ``DEFAULT_INDEX_TABLESPACE`` in the :setting:`OPTIONS` part of your
|
||||
database configuration in :setting:`DATABASES` to specify a default value for
|
||||
You can use ``DEFAULT_INDEX_TABLESPACE`` in your database configuration in
|
||||
:setting:`DATABASES` to specify a default value for
|
||||
:attr:`~django.db.models.Field.db_tablespace`.
|
||||
|
||||
If :attr:`~django.db.models.Field.db_tablespace` isn't specified and you didn't
|
||||
|
@ -154,7 +154,7 @@ class DefaultTablespaceTests(TransactionTestCase):
|
||||
def test_default_tablespace(self):
|
||||
tablespace = "default_tablespace"
|
||||
databases = copy.deepcopy(settings.DATABASES)
|
||||
databases["default"]["OPTIONS"]["DEFAULT_TABLESPACE"] = tablespace
|
||||
databases["default"]["DEFAULT_TABLESPACE"] = tablespace
|
||||
with self.settings(DATABASES=databases):
|
||||
|
||||
class ScientistRef(models.Model):
|
||||
@ -170,7 +170,7 @@ class DefaultTablespaceTests(TransactionTestCase):
|
||||
def test_default_index_tablespace(self):
|
||||
index_tablespace = "default_index_tablespace"
|
||||
databases = copy.deepcopy(settings.DATABASES)
|
||||
databases["default"]["OPTIONS"]["DEFAULT_INDEX_TABLESPACE"] = index_tablespace
|
||||
databases["default"]["DEFAULT_INDEX_TABLESPACE"] = index_tablespace
|
||||
with self.settings(DATABASES=databases):
|
||||
|
||||
class ScientistRef(models.Model):
|
||||
|
Loading…
x
Reference in New Issue
Block a user