Simon Charette
57307bbc7d
Fixed #35666 -- Documented stacklevel usage and testing, and adjusted test suite accordingly.
...
Over the years we've had multiple instances of hit and misses when
emitting warnings: either setting the wrong stacklevel or not setting
it at all.
This work adds assertions for the existing warnings that were declaring
the correct stacklevel, but were lacking tests for it.
2024-08-28 11:44:05 -03:00
Mark Gensler
228128618b
Fixed #35575 -- Added support for constraint validation on GeneratedFields.
2024-08-12 13:45:57 +02:00
David Sanders
509763c799
Fixed #35638 -- Updated validate_constraints to consider db_default.
2024-08-05 17:33:12 +02:00
Tim Graham
b6ad8b687a
Added missing skips in constraint tests.
2024-07-26 18:59:12 +02:00
Simon Charette
0e49a8c3bd
Refs #34701 -- Moved UniqueConstraint(nulls_distinct) validation tests.
...
The original tests required the creation of a model that is no longer necessary
and were exercising Model.full_clean(validate_constraints) which has nothing
to do with the nulls_distinct feature.
2024-07-17 12:52:17 +02:00
Simon Charette
adc0b6aac3
Fixed #35594 -- Added unique nulls distinct validation for expressions.
...
Thanks Mark Gensler for the report.
2024-07-17 12:52:17 +02:00
Simon Charette
13922580cc
Refs #30581 -- Made unattached UniqueConstraint(fields) validation testable.
...
The logic allowing UniqueConstraint(fields).validate to preserve backward
compatiblity with Model.unique_error_message failed to account for cases where
the constraint might not be attached to a model which is a common pattern
during testing.
This changes allows for arbitrary UniqueConstraint(fields) to be tested in
isolation without requiring actual models backing them up.
Co-authored-by: Mark G <mark.gensler@protonmail.com>
2024-07-17 12:52:17 +02: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
Albert Defler
c991602ce5
Fixed #34060 -- Fixed migrations crash when adding check constraints with JSONField __exact lookup on Oracle.
2024-02-15 13:57:58 +01:00
Mariusz Felisiak
9fd3a0ffc8
Refs #34840 -- Fixed test_validate_nullable_textfield_with_isnull_true() on databases that don's support table check constraints.
...
Thanks Tim Graham for the report.
2023-10-12 20:01:44 +02:00
Mariusz Felisiak
779cd28acb
Fixed #34840 -- Avoided casting string base fields on PostgreSQL.
...
Thanks Alex Vandiver for the report.
Regression in 09ffc5c121
.
2023-09-22 06:01:11 +02:00
Francesco Panico
1506f498fe
Fixed #34743 -- Fixed Meta.constraints validation crash when using pk.
...
Thanks Nwawel A Iroume for the report.
2023-08-11 08:51:29 +02:00
Simon Charette
3434dbd39d
Fixed #34754 -- Fixed JSONField check constraints validation on NULL values.
...
The __isnull lookup of JSONField must special case
Value(None, JSONField()) left-hand-side in order to be coherent with
its convoluted null handling.
Since psycopg>=3 offers no way to pass a NULL::jsonb the issue is
resolved by optimizing IsNull(Value(None), True | False) to
True | False.
Regression in 5c23d9f0c3
.
Thanks Alexandre Collet for the report.
2023-08-04 10:14:03 +02:00
Simon Charette
d7d80040c1
Made UniqueConstraint raise TypeError for type violations.
2023-07-19 21:46:20 +02:00
Simon Charette
595a2abb58
Fixed #34701 -- Added support for NULLS [NOT] DISTINCT on PostgreSQL 15+.
2023-07-19 21:42:27 +02:00
Mariusz Felisiak
2c428b37ae
Refs #34338 -- Fixed isolation of constraints tests.
...
Regression in 5b3d3e400a
.
2023-02-24 09:02:45 +01:00
Xavier Fernandez
5b3d3e400a
Fixed #34338 -- Allowed customizing code of ValidationError in BaseConstraint and subclasses.
2023-02-23 10:58:20 +01:00
Xavier Fernandez
51c9bb7cd1
Refs #33829 -- Added violation_error_message to constraints' __repr__().
2023-02-23 05:35:58 +01:00
Xavier Fernandez
ad18a0102c
Fixed #34355 -- Deprecated passing positional arguments to BaseConstraint.
2023-02-22 09:37:58 +01:00
Mariusz Felisiak
2fd755b361
Fixed #34319 -- Fixed Model.validate_constraints() crash on ValidationError with no code.
...
Thanks Mateusz Kurowski for the report.
Regression in 667105877e
.
2023-02-08 16:38:55 +01:00
Mariusz Felisiak
2b1242abb3
Fixed #34291 -- Fixed Meta.constraints validation crash on UniqueConstraint with ordered expressions.
...
Thanks Dan F for the report.
Bug in 667105877e
.
2023-01-26 09:31:40 +01:00
David Sanders
e14d08cd89
Fixed #33996 -- Fixed CheckConstraint validation on NULL values.
...
Bug in 667105877e
.
Thanks James Beith for the report.
2022-09-13 12:48:31 +02:00
Mariusz Felisiak
63884829ac
Fixed #33902 -- Fixed Meta.constraints validation crash with F() expressions.
...
Thanks Adam Zahradník for the report.
Bug in 667105877e
.
2022-08-09 06:08:48 +02:00
Stéphane "Twidi" Angel
ccbf714ebe
Fixed #33829 -- Made BaseConstraint.deconstruct() and equality handle violation_error_message.
...
Regression in 667105877e
.
2022-07-08 08:17:42 +02:00
Gagaro
667105877e
Fixed #30581 -- Added support for Meta.constraints validation.
...
Thanks Simon Charette, Keryn Knight, and Mariusz Felisiak for reviews.
2022-05-10 11:22:23 +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
django-bot
9c19aff7c7
Refs #33476 -- Reformatted code with Black.
2022-02-07 20:37:05 +01:00
Hannes Ljungberg
3aa545281e
Fixed #30916 -- Added support for functional unique constraints.
...
Thanks Ian Foote and Mariusz Felisiak for reviews.
2021-02-23 20:19:53 +01:00
Hannes Ljungberg
87acbf0631
Fixed #32458 -- Made __repr__() for Index and BaseConstraint subclasses more consistent.
2021-02-19 20:25:11 +01:00
Mariusz Felisiak
f4e93919e4
Fixed #31815 -- Fixed schema value encoding on PostgreSQL.
2020-07-27 06:39:02 +02:00
Hannes Ljungberg
30e3d2d78d
Fixed #31745 -- Added error messages when using UniqueConstraint.include/opclasses with deferrable.
2020-06-29 06:41:23 +02:00
Hannes Ljungberg
7edc6e53a7
Fixed #31702 -- Added support for PostgreSQL opclasses in UniqueConstraint.
2020-06-16 07:19:00 +02:00
Mariusz Felisiak
f83b44075d
Refs #30913 -- Added system checks for covering indexes and unique constraints support.
2020-06-04 12:26:25 +02:00
Hannes Ljungberg
8c7992f658
Fixed #30913 -- Added support for covering indexes on PostgreSQL 11+.
2020-06-04 12:26:22 +02:00
Ian Foote
c226c6cb32
Fixed #20581 -- Added support for deferrable unique constraints.
2020-04-30 10:43:50 +02:00
Mariusz Felisiak
4c9886085b
Refs #31351 -- Made partial constraints tests use required_db_features.
...
This will notably silence the warnings issued when running the test
suite on MySQL and MariaDB.
2020-04-17 07:45:52 +02:00
Simon Charette
e9a0e1d4f6
Fixed #30484 -- Added conditional expressions support to CheckConstraint.
2019-11-21 11:56:35 +01:00
ElizabethU
54ea290e5b
Fixed #30651 -- Made __eq__() methods return NotImplemented for not implemented comparisons.
...
Changed __eq__ to return NotImplemented instead of False if compared to
an object of the same type, as is recommended by the Python data model
reference. Now these models can be compared to ANY (or other objects
with __eq__ overwritten) without returning False automatically.
2019-10-01 17:58:19 +02:00
Simon Charette
8b3e1b6e9e
Refs #11964 -- Made constraint support check respect required_db_features.
...
This will notably silence the warnings issued when running the test
suite on MySQL.
2019-08-12 06:44:37 +02:00
Hasan Ramezani
1fc2c70f76
Fixed #30593 -- Added support for check constraints on MariaDB 10.2+.
2019-07-19 11:05:06 +02:00
can
febe136d4c
Fixed #30397 -- Added app_label/class interpolation for names of indexes and constraints.
2019-07-08 14:57:56 +02:00
Paveł Tyślacki
b69f8eb04c
Fixed #30062 -- Added support for unique conditional constraints.
2019-01-12 09:50:20 -05:00
Paveł Tyślacki
f4c0c0b0aa
Added tests for Check/UniqueConstraint.__eq__().
2019-01-12 09:24:22 -05:00
Paveł Tyślacki
647be06538
Renamed variables after generalization of constraints.
...
Follow up to 8eae094638
.
2019-01-10 18:54:41 -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
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
db13bca60a
Fixed #29641 -- Added support for unique constraints in Meta.constraints.
...
This constraint is similar to Meta.unique_together but also allows
specifying a name.
Co-authored-by: Ian Foote <python@ian.feete.org>
2018-11-13 17:57:27 -05: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
Simon Charette
24dc7d8940
Refs #29641 -- Extracted reusable CheckConstraint logic into a base class.
2018-10-02 13:11:18 -04:00
Simon Charette
9142bebff2
Refs #11964 -- Changed CheckConstraint() signature to use keyword-only arguments.
...
Also renamed the `constraint` argument to `check` to better represent which
part of the constraint the provided `Q` object represents.
2018-10-02 10:53:04 -04:00