]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Open up check for relationships that write to the same column
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Feb 2020 21:51:32 +0000 (16:51 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 27 Feb 2020 20:55:06 +0000 (15:55 -0500)
commite5e5bb640abc5c98b39a6a3a955a20ef1525fc02
treed0e6035f32930018606efe8ca75c1d285bdf834c
parentf78db5e1f68d6b2fb6a7acc04036f682d9a22974
Open up check for relationships that write to the same column

Enhanced logic that tracks if relationships will be conflicting with each
other when they write to the same column to include simple cases of two
relationships that should have a "backref" between them.   This means that
if two relationships are not viewonly, are not linked with back_populates
and are not otherwise in an inheriting sibling/overriding arrangement, and
will populate the same foreign key column, a warning is emitted at mapper
configuration time warning that a conflict may arise.  A new parameter
:paramref:`.relationship.overlaps` is added to suit those very rare cases
where such an overlapping persistence arrangement may be unavoidable.

Fixes: #5171
Change-Id: Ifae5998fc1c7e49ce059aec8a67c80cabee768ad
19 files changed:
doc/build/changelog/unreleased_14/5171.rst [new file with mode: 0644]
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/relationships.py
test/ext/declarative/test_inheritance.py
test/ext/test_associationproxy.py
test/orm/inheritance/test_basic.py
test/orm/inheritance/test_single.py
test/orm/test_cycles.py
test/orm/test_deferred.py
test/orm/test_eager_relations.py
test/orm/test_froms.py
test/orm/test_instrumentation.py
test/orm/test_lazy_relations.py
test/orm/test_options.py
test/orm/test_query.py
test/orm/test_relationships.py
test/orm/test_selectin_relations.py
test/orm/test_subquery_relations.py
test/orm/test_unitofwork.py