]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
detect map_imperatively() called twice
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 18 Jan 2022 16:02:57 +0000 (11:02 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 18 Jan 2022 16:15:35 +0000 (11:15 -0500)
commite542448ac9a9cb315a010a8973e58ee1157b91ef
tree397e69369ecc2e57081129e6fe836733ddcb1d3d
parent2bd622d27b44893a0dca5138e4acbff213771ddb
detect map_imperatively() called twice

Fixed issue where calling upon :meth:`_orm.regsitry.map_imperatively` more
than once for the same class would produce an unexpected error, rather than
an informative error that the target class is already mapped. This behavior
differed from that of the :func:`_orm.mapper` function which does report an
informative message already.

For 2.0, this change also cleans up the logic that detects against
`Mapper()` or `_mapper()` being invoked directly.  1.4's backport will
take on a different format as `mapper()` is still public API in that
release.

Fixes: #7579
Change-Id: Ie74a1a2e97f8b6a81ac1942040edd8cae82f4bd8
(cherry picked from commit e6ded82eef63235d7cbfe3ab3382a48f32913640)
doc/build/changelog/unreleased_14/7579.rst [new file with mode: 0644]
lib/sqlalchemy/orm/decl_api.py
lib/sqlalchemy/orm/mapper.py
test/orm/test_mapper.py