]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Column.copy() takes along the "unique" attribute
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 15 Jun 2010 21:56:17 +0000 (17:56 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 15 Jun 2010 21:56:17 +0000 (17:56 -0400)
among others, fixes [ticket:1829] regarding declarative
mixins

CHANGES
lib/sqlalchemy/schema.py
test/engine/test_metadata.py
test/ext/test_declarative.py

diff --git a/CHANGES b/CHANGES
index a479afa9a68b8025e949ec4bdb1631ad160342cf..84cac88906da53e813f1cabe4eb4c0e0ab51d1a5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -52,6 +52,10 @@ CHANGES
     _constructor to return Column, for the purposes of 
     making "configurational" column classes that aren't 
     involved in proxying, etc.
+
+  - Column.copy() takes along the "unique" attribute
+    among others, fixes [ticket:1829] regarding declarative
+    mixins
     
 - firebird
   - Fixed incorrect signature in do_execute(), error 
index 6a69739d1e34978864d647e50550a4cdc2c5456f..b19e2d8baf2f1a6106a0e29c42b8db52f7c8bc7a 100644 (file)
@@ -849,6 +849,7 @@ class Column(SchemaItem, expression.ColumnClause):
                 key = self.key, 
                 primary_key = self.primary_key, 
                 nullable = self.nullable, 
+                unique = self.unique, 
                 quote=self.quote, 
                 index=self.index, 
                 autoincrement=self.autoincrement, 
index 25a9a6d140349510351f849d92524a2fb3dd2a99..4c7eee97b5e0a5a8331295a96be7da2e3cf10c3a 100644 (file)
@@ -40,13 +40,14 @@ class MetaDataTest(TestBase, ComparesTables):
     def test_uninitialized_column_copy(self):
         for col in [
             Column('foo', String(), nullable=False),
+            Column('baz', String(), unique=True),
             Column(Integer(), primary_key=True),
             Column('bar', Integer(), Sequence('foo_seq'), primary_key=True, key='bar'),
             Column(Integer(), ForeignKey('bat.blah')),
             Column('bar', Integer(), ForeignKey('bat.blah'), primary_key=True, key='bar'),
         ]:
             c2 = col.copy()
-            for attr in ('name', 'type', 'nullable', 'primary_key', 'key'):
+            for attr in ('name', 'type', 'nullable', 'primary_key', 'key', 'unique'):
                 eq_(getattr(col, attr), getattr(c2, attr))
             eq_(len(col.foreign_keys), len(c2.foreign_keys))
             if col.default:
index 15799350476edb82ac418e4fbc55e11bb9ca274d..87793658dfd120aebd7b0ea73da3619432bc9ebc 100644 (file)
@@ -1898,6 +1898,17 @@ class DeclarativeMixinTest(DeclarativeTestBase):
         eq_(obj.id,1)
         eq_(obj.name,'testing')
         eq_(obj.foo(),'bar1')
+
+    def test_unique_column(self):
+        
+        class MyMixin(object):
+            id = Column(Integer, primary_key=True)
+            value = Column(String, unique=True)
+
+        class MyModel(Base, MyMixin):
+            __tablename__ = 'test'
+        
+        assert MyModel.__table__.c.value.unique
         
     def test_hierarchical_bases(self):