Commit Graph

193 Commits

Author SHA1 Message Date
Jon Dufresne f02c1fcf4c
Corrected typo in test docstring. 2020-02-20 09:12:09 +01:00
Nick Pope 335c9c94ac Simplified imports from django.db and django.contrib.gis.db. 2020-02-04 13:20:06 +01:00
Mariusz Felisiak 22ce5d0031
Fixed #31106 -- Fixed migrations crash on PostgreSQL 10+ when adding FK constraints inline and changing data.
This allows adding foreign key constraints inline and changing data in
the same migration on PostgreSQL 10+.

Regression in 738faf9da2.

Thanks Janne Rönkkö for the report and Simon Charette for the
implementation idea and review.
2019-12-23 23:28:59 +01:00
Nick Pope 7552de7866 Used more specific unittest assertions in tests.
* assertIsNone()/assertIsNotNone() instead of comparing to None.
* assertLess() for < comparisons.
* assertIs() for 'is' expressions.
* assertIsInstance() for isinstance() expressions.
* rounding of assertAlmostEqual() for round() expressions.
* assertIs(..., True/False) instead of comparing to True/False.
* assertIs()/assertIsNot() for ==/!= comparisons.
* assertNotEqual() for == comparisons.
* assertTrue()/assertFalse() instead of comparing to True/False.
2019-10-29 12:37:30 +01:00
Hasan Ramezani ef4beafa2c Refs #28816 -- Prevented silencing data loss when decreasing CharField.max_length for ArrayField.base_field on PostgreSQL. 2019-10-17 12:50:53 +02:00
Mariusz Felisiak 580e644f24
Fixed #30800 -- Fixed migrations crash when altering a field with custom db_type().
Regression in 1378d665a1.
2019-09-25 12:32:24 +02:00
Mariusz Felisiak c8250ef361
Refs #27338 -- Added tests for altering CharField with primary_key=True to AutoField on PostgreSQL.
Fixed in 91b2bc3e70.
2019-09-11 13:40:49 +02:00
Hasan Ramezani b93d786251 Made SchemaTests.test_alter_db_table_case run only on backends where table names are case-insensitive. 2019-09-05 08:59:48 +02:00
Min ho Kim 7bd9633320 Fixed typos in test names and a comment. 2019-08-23 10:46:43 +02:00
Nick Pope 194d1dfc18 Fixed #30661 -- Added models.SmallAutoField. 2019-08-02 11:39:01 +02:00
Mariusz Felisiak ff111ea5e3 Refs #30664 -- Fixed migrations crash when altering AutoField/BigAutoField with quoted db_column on PostgreSQL. 2019-08-01 12:06:32 +02:00
Ngalim Siregar e4684220af Fixed #30664 -- Fixed migrations crash when altering table on SQLite or altering AutoField/BigAutoField on PostgreSQL for models with quoted db_table. 2019-08-01 12:06:32 +02:00
Hasan Ramezani 1fc2c70f76 Fixed #30593 -- Added support for check constraints on MariaDB 10.2+. 2019-07-19 11:05:06 +02:00
Mariusz Felisiak 8233144ca0 Changed django.db.models.indexes.Index imports to django.db.models.Index. 2019-07-08 14:19:46 +02:00
Hasan Ramezani 1378d665a1 Fixed #28816 -- Prevented silencing data loss when decreasing CharField.max_length on PostgreSQL. 2019-05-21 14:15:43 +02:00
Dolan Antenucci f944cb3d3b
Fixed #30266 -- Kept a sequence owner when altering an AutoField/BigAutoField on PostgreSQL. 2019-04-08 22:24:18 +02:00
Paveł Tyślacki 5c17c273ae Refs #30172 -- Prevented removing a model Meta's index/unique_together from removing Meta constraints/indexes. 2019-03-17 20:50:57 -04:00
Paveł Tyślacki 4bb859e246 Refs #30172 -- Prevented removing a field's check or unique constraint from removing Meta constraints. 2019-03-17 20:50:22 -04:00
Paveł Tyślacki 782d85b6df Fixed #30183 -- Added introspection of inline SQLite constraints. 2019-03-13 10:24:28 -04:00
Dan Tao 738faf9da2 Fixed #30108 -- Allowed adding foreign key constraints in the same statement that adds a field. 2019-01-29 15:42:57 -05:00
Paveł Tyślacki 0123b67f6b Fixed #30060 -- Moved SQL generation for indexes and constraints to SchemaEditor. 2019-01-01 09:39:58 -05:00
Tim Graham 0b54ab0675 Refs #30033 -- Fixed schema's test_m2m_rename_field_in_target_model test failure on SQLite < 3.20.
Mixing local test models with non-local models resulted in a referential
integrity error during tear down since the models are removed in separate
schema editor instances which each check constraints.

Failure appeared after 7289874adc.
2018-12-26 11:26:51 -05:00
Mariusz Felisiak d5f4ce9849
Fixed #29949 -- Refactored db introspection identifier converters.
Removed DatabaseIntrospection.table_name_converter()/column_name_converter()
and use instead DatabaseIntrospection.identifier_converter().

Removed DatabaseFeatures.uppercases_column_names.

Thanks Tim Graham for the initial patch and review and Simon Charette
for the review.
2018-11-21 09:06:50 +01:00
Simon Charette dba4a634ba Refs #29641 -- Refactored database schema constraint creation.
Added a test for constraint names in the database.

Updated SQLite introspection to use sqlparse to allow reading the
constraint name for table check and unique constraints.

Co-authored-by: Ian Foote <python@ian.feete.org>
2018-11-13 15:25:44 -05:00
Mads Jensen a906c98982 Fixed #29547 -- Added support for partial indexes.
Thanks to Ian Foote, Mariusz Felisiak, Simon Charettes, and
Markus Holtermann for comments and feedback.
2018-10-29 19:34:54 -04:00
Oleg d1d5c97bc2 Fixed #29778 -- Fixed quoting of unique index names.
Regression in 3b429c9673.
2018-09-25 16:00:20 -04:00
Mariusz Felisiak 6dd4edb1b4
Fixed #29496 -- Fixed crash on Oracle when converting a non-unique field to primary key.
Thanks Tim Graham for the review.
2018-06-17 08:51:02 +02:00
Claude Paroz 607970f31c Replaced django.test.utils.patch_logger() with assertLogs().
Thanks Tim Graham for the review.
2018-05-07 09:34:00 -04:00
Tim Graham 78f8b80f9b Fixed schema test failure when running tests in reverse.
Follow up to 003334f8af.
2018-04-12 13:59:02 -04:00
Jeremy Bowman ee17bb8a67 Fixed #29193 -- Prevented unnecessary foreign key drops when altering a unique field.
Stopped dropping and recreating foreign key constraints on other fields
in the same table as the one which is actually being altered in an
AlterField operation.

Regression in c3e0adcad8.
2018-04-11 23:17:11 -04:00
Jeremy Bowman 003334f8af Tested altering a unique field when a reverse M2M relation exists. 2018-04-11 23:17:11 -04:00
Tim Graham 6421bd702f Refs #29227 -- Made inspectdb generate BooleanField(null=True) rather than NullBooleanField. 2018-03-20 12:10:10 -04:00
Claude Paroz 3c4ff21763 Fixed #29103 -- Removed bad 'b'-prefix added by MySQL's SchemaEditor.quote_value(). 2018-03-17 16:36:54 -04:00
Tim Graham fb8fd535c0 Moved SchemaLoggingTest to tests/schema. 2018-03-14 10:24:34 -04:00
Tim Martin 02365d3f38 Fixed #28542 -- Fixed deletion of primary key constraint if the new field is unique. 2018-01-13 20:11:55 -05:00
Tim Graham 5f456408a0 Refs #28930 -- Simplified schemas test with any(). 2018-01-02 10:11:48 -05:00
Simon Charette 9f7772e098 Fixed #28884 -- Fixed crash on SQLite when renaming a field in a model referenced by a ManyToManyField.
Introspected database constraints instead of relying on _meta.related_objects
to determine whether or not a table or a column is referenced on rename
operations.

This has the side effect of ignoring both db_constraint=False and virtual
fields such as GenericRelation which aren't backend by database level
constraints and thus shouldn't prevent the rename operations from being
performed in a transaction.

Regression in 095c1aaa89.

Thanks Tim for the additional tests and edits, and Mariusz for the review.
2017-12-22 15:19:05 -05:00
Tim Graham a862af3839
Fixed #28893 -- Removed unnecessary dict.items() calls. 2017-12-06 17:17:59 -05:00
Mariusz Felisiak fc48047586
Refs #28876 -- Fixed incorrect foreign key constraint name for models with quoted db_table.
Thanks Simon Charette and Tim Graham for the review and Carlos E. C.
Leite for the report.
2017-12-05 21:11:20 +01:00
Simon Charette 095c1aaa89 Fixed #28849 -- Fixed referenced table and column rename on SQLite.
Thanks Ramiro for the input and Tim for the review.
2017-12-01 22:12:24 -05:00
Simon Charette ee85ef8315 Fixed #28792 -- Fixed index name truncation of namespaced tables.
Refs #27458, #27843.

Thanks Tim and Mariusz for the review.
2017-11-14 21:36:25 -05:00
Tim Graham 8a1768432b Fixed #28552 -- Dropped support for MySQL 5.5. 2017-09-25 14:48:11 -04:00
Sergey Fedoseev 5b1c389603 Refs #23919 -- Replaced usage of django.utils.functional.curry() with functools.partial()/partialmethod(). 2017-09-06 13:11:18 -04:00
Claude Paroz 169c3b3e07 Fixed #14204 -- Enforced SQLite foreign key constraints.
Thanks Tim Graham for contributing to the patch and
Simon Charette for advice and review.
2017-07-11 09:07:31 -04:00
Josh Schneier fba0eaa5d6 Fixed #28298 -- Prevented a primary key alteration from adding a foreign key constraint if db_constraint=False. 2017-06-22 21:31:56 -04:00
Simon Charette b1cbbe9267 Refs #25530 -- Deleted deferred SQL references on delete operation. 2017-06-21 00:26:30 -04:00
Simon Charette b50815ee41 Refs #25530 -- Renamed deferred SQL references on rename operation. 2017-06-21 00:26:30 -04:00
Simon Charette ea91ad4c13 Refs #25530 -- Changed _create_index_name to take a table as first parameter. 2017-06-20 22:59:22 -04:00
Jon Dufresne 2c69824e5a Refs #23968 -- Removed unnecessary lists, generators, and tuple calls. 2017-06-01 19:08:59 -04:00
Mariusz Felisiak 924a89e135 Fixed #26682 -- Added support for Oracle identity columns.
Thanks Shai Berger and Tim Graham for reviews.
2017-06-01 19:33:48 +02:00