]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fix missing argument in TypeDecorator.copy(), fixes #3584, references #2919
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 13 Nov 2015 16:01:49 +0000 (11:01 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 13 Nov 2015 16:01:49 +0000 (11:01 -0500)
lib/sqlalchemy/sql/type_api.py
test/sql/test_metadata.py

index bc67270eb2e6d9da1070ec59b5f3715b6d8f9be6..c367bc73e0ca9bb22457567c4f3bebcb9f72eec2 100644 (file)
@@ -675,7 +675,7 @@ class TypeDecorator(SchemaEventTarget, TypeEngine):
           def process_result_value(self, value, dialect):
               return value[7:]
 
-          def copy(self):
+          def copy(self, **kw):
               return MyType(self.impl.length)
 
     The class-level "impl" attribute is required, and can reference any
@@ -1136,7 +1136,7 @@ class TypeDecorator(SchemaEventTarget, TypeEngine):
         """
         return self
 
-    def copy(self):
+    def copy(self, **kw):
         """Produce a copy of this :class:`.TypeDecorator` instance.
 
         This is a shallow copy and is provided to fulfill part of
index 501df4671107aa8d3e8e41f35ccd03a90df1ccce..d4039a5fecdc5b1ade8f8dfaaed81971a622698d 100644 (file)
@@ -7,7 +7,7 @@ from sqlalchemy import Integer, String, UniqueConstraint, \
     CheckConstraint, ForeignKey, MetaData, Sequence, \
     ForeignKeyConstraint, PrimaryKeyConstraint, ColumnDefault, Index, event,\
     events, Unicode, types as sqltypes, bindparam, \
-    Table, Column, Boolean, Enum, func, text
+    Table, Column, Boolean, Enum, func, text, TypeDecorator
 from sqlalchemy import schema, exc
 from sqlalchemy.sql import elements, naming
 import sqlalchemy as tsa
@@ -1547,6 +1547,20 @@ class SchemaTypeTest(fixtures.TestBase):
         # our test type sets table, though
         is_(t2.c.y.type.table, t2)
 
+    def test_tometadata_copy_decorated(self):
+
+        class MyDecorated(TypeDecorator):
+            impl = self.MyType
+
+        m1 = MetaData()
+
+        type_ = MyDecorated(schema="z")
+        t1 = Table('x', m1, Column("y", type_))
+
+        m2 = MetaData()
+        t2 = t1.tometadata(m2)
+        eq_(t2.c.y.type.schema, "z")
+
     def test_tometadata_independent_schema(self):
         m1 = MetaData()