]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- the history_meta versioning recipe sets "unique=False"
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 23 Aug 2010 22:17:31 +0000 (18:17 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 23 Aug 2010 22:17:31 +0000 (18:17 -0400)
when copying columns, so that the versioning
table handles multiple rows with repeating values.
[ticket:1887]

CHANGES
examples/versioning/history_meta.py
examples/versioning/test_versioning.py

diff --git a/CHANGES b/CHANGES
index e099f68ae093997b33e826e28b3fc5dda20dd3f7..6e41063a50d9014244f05c802abd9fe58ba2430b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -207,6 +207,11 @@ CHANGES
     custom cache code is portable and now within
     "caching_query.py".  This allows the example to 
     be easier to "drop in" to existing projects.
+
+  - the history_meta versioning recipe sets "unique=False"
+    when copying columns, so that the versioning 
+    table handles multiple rows with repeating values.
+    [ticket:1887]
     
 0.6.3
 =====
index a7b03c5bfc324a3e21bafef7ef52cd7034cedccc..c2b283f1a04541c5d1dbe7ea5b411660652b38e3 100644 (file)
@@ -31,6 +31,7 @@ def _history_mapper(local_mapper):
                 continue
                 
             col = column.copy()
+            col.unique = False
 
             if super_mapper and col_references_table(column, super_mapper.local_table):
                 super_fks.append((col.key, list(super_history_mapper.base_mapper.local_table.primary_key)[0]))
@@ -160,5 +161,4 @@ class VersionedListener(SessionExtension):
         for obj in versioned_objects(session.dirty):
             create_version(obj, session)
         for obj in versioned_objects(session.deleted):
-            create_version(obj, session, deleted = True)
-            
+            create_version(obj, session, deleted = True)
\ No newline at end of file
index 1a72a0659236e98d6175f4ccdd72cd0c860aa3cc..2a7a2ca668896bc3237653e78790e22086187a2d 100644 (file)
@@ -244,5 +244,28 @@ class TestVersioning(TestBase):
                 SubClassHistory(id=2, name=u's1', type=u'sub', version=1)
             ]
         )
+    
+    def test_unique(self):
+        class SomeClass(Base, ComparableEntity):
+            __tablename__ = 'sometable'
+            
+            id = Column(Integer, primary_key=True)
+            name = Column(String(50), unique=True)
+            data = Column(String(50))
+            
+        self.create_tables()
+        sess = Session()
+        sc = SomeClass(name='sc1', data='sc1')
+        sess.add(sc)
+        sess.commit()
+        
+        sc.data = 'sc1modified'
+        sess.commit()
+        
+        assert sc.version == 2
+        
+        sc.data = 'sc1modified2'
+        sess.commit()
         
+        assert sc.version == 3