- fix bug due to regression from #2793, make sure we only go to load

scalar attributes here and not relationships, else we get an error if there's no
actual scalars to load
This commit is contained in:
Mike Bayer
2013-10-11 16:41:52 -04:00
parent 1f1ad557af
commit 75be18004f
3 changed files with 24 additions and 3 deletions
+2 -2
View File
@@ -728,8 +728,8 @@ def _finalize_insert_update_commands(base_mapper, uowtransaction,
# it isn't expired.
toload_now = []
if base_mapper.eager_defaults and state.unloaded:
toload_now.extend(state.unloaded)
if base_mapper.eager_defaults:
toload_now.extend(state._unloaded_non_object)
elif mapper.version_id_col is not None and \
mapper.version_id_generator is False:
prop = mapper._columntoproperty[mapper.version_id_col]
+9
View File
@@ -392,6 +392,15 @@ class InstanceState(interfaces._InspectionAttr):
difference(self.committed_state).\
difference(self.dict)
@property
def _unloaded_non_object(self):
return self.unloaded.difference(self._uses_objects)
@property
def _uses_objects(self):
return (attr for attr in self.manager
if self.manager[attr].impl.uses_objects)
@property
def expired_attributes(self):
"""Return the set of keys which are 'expired' to be loaded by
+13 -1
View File
@@ -854,9 +854,13 @@ class DefaultTest(fixtures.MappedTest):
hohoval, default_t, Hoho = (self.other.hohoval,
self.tables.default_t,
self.classes.Hoho)
Secondary = self.classes.Secondary
mapper(Hoho, default_t, eager_defaults=True)
mapper(Hoho, default_t, eager_defaults=True, properties={
"sec": relationship(Secondary)
})
mapper(Secondary, self.tables.secondary_table)
h1 = Hoho()
session = create_session()
@@ -869,6 +873,14 @@ class DefaultTest(fixtures.MappedTest):
self.sql_count_(0, lambda: eq_(h1.hoho, hohoval))
# no actual eager defaults, make sure error isn't raised
h2 = Hoho(hoho='fas', counter=5)
session.add(h2)
session.flush()
eq_(h2.hoho, 'fas')
eq_(h2.counter, 5)
def test_insert_nopostfetch(self):
default_t, Hoho = self.tables.default_t, self.classes.Hoho