establishing forwards compatibility with 0.5.
"modified" history to be properly cleared after
a flush() (backported from 0.5).
+ - added add() and add_all() methods to Session,
+ establishing forwards compatibility with 0.5.
+
- fixed bug preventing merge() from functioning in
conjunction with a comparable_property()
self._save_or_update_impl(instance, entity_name=entity_name)
self._cascade_save_or_update(instance)
+ def add(self, instance, entity_name=None):
+ """Add the given instance into this ``Session``.
+
+ This provides forwards compatibility with 0.5.
+
+ """
+ self.save_or_update(instance, entity_name)
+
+ def add_all(self, instances):
+ """Add the given collection of instances to this ``Session``.
+
+ This provides forwards compatibility with 0.5.
+ """
+
+ for instance in instances:
+ self.add(instance)
+
def _cascade_save_or_update(self, instance):
for obj, mapper in _cascade_iterator('save-update', instance, halt_on=lambda c:c in self):
self._save_or_update_impl(obj, mapper.entity_name)
session.flush(objects=set())
session.flush(objects=())
session.flush(objects=iter([]))
-
+
+ def test_forwards_compat_add(self):
+ class User(object):pass
+ mapper(User, users)
+ sess = create_session()
+ u1 = User()
+ sess.add(u1)
+ assert u1 in sess
+ u2, u3 = User(), User()
+ sess.add_all([u2, u3])
+ assert u2, u3 in sess
+ sess.flush()
+ sess.expunge(u1)
+ assert u1 not in sess
+ sess.add(u1)
+ assert u1 in sess
+
@testing.unsupported('sqlite', 'mssql') # TEMP: test causes mssql to hang
@engines.close_open_connections
def test_autoflush(self):