From: Mike Bayer Date: Sun, 14 Mar 2010 01:05:17 +0000 (-0500) Subject: - Fixed bug in 0.6-reworked "many-to-one" optimizations X-Git-Tag: rel_0_6beta2~54^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c03b434104368b1c025f45987d7a3fa8048d5e37;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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) --- 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):