diff options
| author | Дилян Палаузов <Dilyan.Palauzov@db.com> | 2018-01-03 18:52:12 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-03 20:12:23 -0500 |
| commit | d7b2aa24f75434c2ce50100cfef3586071e0747a (patch) | |
| tree | 9074eb7522888e744f948c52174f367a4281c200 /django/db/backends | |
| parent | c2d0f8c084456b5073252a91eeb09ab3d7453b18 (diff) | |
Fixed #28982 -- Simplified code with and/or.
Diffstat (limited to 'django/db/backends')
| -rw-r--r-- | django/db/backends/mysql/schema.py | 4 | ||||
| -rw-r--r-- | django/db/backends/postgresql/creation.py | 4 | ||||
| -rw-r--r-- | django/db/backends/postgresql/operations.py | 8 |
3 files changed, 5 insertions, 11 deletions
diff --git a/django/db/backends/mysql/schema.py b/django/db/backends/mysql/schema.py index 24abdaf611..997fef1c0c 100644 --- a/django/db/backends/mysql/schema.py +++ b/django/db/backends/mysql/schema.py @@ -61,9 +61,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): field.get_internal_type() == 'ForeignKey' and field.db_constraint): return False - if self._is_limited_data_type(field): - return False - return create_index + return not self._is_limited_data_type(field) and create_index def _delete_composed_index(self, model, fields, *args): """ diff --git a/django/db/backends/postgresql/creation.py b/django/db/backends/postgresql/creation.py index a93bdbb4a1..0169fc5c1f 100644 --- a/django/db/backends/postgresql/creation.py +++ b/django/db/backends/postgresql/creation.py @@ -16,9 +16,7 @@ class DatabaseCreation(BaseDatabaseCreation): suffix += " ENCODING '{}'".format(encoding) if template: suffix += " TEMPLATE {}".format(self._quote_name(template)) - if suffix: - suffix = "WITH" + suffix - return suffix + return suffix and "WITH" + suffix def sql_table_creation_suffix(self): test_settings = self.connection.settings_dict['TEST'] diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index 06a46f4303..3b71cd4f2c 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -131,11 +131,9 @@ class DatabaseOperations(BaseDatabaseOperations): sql = [] for sequence_info in sequences: table_name = sequence_info['table'] - column_name = sequence_info['column'] - if not column_name: - # This will be the case if it's an m2m using an autogenerated - # intermediate table (see BaseDatabaseIntrospection.sequence_list) - column_name = 'id' + # 'id' will be the case if it's an m2m using an autogenerated + # intermediate table (see BaseDatabaseIntrospection.sequence_list). + column_name = sequence_info['column'] or 'id' sql.append("%s setval(pg_get_serial_sequence('%s','%s'), 1, false);" % ( style.SQL_KEYWORD('SELECT'), style.SQL_TABLE(self.quote_name(table_name)), |
