1
0
mirror of https://github.com/django/django.git synced 2024-12-22 09:05:43 +00:00
Commit Graph

256 Commits

Author SHA1 Message Date
lufafajoshua
27375ad50e Fixed #35969 -- Disallowed specifying a USING clause for altered generated field.
PostgreSQL versions 16.5 and above no longer permit the use
of a USING clause when changing the type of a generated column.
2024-12-17 11:27:25 +01:00
Andrés Reverón Molina
b44efdfe54 Fixed #34856 -- Fixed references to index_together in historical migrations.
While AlterUniqueTogether has been documented to be still allowed in historical
migrations for the foreseeable future it has been crashing since 2abf417c81
was merged because the latter removed support for Meta.index_together which the
migration framework uses to render models to perform schema changes.

CreateModel(options["unique_together"]) was also affected.

Refs #27236.

Co-authored-by: Simon Charette <charette.s@gmail.com>
2024-12-17 09:59:39 +01:00
Bendeguz Csirmaz
978aae4334 Fixed #373 -- Added CompositePrimaryKey.
Thanks Lily Foote and Simon Charette for reviews and mentoring
this Google Summer of Code 2024 project.

Co-authored-by: Simon Charette <charette.s@gmail.com>
Co-authored-by: Lily Foote <code@lilyf.org>
2024-11-29 11:23:04 +01:00
Salvo Polizzi
b82f80906a Fixed #35038 -- Created AlterConstraint operation. 2024-11-28 17:40:52 +01:00
Sarah Boyce
3dac3271d2 Reverted "Fixed #28646 -- Prevented duplicate index when unique is set to True on PostgreSQL."
This reverts commit 9cf9c796be due to a crash on Oracle
as it didn't allow multiple indexes on the same field.
2024-08-01 09:25:33 +02:00
Ben Cail
9cf9c796be Fixed #28646 -- Prevented duplicate index when unique is set to True on PostgreSQL. 2024-07-30 17:27:10 +02:00
Simon Charette
f359990e49 Fixed #35625 -- Fixed a crash when adding a field with db_default and check constraint.
This is the exact same issue as refs #30408 but for creating a model with a
constraint containing % escapes instead of column addition. All of these issues
stem from a lack of SQL and parameters separation from the BaseConstraint DDL
generating methods preventing them from being mixed with other parts of the
schema alteration logic that do make use of parametrization on some backends
(e.g. Postgres, MySQL for DEFAULT).

Prior to the addition of Field.db_default and GeneratedField in 5.0
parametrization of DDL was never exercised on model creation so this is
effectively a bug with db_default as the GeneratedField case was addressed by
refs #35336.

Thanks Julien Chaumont for the report and Mariusz Felisiak for the review.
2024-07-25 07:48:53 +02:00
Mariusz Felisiak
fa78481467 Refs #34881 -- Fixed OperationTests.test_rename_m2m_field_with_2_references() test on Oracle. 2024-06-14 19:52:09 +02:00
Anže Pečar
e99187e5c9 Fixed #34881 -- Fixed a crash when renaming a model with multiple ManyToManyField.through references on SQLite.
Thank you to dennisvang for the report and Jase Hackman for the test.

Co-authored-by: Jase Hackman <jase.hackman@zapier.com>
2024-06-13 17:49:22 +02:00
Tim Graham
bcbc4b9b8a Fixed typo in migrations test name. 2024-05-23 17:19:48 +02:00
Mariusz Felisiak
91a4b9a8ec Fixed #35422 -- Fixed migrations crash when altering GeneratedField referencing rename field.
Thanks Sarah Boyce for the report and Simon Charette for the
implementation idea.
2024-05-03 09:28:24 +02:00
DevilsAutumn
9aeb38c296 Fixed #35359 -- Fixed migration operations ordering when adding fields referenced by GeneratedField.expression.
Thank you to Simon Charette for the review.
2024-05-02 21:43:13 -03:00
Mariusz Felisiak
a2dcc4ecbb
Increased test coverage for django.db.migrations.operations.special. 2024-03-25 08:31:32 +01:00
Ben Cail
593067a8ee Fixed #28541 -- Fixed migrations crash when changing primary key on SQLite. 2024-03-14 20:56:43 +01:00
Simon Charette
daf7d482db Refs #35234 -- Deprecated CheckConstraint.check in favor of .condition.
Once the deprecation period ends CheckConstraint.check() can become the
documented method that performs system checks for BaseConstraint
subclasses.
2024-03-01 07:15:32 +01:00
Simon Charette
e67d7d70fa Fixed #35149 -- Fixed crashes of db_default with unresolvable output field.
Field.db_default accepts either literal Python values or compilables
(as_sql) and wrap the former ones in Value internally.

While 1e38f11 added support for automatic resolving of output fields for
types such as str, int, float, and other unambigous ones it's cannot do
so for all types such as dict or even contrib.postgres and contrib.gis
primitives.

When a literal, non-compilable, value is provided it likely make the
most sense to bind its output field to the field its attached to avoid
forcing the user to provide an explicit `Value(output_field)`.

Thanks David Sanders for the report.
2024-02-04 09:39:41 +01:00
Mariusz Felisiak
305757aec1
Applied Black's 2024 stable style.
https://github.com/psf/black/releases/tag/24.1.0
2024-01-26 12:45:07 +01:00
Amir Karimi
27a3eee721 Fixed #31700 -- Made makemigrations command display meaningful symbols for each operation. 2024-01-17 14:00:02 +01:00
David Wobrock
7045661069 Fixed #35022 -- Fixed RenameIndex() crash on unnamed indexes if exists unique constraint on the same fields. 2023-12-22 12:47:17 +01:00
Sarah Boyce
828082dad9 Fixed #34984 -- Skipped GeneratedFields when remaking tables on SQLite.
Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95.t

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Co-authored-by: David Sanders <shang.xiao.sanders@gmail.com>
2023-11-22 12:29:14 +01:00
Mariusz Felisiak
5875f03ce6 Fixed #34944 -- Made GeneratedField.output_field required.
Regression in f333e3513e.
2023-11-14 20:22:07 +01:00
Simon Charette
8a28e983df
Fixed #34946 -- Preserved db_default on combined default field addition.
Regression in 7414704e88.
2023-11-07 13:32:34 +03:00
David Sanders
1944f490f9 Refs #34936 -- Added test for altering DecimalField with db_default to non-nullable. 2023-11-02 17:57:34 +01:00
Mariusz Felisiak
2abf417c81 Refs #27236 -- Removed Meta.index_together per deprecation timeline. 2023-09-18 22:12:40 +02:00
donghao
71820c9f91 Fixed #34820 -- Fixed migrations crash when changing a ForeignObject field. 2023-09-09 22:15:14 +02:00
Jeremy Nauta
f333e3513e Fixed #31300 -- Added GeneratedField model field.
Thanks Adam Johnson and Paolo Melchiorre for reviews.

Co-Authored-By: Lily Foote <code@lilyf.org>
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2023-09-07 06:19:08 +02:00
Mariusz Felisiak
2b582387d5
Fixed #34760 -- Dropped support for SQLite < 3.27. 2023-08-04 06:35:13 +02:00
devilsautumn
f05cc5e3d2 Refs #24686 -- Made AlterField operation a noop when renaming related model with db_table. 2023-07-22 20:13:42 +02:00
Mariusz Felisiak
3109038992
Refs #33201 -- Avoided unnecessary queries when renaming models with db_table on SpatiaLite. 2023-07-18 14:08:47 +02:00
Ian Foote
7414704e88 Fixed #470 -- Added support for database defaults on fields.
Special thanks to Hannes Ljungberg for finding multiple implementation
gaps.

Thanks also to Simon Charette, Adam Johnson, and Mariusz Felisiak for
reviews.
2023-05-12 19:11:40 +02:00
Simon Charette
ffff17d4b0 Fixed #34553 -- Fixed improper % escaping of literal in constraints.
Proper escaping of % in string literals used when defining constaints
was attempted (a8b3f96f6) by overriding quote_value of Postgres and
Oracle schema editor. The same approach was used when adding support for
constraints to the MySQL/MariaDB backend (1fc2c70).

Later on it was discovered that this approach was not appropriate and
that a preferable one was to pass params=None when executing the
constraint creation DDL to avoid any form of interpolation in the first
place (42e8cf47).

When the second patch was applied the corrective of the first were not
removed which caused % literals to be unnecessary doubled. This flew
under the radar because the existings test were crafted in a way that
consecutive %% didn't catch regressions.

This commit introduces an extra test for __exact lookups which
highlights more adequately % doubling problems but also adjust a
previous __endswith test to cover % doubling problems (%\% -> %%\%%).

Thanks Thomas Kolar for the report.

Refs #32369, #30408, #30593.
2023-05-10 17:25:57 +02:00
Simon Charette
e0f8104a96 Refs #34553 -- Split constraint escaping test in subtests.
This ensures that constraint violations are tested in isolation from
each other as an IntegrityError only ensures a least one constraint is
violated.

For example, the assertion added in 42e8cf4 break both the
name_constraint_rhs and the rebate_constraint constraints and thus
doesn't constitute a proper regression test. Refs #32369.
2023-05-10 17:25:57 +02:00
Mariusz Felisiak
16c966ff7f
Refs #30060, Refs #34217 -- Made SchemaEditor not generate SQL for CheckConstraint if not supported.
The new logic mirrors the logic in SchemaEditor._delete_check_sql()
added in 68ef274bc5.

Thanks Tim Graham for the report.
2023-02-23 21:12:17 +01:00
DevilsAutumn
ff3a283422 Fixed #34250 -- Fixed renaming model with m2m relation to a model with the same name. 2023-02-14 14:08:06 +01:00
kimsoungryoul
78f163a4fb Fixed #18468 -- Added support for comments on columns and tables.
Thanks Jared Chung, Tom Carrick, David Smith, Nick Pope, and Mariusz
Felisiak for reviews.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-12-28 06:28:07 +01:00
DevilsAutumn
68ef274bc5 Fixed #34217 -- Fixed migration crash when removing check constraints on MySQL < 8.0.16. 2022-12-27 07:11:13 +01:00
DevilsAutumn
81b1c167bf Fixed #28987 -- Fixed altering ManyToManyField when changing to self-referential. 2022-11-17 12:36:52 +01:00
David Sanders
9f8c994851 Fixed #34027 -- Fixed migrations crash when altering type of char/text fields referenced by foreign key on PostgreSQL. 2022-09-25 20:23:01 +02:00
Mariusz Felisiak
a9e7beb959
Refs #33953 -- Fixed test_rename_model_with_db_table_rename_m2m() crash on SQLite < 3.20. 2022-08-29 10:07:53 +02:00
Iuri de Silvio
166a3b3263 Fixed #33953 -- Reverted "Fixed #33201 -- Made RenameModel operation a noop for models with db_table."
Regression in afeafd6036.
This reverts afeafd6036.

Thanks Timothy Thomas for the report.
2022-08-26 06:14:44 +02:00
Mariusz Felisiak
c773d5794e Refs #27236 -- Reverted AlterIndexTogether deprecation.
This partly reverts a6385b382e.
2022-07-26 11:41:19 +02:00
Mariusz Felisiak
f810325721
Refs #27236 -- Made cosmetic edits to Meta.index_together deprecation.
This should make it more straightforward to move forward when
deprecation ends.
2022-07-21 07:05:50 +02:00
David Wobrock
a6385b382e
Fixed #27236 -- Deprecated Meta.index_together in favor of Meta.indexes.
This also deprecates AlterIndexTogether migration operation.
2022-07-12 09:04:31 +02:00
David Wobrock
4f284115a9 Refs #27236 -- Split RenameField() tests with unique/index_together. 2022-07-12 06:38:03 +02:00
David Wobrock
b949e40e8c Fixed #23740 -- Fixed removing unique_together constraint if exists primary key/unique constraint on the same field. 2022-05-26 08:33:07 +02:00
David Wobrock
11310e9abb Fixed #33710 -- Made RenameIndex operation a noop when the old and new name match. 2022-05-16 10:36:56 +02:00
David Wobrock
eacd4977f6 Refs #27064 -- Added RenameIndex migration operation. 2022-05-12 20:44:03 +02:00
Mariusz Felisiak
27b07a3246
Refs #30581 -- Moved CheckConstraint tests for conditional expressions to migrations.test_operations.
This allows avoiding warning in tests about using RawSQL in
CheckConstraints.
2022-05-05 06:44:34 +02:00
David Wobrock
aca9bb2a12 Fixed #33413 -- Made migrations propage collations to related fields. 2022-05-02 08:13:38 +02:00
Mariusz Felisiak
7119f40c98 Refs #33476 -- Refactored code to strictly match 88 characters line length. 2022-02-07 20:37:05 +01:00