]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add compiler support for PostgreSQL "NOT VALID" constraints.
authorGilbert Gilb's <gilbsgilbert@gmail.com>
Sat, 22 Jan 2022 00:45:31 +0000 (01:45 +0100)
committerGilbert Gilb's <gilbsgilbert@gmail.com>
Sun, 23 Jan 2022 17:53:51 +0000 (18:53 +0100)
commit21a1e9e402d8c1b4fd3739dd4c93df3e0b5b4b08
treeac75f49ffe0488e4095f168c358994a77132cc1e
parentd46a4c0326bd2e697794514b920e6727d5153324
Add compiler support for PostgreSQL "NOT VALID" constraints.

PostgreSQL supports declaring CHECK and FOREIGN KEY constraints as "NOT
VALID" which prevents the constraint from being validated on already
inserted rows, but still validates against any newly inserted or updated
rows.

This commit adds compiler support for this dialect option on
`CheckConstraint` and `ForeignKeyConstraint` classes. Although this
option doesn't make much sense on table creation, it doesn't seem to
cause any issue with Postgres and it is a preliminary step to have this
supported in Alembic during `ALTER TABLE`. Note that other constraints
types do not support this option.

See https://www.postgresql.org/docs/current/sql-altertable.html

See also #4825 which added supported for "NOT VALID" constraints
introsecpection.

Fixes: #7600
Signed-off-by: Gilbert Gilb's <gilbsgilbert@gmail.com>
doc/build/changelog/unreleased_14/7601.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/base.py
test/dialect/postgresql/test_compiler.py