]> 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:02:57 +0000 (11:02 -0500)
commite6ded82eef63235d7cbfe3ab3382a48f32913640
treeff255d62611b9f8af600d2d67033a2b374343b53
parenteb716884a4abcabae84a6aaba105568e925b7d27
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
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