]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
add new pattern for single inh column override
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 17 Nov 2022 17:03:46 +0000 (12:03 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 30 Nov 2022 23:04:08 +0000 (18:04 -0500)
commitde68627dd1ba9c2dd44bb3d11be1a3945b285205
tree0f80ae8fb55c5363fafd4fef48a728165b3e746e
parent1057b47bca2522e45d9621a709d033aa4fb88888
add new pattern for single inh column override

Added a new parameter :paramref:`_orm.mapped_column.use_existing_column` to
accommodate the use case of a single-table inheritance mapping that uses
the pattern of more than one subclass indicating the same column to take
place on the superclass. This pattern was previously possible by using
:func:`_orm.declared_attr` in conjunction with locating the existing column
in the ``.__table__`` of the superclass, however is now updated to work
with :func:`_orm.mapped_column` as well as with pep-484 typing, in a
simple and succinct way.

Fixes: #8822
Change-Id: I2296a4a775da976c642c86567852cdc792610eaf
doc/build/changelog/unreleased_20/8822.rst [new file with mode: 0644]
doc/build/orm/inheritance.rst
lib/sqlalchemy/orm/_orm_constructors.py
lib/sqlalchemy/orm/decl_base.py
lib/sqlalchemy/orm/descriptor_props.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/orm/relationships.py
test/ext/declarative/test_reflection.py
test/orm/declarative/test_inheritance.py