0.1.6
+- added 'version_id' keyword argument to mapper. this keyword should reference a
+Column object with type Integer, preferably non-nullable, which will be used on
+the mapped table to track version numbers. this number is incremented on each
+save operation and is specifed in the UPDATE/DELETE conditions so that it
+factors into the returned row count, which results in a ConcurrencyError if the
+value received is not the expected count.
- added 'entity_name' keyword argument to mapper. a mapper is now associated
with a class via the class object as well as an optional entity_name parameter,
which is a string defaulting to None. any number of primary mappers can be
objectstore.clear()
self.assert_(m.get(8).user_name == name2)
self.assert_(m.get(7).user_name != name1)
+
+class VersioningTest(AssertMixin):
+ def setUpAll(self):
+ global version_table
+ version_table = Table('version_test', db,
+ Column('id', Integer, primary_key=True),
+ Column('version_id', Integer, nullable=False),
+ Column('value', String(40), nullable=False)
+ ).create()
+ def tearDownAll(self):
+ version_table.drop()
+ def tearDown(self):
+ version_table.delete().execute()
+ objectstore.clear()
+ clear_mappers()
+
+ def testbasic(self):
+ class Foo(object):pass
+ assign_mapper(Foo, version_table, version_id_col=version_table.c.version_id)
+ f1 =Foo(value='f1')
+ f2 = Foo(value='f2')
+ objectstore.commit()
+
+ f1.value='f1rev2'
+ objectstore.commit()
+ s = objectstore.Session()
+ f1_s = Foo.mapper.using(s).get(f1.id)
+ f1_s.value='f1rev3'
+ s.commit()
+
+ f1.value='f1rev3mine'
+ success = False
+ try:
+ # a concurrent session has modified this, should throw
+ # an exception
+ objectstore.commit()
+ except SQLAlchemyError:
+ success = True
+ assert success
+
+ objectstore.clear()
+ f1 = Foo.mapper.get(f1.id)
+ f2 = Foo.mapper.get(f2.id)
+
+ f1_s.value='f1rev4'
+ s.commit()
+
+ objectstore.delete(f1, f2)
+ success = False
+ try:
+ objectstore.commit()
+ except SQLAlchemyError:
+ success = True
+ assert success
class UnicodeTest(AssertMixin):
def setUpAll(self):