diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-01-10 13:16:43 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-01-11 21:58:12 -0500 |
| commit | 615ec3e640373bcb10311ba1d5cfc72e570b6534 (patch) | |
| tree | 81c038b1c6f379f961b1fead75cf4956dd69dba0 /lib | |
| parent | 48b37a062a26a41bd5c9243d2365a6c06a77a347 (diff) | |
| download | sqlalchemy-615ec3e640373bcb10311ba1d5cfc72e570b6534.tar.gz | |
Fixes for table-bound version_id_col against mapped selectable
Fixed bug where a versioning column specified on a mapper against a
:func:`.select` construct where the version_id_col itself were against the
underlying table would incur additional loads when accessed, even if the
value were locally persisted by the flush. The actual fix is a result of
the changes in :ticket:`4617`, by fact that a :func:`.select` object no
longer has a ``.c`` attribute and therefore does not confuse the mapper
into thinking there's an unknown column value present.
Fixed bug in ORM versioning feature where assignment of an explicit
version_id for a counter configured against a mapped selectable where
version_id_col is against the underlying table would fail if the previous
value were expired; this was due to the fact that the mapped attribute
would not be configured with active_history=True.
Fixes: #4194
Fixes: #4195
Change-Id: I214879f441f905bdd85a7411f90352af7399051d
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 79e36026c..9abb5be40 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -198,7 +198,11 @@ class ColumnLoader(LoaderStrategy): active_history = ( self.parent_property.active_history or self.columns[0].primary_key - or mapper.version_id_col in set(self.columns) + or ( + mapper.version_id_col is not None + and mapper._columntoproperty.get(mapper.version_id_col, None) + is self.parent_property + ) ) _register_attribute( |
