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