]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The :meth:`.TypeEngine.with_variant` method will now accept a
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Jul 2014 15:26:13 +0000 (11:26 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Jul 2014 15:26:13 +0000 (11:26 -0400)
type class as an argument which is internally converted to an
instance, using the same convention long established by other
constructs such as :class:`.Column`. fixes #3122

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/sql/type_api.py
test/sql/test_types.py

index f6aa96a0f42795090e6eac1338c1021207c16fc5..6473da10bde7ddf642f42cca6d704fe346003e24 100644 (file)
     :version: 0.9.7
     :released:
 
+    .. change::
+        :tags: bug, sql
+        :tickets: 3122
+
+        The :meth:`.TypeEngine.with_variant` method will now accept a
+        type class as an argument which is internally converted to an
+        instance, using the same convention long established by other
+        constructs such as :class:`.Column`.
+
     .. change::
         :tags: bug, orm
         :tickets: 3117
index 6fa0bc64a227e92166c69b4e4a236f72a62ea274..f9af21baacc68af985b7a7ab86adb0991578e411 100644 (file)
@@ -263,7 +263,7 @@ class TypeEngine(Visitable):
         .. versionadded:: 0.7.2
 
         """
-        return Variant(self, {dialect_name: type_})
+        return Variant(self, {dialect_name: to_instance(type_)})
 
 
     @util.memoized_property
index 1130c9e40cc20dde24d6c76eac093f4c5598dd41..e5c1e7b62404a023ea97a710f24c23fd4d26b1fe 100644 (file)
@@ -816,6 +816,13 @@ class VariantTest(fixtures.TestBase, AssertsCompiledSQL):
             dialect=dialects.postgresql.dialect()
         )
 
+    def test_to_instance(self):
+        self.assert_compile(
+            self.UTypeOne().with_variant(self.UTypeTwo, "postgresql"),
+            "UTYPETWO",
+            dialect=dialects.postgresql.dialect()
+        )
+
     def test_compile_composite(self):
         self.assert_compile(
             self.composite,