From: Mike Bayer Date: Fri, 11 Feb 2011 20:37:44 +0000 (-0500) Subject: - replace all usage of True and False for passive with PASSIVE_NO_INITIALIZE, X-Git-Tag: rel_0_7b1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad9b85fa8e751f5bfc8c27705e86898131dbc62e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - replace all usage of True and False for passive with PASSIVE_NO_INITIALIZE, PASSIVE_OFF, now expresed as non-boolean symbols - make "passive" available positionally on all get_history() methods, call it like that --- diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index c0ec474cb5..6ee5cbffeb 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -28,14 +28,11 @@ ATTR_EMPTY = util.symbol('ATTR_EMPTY') NO_VALUE = util.symbol('NO_VALUE') NEVER_SET = util.symbol('NEVER_SET') -# "passive" get settings -# TODO: the True/False values need to be factored out -PASSIVE_NO_INITIALIZE = True #util.symbol('PASSIVE_NO_INITIALIZE') +PASSIVE_NO_INITIALIZE = util.symbol('PASSIVE_NO_INITIALIZE') """Symbol indicating that loader callables should not be fired off, and a non-initialized attribute should remain that way.""" -# this is used by backrefs. PASSIVE_NO_FETCH = util.symbol('PASSIVE_NO_FETCH') """Symbol indicating that loader callables should not emit SQL. Non-initialized attributes should be initialized to an empty value.""" @@ -57,7 +54,7 @@ persistent objects. Loads of "previous" values during change events use this flag. """ -PASSIVE_OFF = False #util.symbol('PASSIVE_OFF') +PASSIVE_OFF = util.symbol('PASSIVE_OFF') """Symbol indicating that loader callables should be executed.""" @@ -88,9 +85,9 @@ class QueryableAttribute(interfaces.PropComparator): def _supports_population(self): return self.impl.supports_population - def get_history(self, instance, **kwargs): + def get_history(self, instance, passive=PASSIVE_OFF): return self.impl.get_history(instance_state(instance), - instance_dict(instance), **kwargs) + instance_dict(instance), passive) def __selectable__(self): # TODO: conditionally attach this method based on clause_element ? @@ -386,7 +383,6 @@ class AttributeImpl(object): passive is False, the callable will be executed and the resulting value will be set as the new value for this attribute. """ - if self.key in dict_: return dict_[self.key] else: @@ -1101,7 +1097,7 @@ class History(tuple): HISTORY_BLANK = History(None, None, None) -def get_history(obj, key, **kwargs): +def get_history(obj, key, passive=PASSIVE_OFF): """Return a :class:`.History` record for the given object and attribute key. @@ -1110,17 +1106,16 @@ def get_history(obj, key, **kwargs): :param key: string attribute name. - :param kwargs: Optional keyword arguments currently - include the ``passive`` flag, which indicates if the attribute should be + :param passive: indicates if the attribute should be loaded from the database if not already present (:attr:`PASSIVE_NO_FETCH`), and if the attribute should be not initialized to a blank value otherwise (:attr:`PASSIVE_NO_INITIALIZE`). Default is :attr:`PASSIVE_OFF`. """ - return get_state_history(instance_state(obj), key, **kwargs) + return get_state_history(instance_state(obj), key, passive) -def get_state_history(state, key, **kwargs): - return state.get_history(key, **kwargs) +def get_state_history(state, key, passive=PASSIVE_OFF): + return state.get_history(key, passive) def has_parent(cls, obj, key, optimistic=False): diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index dde0d94c8a..5b513c9c85 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -26,9 +26,15 @@ class DependencyProcessor(object): self.passive_deletes = prop.passive_deletes self.passive_updates = prop.passive_updates self.enable_typechecks = prop.enable_typechecks - self._passive_delete_flag = self.passive_deletes and \ - attributes.PASSIVE_NO_INITIALIZE or \ - attributes.PASSIVE_OFF + if self.passive_deletes: + self._passive_delete_flag = attributes.PASSIVE_NO_INITIALIZE + else: + self._passive_delete_flag = attributes.PASSIVE_OFF + if self.passive_updates: + self._passive_update_flag = attributes.PASSIVE_NO_INITIALIZE + else: + self._passive_update_flag= attributes.PASSIVE_OFF + self.key = prop.key if not self.prop.synchronize_pairs: raise sa_exc.ArgumentError( @@ -233,7 +239,7 @@ class DependencyProcessor(object): history = uowcommit.get_attribute_history( s, self.key, - passive=passive) + passive) if history and not history.empty(): return True else: @@ -398,7 +404,7 @@ class OneToManyDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - passive=self._passive_delete_flag) + self._passive_delete_flag) if history: for child in history.deleted: if child is not None and self.hasparent(child) is False: @@ -421,11 +427,15 @@ class OneToManyDP(DependencyProcessor): for state in states: pks_changed = self._pks_changed(uowcommit, state) + if not pks_changed or self.passive_updates: + passive = attributes.PASSIVE_NO_INITIALIZE + else: + passive = attributes.PASSIVE_OFF + history = uowcommit.get_attribute_history( state, self.key, - passive=not pks_changed - or self.passive_updates) + passive) if history: for child in history.added: if child is not None: @@ -474,7 +484,7 @@ class OneToManyDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - passive=self._passive_delete_flag) + self._passive_delete_flag) if history: for child in history.deleted: if child is not None and \ @@ -508,9 +518,10 @@ class OneToManyDP(DependencyProcessor): def process_saves(self, uowcommit, states): for state in states: - history = uowcommit.get_attribute_history(state, - self.key, - passive=True) + history = uowcommit.get_attribute_history( + state, + self.key, + attributes.PASSIVE_NO_INITIALIZE) if history: for child in history.added: self._synchronize(state, child, None, @@ -654,7 +665,7 @@ class ManyToOneDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - passive=self._passive_delete_flag) + self._passive_delete_flag) if history: if self.cascade.delete_orphan: todelete = history.sum() @@ -677,7 +688,7 @@ class ManyToOneDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - passive=self._passive_delete_flag) + self._passive_delete_flag) if history: ret = True for child in history.deleted: @@ -705,15 +716,16 @@ class ManyToOneDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - passive=self._passive_delete_flag) + self._passive_delete_flag) if history: self._post_update(state, uowcommit, history.sum()) def process_saves(self, uowcommit, states): for state in states: - history = uowcommit.get_attribute_history(state, - self.key, - passive=True) + history = uowcommit.get_attribute_history( + state, + self.key, + attributes.PASSIVE_NO_INITIALIZE) if history: for child in history.added: self._synchronize(state, child, None, False, @@ -834,7 +846,7 @@ class DetectKeySwitch(DependencyProcessor): continue dict_ = state.dict related = state.get_impl(self.key).get(state, dict_, - passive=self.passive_updates) + passive=self._passive_update_flag) if related is not attributes.PASSIVE_NO_RESULT and \ related is not None: related_state = attributes.instance_state(dict_[self.key]) @@ -914,7 +926,7 @@ class ManyToManyDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - passive=self._passive_delete_flag) + self._passive_delete_flag) def presort_saves(self, uowcommit, states): if not self.passive_updates: @@ -926,7 +938,7 @@ class ManyToManyDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - False) + attributes.PASSIVE_OFF) if not self.cascade.delete_orphan: return @@ -937,7 +949,7 @@ class ManyToManyDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - passive=True) + attributes.PASSIVE_NO_INITIALIZE) if history: for child in history.deleted: if self.hasparent(child) is False: @@ -962,7 +974,7 @@ class ManyToManyDP(DependencyProcessor): history = uowcommit.get_attribute_history( state, self.key, - passive=self._passive_delete_flag) + self._passive_delete_flag) if history: for child in history.non_added(): if child is None or \ @@ -997,8 +1009,12 @@ class ManyToManyDP(DependencyProcessor): for state in states: need_cascade_pks = not self.passive_updates and \ self._pks_changed(uowcommit, state) + if need_cascade_pks: + passive = attributes.PASSIVE_OFF + else: + passive = attributes.PASSIVE_NO_INITIALIZE history = uowcommit.get_attribute_history(state, self.key, - passive=not need_cascade_pks) + passive) if history: for child in history.added: if child is None or \ diff --git a/lib/sqlalchemy/orm/descriptor_props.py b/lib/sqlalchemy/orm/descriptor_props.py index 79c57ac0e4..49f310787d 100644 --- a/lib/sqlalchemy/orm/descriptor_props.py +++ b/lib/sqlalchemy/orm/descriptor_props.py @@ -35,8 +35,9 @@ class DescriptorProperty(MapperProperty): self.key = key if hasattr(prop, 'get_history'): - def get_history(self, state, dict_, **kw): - return prop.get_history(state, dict_, **kw) + def get_history(self, state, dict_, + passive=attributes.PASSIVE_OFF): + return prop.get_history(state, dict_, passive) if self.descriptor is None: desc = getattr(mapper.class_, self.key, None) @@ -222,7 +223,7 @@ class CompositeProperty(DescriptorProperty): prop.key for prop in self.props ] - def get_history(self, state, dict_, **kw): + def get_history(self, state, dict_, passive=attributes.PASSIVE_OFF): """Provided for userland code that uses attributes.get_history().""" added = [] diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py index 8dbdd8ffe4..bdcb7b6b26 100644 --- a/lib/sqlalchemy/orm/dynamic.py +++ b/lib/sqlalchemy/orm/dynamic.py @@ -56,20 +56,20 @@ class DynamicAttributeImpl(attributes.AttributeImpl): else: self.query_class = mixin_user_query(query_class) - def get(self, state, dict_, passive=False): - if passive: + def get(self, state, dict_, passive=attributes.PASSIVE_OFF): + if passive is not attributes.PASSIVE_OFF: return self._get_collection_history(state, - passive=True).added_items + attributes.PASSIVE_NO_INITIALIZE).added_items else: return self.query_class(self, state) - def get_collection(self, state, dict_, user_data=None, passive=True): - if passive: + def get_collection(self, state, dict_, user_data=None, + passive=attributes.PASSIVE_NO_INITIALIZE): + if passive is not attributes.PASSIVE_OFF: return self._get_collection_history(state, - passive=passive).added_items + passive).added_items else: - history = self._get_collection_history(state, - passive=passive) + history = self._get_collection_history(state, passive) return history.added_items + history.unchanged_items def fire_append_event(self, state, dict_, value, initiator): @@ -132,7 +132,7 @@ class DynamicAttributeImpl(attributes.AttributeImpl): raise NotImplementedError("Dynamic attributes don't support " "collection population.") - def get_history(self, state, dict_, passive=False): + def get_history(self, state, dict_, passive=attributes.PASSIVE_OFF): c = self._get_collection_history(state, passive) return attributes.History(c.added_items, c.unchanged_items, c.deleted_items) @@ -145,22 +145,24 @@ class DynamicAttributeImpl(attributes.AttributeImpl): c.added_items + c.unchanged_items + c.deleted_items ] - def _get_collection_history(self, state, passive=False): + def _get_collection_history(self, state, passive=attributes.PASSIVE_OFF): if self.key in state.committed_state: c = state.committed_state[self.key] else: c = CollectionHistory(self, state) - if not passive: + if passive is attributes.PASSIVE_OFF: return CollectionHistory(self, state, apply_to=c) else: return c - def append(self, state, dict_, value, initiator, passive=False): + def append(self, state, dict_, value, initiator, + passive=attributes.PASSIVE_OFF): if initiator is not self: self.fire_append_event(state, dict_, value, initiator) - def remove(self, state, dict_, value, initiator, passive=False): + def remove(self, state, dict_, value, initiator, + passive=attributes.PASSIVE_OFF): if initiator is not self: self.fire_remove_event(state, dict_, value, initiator) @@ -225,7 +227,7 @@ class AppenderMixin(object): if sess is None: return iter(self.attr._get_collection_history( attributes.instance_state(self.instance), - passive=True).added_items) + attributes.PASSIVE_NO_INITIALIZE).added_items) else: return iter(self._clone(sess)) @@ -234,7 +236,8 @@ class AppenderMixin(object): if sess is None: return self.attr._get_collection_history( attributes.instance_state(self.instance), - passive=True).added_items.__getitem__(index) + attributes.PASSIVE_NO_INITIALIZE).added_items.\ + __getitem__(index) else: return self._clone(sess).__getitem__(index) @@ -243,7 +246,7 @@ class AppenderMixin(object): if sess is None: return len(self.attr._get_collection_history( attributes.instance_state(self.instance), - passive=True).added_items) + attributes.PASSIVE_NO_INITIALIZE).added_items) else: return self._clone(sess).count() diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index a6d2c95f51..fae47ac058 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1264,7 +1264,7 @@ class Mapper(object): manager = state.manager return self._identity_class, tuple([ manager[self._columntoproperty[col].key].\ - impl.get(state, dict_, False) + impl.get(state, dict_, attributes.PASSIVE_OFF) for col in self.primary_key ]) @@ -1281,11 +1281,12 @@ class Mapper(object): manager = state.manager return [ manager[self._columntoproperty[col].key].\ - impl.get(state, dict_, False) + impl.get(state, dict_, attributes.PASSIVE_OFF) for col in self.primary_key ] - def _get_state_attr_by_column(self, state, dict_, column, passive=False): + def _get_state_attr_by_column(self, state, dict_, column, + passive=attributes.PASSIVE_OFF): prop = self._columntoproperty[column] return state.manager[prop.key].impl.get(state, dict_, passive=passive) @@ -1298,8 +1299,8 @@ class Mapper(object): dict_ = attributes.instance_dict(obj) return self._get_committed_state_attr_by_column(state, dict_, column) - def _get_committed_state_attr_by_column(self, state, dict_, column, - passive=False): + def _get_committed_state_attr_by_column(self, state, dict_, + column, passive=attributes.PASSIVE_OFF): prop = self._columntoproperty[column] return state.manager[prop.key].impl.\ @@ -1337,16 +1338,18 @@ class Mapper(object): if leftcol.table not in tables: leftval = self._get_committed_state_attr_by_column( - state, state.dict, - leftcol, passive=True) + state, state.dict, + leftcol, + passive=attributes.PASSIVE_NO_INITIALIZE) if leftval is attributes.PASSIVE_NO_RESULT or leftval is None: raise ColumnsNotAvailable() binary.left = sql.bindparam(None, leftval, type_=binary.right.type) elif rightcol.table not in tables: rightval = self._get_committed_state_attr_by_column( - state, state.dict, - rightcol, passive=True) + state, state.dict, + rightcol, + passive=attributes.PASSIVE_NO_INITIALIZE) if rightval is attributes.PASSIVE_NO_RESULT or rightval is None: raise ColumnsNotAvailable() binary.right = sql.bindparam(None, rightval, @@ -1395,7 +1398,8 @@ class Mapper(object): visited_states = set() prp, mpp = object(), object() - visitables = deque([(deque(self._props.values()), prp, state, state.dict)]) + visitables = deque([(deque(self._props.values()), prp, + state, state.dict)]) while visitables: iterator, item_type, parent_state, parent_dict = visitables[-1] @@ -1414,9 +1418,11 @@ class Mapper(object): elif item_type is mpp: instance, instance_mapper, corresponding_state, \ corresponding_dict = iterator.popleft() - yield instance, instance_mapper, corresponding_state, corresponding_dict + yield instance, instance_mapper, \ + corresponding_state, corresponding_dict visitables.append((deque(instance_mapper._props.values()), - prp, corresponding_state, corresponding_dict)) + prp, corresponding_state, + corresponding_dict)) @_memoized_configured_property def _compiled_cache(self): @@ -1523,7 +1529,8 @@ class Mapper(object): elif col in post_update_cols: prop = mapper._columntoproperty[col] history = attributes.get_state_history( - state, prop.key, passive=True) + state, prop.key, + attributes.PASSIVE_NO_INITIALIZE) if history.added: value = history.added[0] params[col.key] = value @@ -1701,7 +1708,8 @@ class Mapper(object): prop = mapper._columntoproperty[col] history = attributes.get_state_history( - state, prop.key, passive=True + state, prop.key, + attributes.PASSIVE_NO_INITIALIZE ) if history.added: params[col.key] = history.added[0] @@ -1718,14 +1726,15 @@ class Mapper(object): for prop in mapper._columntoproperty.\ itervalues(): history = attributes.get_state_history( - state, prop.key, - passive=True) + state, prop.key, + attributes.PASSIVE_NO_INITIALIZE) if history.added: hasdata = True else: prop = mapper._columntoproperty[col] history = attributes.get_state_history( - state, prop.key, passive=True) + state, prop.key, + attributes.PASSIVE_NO_INITIALIZE) if history.added: if isinstance(history.added[0], sql.ClauseElement): diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py index 813be60ce9..1815901e8a 100644 --- a/lib/sqlalchemy/orm/properties.py +++ b/lib/sqlalchemy/orm/properties.py @@ -119,7 +119,8 @@ class ColumnProperty(StrategizedProperty): active_history=self.active_history, *self.columns) - def _getcommitted(self, state, dict_, column, passive=False): + def _getcommitted(self, state, dict_, column, + passive=attributes.PASSIVE_OFF): return state.get_impl(self.key).\ get_committed_value(state, dict_, passive=passive) @@ -964,8 +965,8 @@ class RelationshipProperty(StrategizedProperty): elif manytoone_fk: self.direction = MANYTOONE if not self.direction: - raise sa_exc.ArgumentError("Can't determine relationshi" - "p direction for relationship '%s' - foreign " + raise sa_exc.ArgumentError("Can't determine relationship" + " direction for relationship '%s' - foreign " "key columns are present in both the parent " "and the child's mapped tables. Specify " "'foreign_keys' argument." % self) @@ -979,7 +980,8 @@ class RelationshipProperty(StrategizedProperty): % self) if self.direction is MANYTOONE and self.passive_deletes: util.warn("On %s, 'passive_deletes' is normally configured " - "on one-to-many, one-to-one, many-to-many relationships only." + "on one-to-many, one-to-one, many-to-many " + "relationships only." % self) def _determine_local_remote_pairs(self): diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 935eed9754..eca88c9dfd 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -1554,7 +1554,7 @@ class Session(object): raise - def is_modified(self, instance, include_collections=True, passive=False): + def is_modified(self, instance, include_collections=True, passive=attributes.PASSIVE_OFF): """Return ``True`` if instance has modified attributes. This method retrieves a history instance for each instrumented diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 435c7ebf70..e5e74eafb4 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -107,8 +107,8 @@ class InstanceState(object): manager.dispatch.init_failure(self, args, kwargs) raise - def get_history(self, key, **kwargs): - return self.manager[key].impl.get_history(self, self.dict, **kwargs) + def get_history(self, key, passive): + return self.manager[key].impl.get_history(self, self.dict, passive) def get_impl(self, key): return self.manager[key].impl diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 8d5649a39a..acdac9984d 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -254,7 +254,7 @@ class LoadDeferredColumns(object): self.state = state self.key = key - def __call__(self, passive=False): + def __call__(self, passive=attributes.PASSIVE_OFF): state, key = self.state, self.key localparent = state.manager.mapper @@ -636,7 +636,7 @@ class LoadLazyAttribute(object): self.state = state self.key = key - def __call__(self, passive=False): + def __call__(self, passive=attributes.PASSIVE_OFF): state, key = self.state, self.key instance_mapper = state.manager.mapper prop = instance_mapper._props[key] diff --git a/lib/sqlalchemy/orm/sync.py b/lib/sqlalchemy/orm/sync.py index bc250b226a..60a8bcb9ac 100644 --- a/lib/sqlalchemy/orm/sync.py +++ b/lib/sqlalchemy/orm/sync.py @@ -8,7 +8,7 @@ between instances based on join conditions. """ -from sqlalchemy.orm import exc, util as mapperutil +from sqlalchemy.orm import exc, util as mapperutil, attributes def populate(source, source_mapper, dest, dest_mapper, synchronize_pairs, uowcommit, flag_cascaded_pks): @@ -19,7 +19,8 @@ def populate(source, source_mapper, dest, dest_mapper, try: # inline of source_mapper._get_state_attr_by_column prop = source_mapper._columntoproperty[l] - value = source.manager[prop.key].impl.get(source, source_dict, False) + value = source.manager[prop.key].impl.get(source, source_dict, + attributes.PASSIVE_OFF) except exc.UnmappedColumnError: _raise_col_to_prop(False, source_mapper, l, dest_mapper, r) @@ -82,7 +83,8 @@ def source_modified(uowcommit, source, source_mapper, synchronize_pairs): prop = source_mapper._columntoproperty[l] except exc.UnmappedColumnError: _raise_col_to_prop(False, source_mapper, l, None, r) - history = uowcommit.get_attribute_history(source, prop.key, passive=True) + history = uowcommit.get_attribute_history(source, prop.key, + attributes.PASSIVE_NO_INITIALIZE) return bool(history.deleted) else: return False diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index 07c9c2b6d6..5e0c939385 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -149,7 +149,8 @@ class UOWTransaction(object): self.states[state] = (isdelete, True) - def get_attribute_history(self, state, key, passive=attributes.PASSIVE_NO_INITIALIZE): + def get_attribute_history(self, state, key, + passive=attributes.PASSIVE_NO_INITIALIZE): """facade to attributes.get_state_history(), including caching of results.""" hashkey = ("history", state, key) @@ -162,9 +163,11 @@ class UOWTransaction(object): history, state_history, cached_passive = self.attributes[hashkey] # if the cached lookup was "passive" and now # we want non-passive, do a non-passive lookup and re-cache - if cached_passive and not passive: + if cached_passive is not attributes.PASSIVE_OFF \ + and passive is attributes.PASSIVE_OFF: impl = state.manager[key].impl - history = impl.get_history(state, state.dict, passive=False) + history = impl.get_history(state, state.dict, + attributes.PASSIVE_OFF) if history and impl.uses_objects: state_history = history.as_state() else: @@ -174,7 +177,7 @@ class UOWTransaction(object): impl = state.manager[key].impl # TODO: store the history as (state, object) tuples # so we don't have to keep converting here - history = impl.get_history(state, state.dict, passive=passive) + history = impl.get_history(state, state.dict, passive) if history and impl.uses_objects: state_history = history.as_state() else: diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 4ac78bd169..d723a18695 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -665,6 +665,7 @@ class _symbol(object): return symbol, (self.name,) def __repr__(self): return "" % self.name + _symbol.__name__ = 'symbol' diff --git a/test/orm/test_attributes.py b/test/orm/test_attributes.py index 46bddb0471..52a06d1504 100644 --- a/test/orm/test_attributes.py +++ b/test/orm/test_attributes.py @@ -972,7 +972,9 @@ class PendingBackrefTest(_base.ORMTest): p4 = Post("post 5") p4.blog = b assert called[0] == 0 - eq_(attributes.instance_state(b).get_history('posts'), ([p, p4], [p1, p2, p3], [])) + eq_(attributes.instance_state(b). + get_history('posts', attributes.PASSIVE_OFF), + ([p, p4], [p1, p2, p3], [])) assert called[0] == 1 def test_lazy_remove(self):