dirty = property(lambda s:s.uow.locate_dirty(), doc="a Set of all objects marked as 'dirty' within this Session")
deleted = property(lambda s:s.uow.deleted, doc="a Set of all objects marked as 'deleted' within this Session")
new = property(lambda s:s.uow.new, doc="a Set of all objects marked as 'new' within this Session.")
- identity_map = property(lambda s:s.uow.identity_map, doc="a WeakValueDictionary consisting of all objects within this Session keyed to their _instance_key value.")
+ identity_map = property(lambda s:s.uow.identity_map, doc="a dictionary consisting of all objects within this Session keyed to their _instance_key value.")
def import_instance(self, *args, **kwargs):
"""deprecated; a synynom for merge()"""
s.update(user)
assert user in s
assert user not in s.dirty
+
+ def test_strong_ref(self):
+ """test that the session is strong-referencing"""
+ tables.delete()
+ s = create_session()
+ class User(object):pass
+ mapper(User, users)
+
+ # save user
+ s.save(User())
+ s.flush()
+ user = s.query(User).selectone()
+ user = None
+ print s.identity_map
+ import gc
+ gc.collect()
+ assert len(s.identity_map) == 1
def test_no_save_cascade(self):
mapper(Address, addresses)
u = User()
u.user_id=42
ctx.current.flush()
-
+
+ def test_dont_update_blanks(self):
+ mapper(User, users)
+ u = User()
+ u.user_name = ""
+ ctx.current.flush()
+ ctx.current.clear()
+ u = ctx.current.query(User).get(u.user_id)
+ u.user_name = ""
+ def go():
+ ctx.current.flush()
+ self.assert_sql_count(db, go, 0)
+
def testmultitable(self):
"""tests a save of an object where each instance spans two tables. also tests
redefinition of the keynames for the column properties."""