From c03b434104368b1c025f45987d7a3fa8048d5e37 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 13 Mar 2010 20:05:17 -0500 Subject: [PATCH] - Fixed bug in 0.6-reworked "many-to-one" optimizations such that a many-to-one that is against a non-primary key column on the remote table (i.e. foreign key against a UNIQUE column) will pull the "old" value in from the database during a change, since if it's in the session we will need it for proper history/backref accounting, and we can't pull from the local identity map on a non-primary key column. [ticket:1737] (test is pending) --- CHANGES | 11 ++++++++++- lib/sqlalchemy/orm/strategies.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index dfaf4846f6..b33bf4b262 100644 --- a/CHANGES +++ b/CHANGES @@ -30,7 +30,16 @@ CHANGES on existing items. Will still mark the attr as expired if the destination doesn't have the attr, though, which fulfills some contracts of deferred cols. [ticket:1681] - + + - Fixed bug in 0.6-reworked "many-to-one" optimizations + such that a many-to-one that is against a non-primary key + column on the remote table (i.e. foreign key against a + UNIQUE column) will pull the "old" value in from the + database during a change, since if it's in the session + we will need it for proper history/backref accounting, + and we can't pull from the local identity map on a + non-primary key column. [ticket:1737] + - session.merge() works with relations that specifically don't include "merge" in their cascade options - the target is ignored completely. diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index eea7a8b124..bd96dd5b78 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -377,7 +377,7 @@ class LazyLoader(AbstractRelationLoader): callable_=self._class_level_loader, uselist = self.parent_property.uselist, typecallable = self.parent_property.collection_class, - active_history = self.parent_property.direction is not interfaces.MANYTOONE, + active_history = not self.use_get, ) def lazy_clause(self, state, reverse_direction=False, alias_secondary=False, adapt_source=None): -- 2.47.3