[Django] #30593: Add support for check constraints on MariaDB 10.2+.

12 views
Skip to first unread message

Django

unread,
Jun 25, 2019, 1:37:04 PM6/25/19
to django-...@googlegroups.com
#30593: Add support for check constraints on MariaDB 10.2+.
-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: nobody
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) | Keywords: MariaDB,
Severity: Normal | constraint, check
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
MariaDB 10.2+ support check constraints (see
[https://mariadb.com/kb/en/library/constraint/#check-constraints check-
constraints]), we should support them because we officially support this
database. I created [https://github.com/django/django/pull/11513 PR] to
fix feature flags but it requires more work e.g. with introspection.

10 tests fail at 698df6a009cb1c4dbd55905264f24f6edf41066e:
- `constraints.tests.CheckConstraintTests.test_name`
- `constraints.tests.CheckConstraintTests.test_database_constraint`
- `introspection.tests.IntrospectionTests.test_get_constraints`
- `migrations.test_operations.OperationTests.test_add_constraint`
-
`migrations.test_operations.OperationTests.test_add_constraint_percent_escaping`
- `migrations.test_operations.OperationTests.test_add_or_constraint`
-
`migrations.test_operations.OperationTests.test_create_model_with_constraint`
- `migrations.test_operations.OperationTests.test_remove_constraint`
- `schema.tests.SchemaTests.test_check_constraints`
-
`schema.tests.SchemaTests.test_remove_field_check_does_not_remove_meta_constraints`

[1] https://mariadb.com/kb/en/library/information-schema-
check_constraints-table/

--
Ticket URL: <https://code.djangoproject.com/ticket/30593>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 13, 2019, 7:55:10 PM7/13/19
to django-...@googlegroups.com
#30593: Add support for check constraints on MariaDB 10.2+.
-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: MariaDB, | Triage Stage: Accepted
constraint, check |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


Comment:

3 tests fail:
* `introspection.tests.IntrospectionTests.test_get_constraints`
* `schema.tests.SchemaTests.test_check_constraints`
*
`schema.tests.SchemaTests.test_remove_field_check_does_not_remove_meta_constraints`

The `information_schema.key_column_usage` table, does not contain `CHECK`
constraints records. we can find them in
`information_schema.table_constraints` table.
The problem is that records in `information_schema.table_constraints` do
not have `column_name` and we have to add them to constraints with an
empty list of columns [https://github.com/django/django/pull/11566/files
#diff-ed5c74bb534df74e38bc62e79c84fa12R194].

Those 3 tests fail because of the above-mentioned problem.
Any idea?

--
Ticket URL: <https://code.djangoproject.com/ticket/30593#comment:1>

Django

unread,
Jul 19, 2019, 10:01:42 AM7/19/19
to django-...@googlegroups.com
#30593: Add support for check constraints on MariaDB 10.2+.
-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: MariaDB, | Triage Stage: Accepted
constraint, check |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"1fc2c70f7613e014a31771afa537439b28dd35fb" 1fc2c70f]:
{{{
#!CommitTicketReference repository=""
revision="1fc2c70f7613e014a31771afa537439b28dd35fb"
Fixed #30593 -- Added support for check constraints on MariaDB 10.2+.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30593#comment:2>

Django

unread,
Jul 30, 2019, 10:50:47 AM7/30/19
to django-...@googlegroups.com
#30593: Add support for check constraints on MariaDB 10.2+.
-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: MariaDB, | Triage Stage: Accepted
constraint, check |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"b2aad9ad4d35ee3bb448ba698b8c56bb972bdd8a" b2aad9ad]:
{{{
#!CommitTicketReference repository=""
revision="b2aad9ad4d35ee3bb448ba698b8c56bb972bdd8a"
Refs #30593 -- Added _parse_constraint_columns() hook to introspection on
MariaDB.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30593#comment:3>

Django

unread,
Jul 30, 2019, 10:50:48 AM7/30/19
to django-...@googlegroups.com
#30593: Add support for check constraints on MariaDB 10.2+.
-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: MariaDB, | Triage Stage: Accepted
constraint, check |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"e3fc9af4abd65262f2d3bdced96b687b65be618a" e3fc9af]:
{{{
#!CommitTicketReference repository=""
revision="e3fc9af4abd65262f2d3bdced96b687b65be618a"
Refs #30593 -- Fixed introspection of check constraints columns on
MariaDB.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30593#comment:4>

Django

unread,
May 10, 2023, 1:21:12 PM5/10/23
to django-...@googlegroups.com
#30593: Add support for check constraints on MariaDB 10.2+.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody

Type: New feature | Status: closed
Component: Database layer | Version: dev

(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: MariaDB, | Triage Stage: Accepted
constraint, check |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"ffff17d4b0117cce59f65c9f56fa164694eafd23" ffff17d4]:
{{{
#!CommitTicketReference repository=""
revision="ffff17d4b0117cce59f65c9f56fa164694eafd23"
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.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30593#comment:5>

Reply all
Reply to author
Forward
0 new messages