0.4.5
=====
-
+- orm
+ - when attributes are expired on a pending instance, an
+ error will not be raised when the "refresh" action
+ is triggered and returns no result
+
0.4.4
------
- sql
state = instance._state
if '_instance_key' in state.dict:
identity_key = state.dict['_instance_key']
+ shouldraise = True
else:
+ # if instance is pending, a refresh operation may not complete (even if PK attributes are assigned)
+ shouldraise = False
identity_key = mapper._identity_key_from_state(state)
- if session.query(mapper)._get(identity_key, refresh_instance=state, only_load_props=attribute_names) is None:
+ if session.query(mapper)._get(identity_key, refresh_instance=state, only_load_props=attribute_names) is None and shouldraise:
raise exceptions.InvalidRequestError("Could not refresh instance '%s'" % instance_str(instance))
def _state_mapper(state, entity_name=None):
except exceptions.InvalidRequestError, e:
assert str(e) == "Instance <class 'testlib.fixtures.User'> is not bound to a Session, and no contextual session is established; attribute refresh operation cannot proceed"
+ def test_pending_doesnt_raise(self):
+ mapper(User, users)
+ sess = create_session()
+ u = User(id=15)
+ sess.save(u)
+ sess.expire(u, ['name'])
+ assert u.name is None
+
def test_no_instance_key(self):
# this tests an artificial condition such that
# an instance is pending, but has expired attributes. this