]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Support column list for foreign key ON DELETE SET actions on PostgreSQL
authorDenis Laxalde <denis@laxalde.org>
Tue, 11 Mar 2025 19:48:39 +0000 (20:48 +0100)
committerDenis Laxalde <denis@laxalde.org>
Wed, 12 Mar 2025 17:10:11 +0000 (18:10 +0100)
commit7c01d3e3a8d4d25d85779183691130b27ae1eac2
tree1abb0bc0e37fb4cb2919bf90fc896328c7e80ee1
parenteeeff33c6d59e88f055914505dfe552f8ce6df47
Support column list for foreign key ON DELETE SET actions on PostgreSQL

Added support for specifying a list of columns for ON DELETE SET
(NULL|DEFAULT) actions of foreign key definition on PostgreSQL. This is
handled on both compiler and reflection sides.

In order to make it possible to override the logic of
DDLCompiler.define_constraint_cascades() in derived classes, namely
PGDDLCompiler here, we add two methods,
define_constraint_ondelete_cascade() and
define_constraint_onupdate_cascade(), the former being overridden in
PGDDLCompiler.

Test cases (tables definition) are taken from PostgreSQL test suite.

Fixes: #11595
Fixes: #11946
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/sql/compiler.py
test/dialect/postgresql/test_compiler.py
test/dialect/postgresql/test_reflection.py