]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
the compiler works for types ! heh
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 31 May 2009 14:56:56 +0000 (14:56 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 31 May 2009 14:56:56 +0000 (14:56 +0000)
test/ext/compiler.py

index c8fefdf06f48db76b9ddeaa07907413d1a2f231a..71a7c8821e81017b6a19d3e675ad762cc283665b 100644 (file)
@@ -1,5 +1,6 @@
 import testenv; testenv.configure_for_tests()
 from sqlalchemy import *
+from sqlalchemy.types import TypeEngine
 from sqlalchemy.sql.expression import ClauseElement, ColumnClause
 from sqlalchemy.schema import DDLElement
 from sqlalchemy.ext.compiler import compiles
@@ -27,7 +28,35 @@ class UserDefinedTest(TestBase, AssertsCompiledSQL):
             select([MyThingy('x'), MyThingy('y')]).where(MyThingy() == 5),
             "SELECT >>x<<, >>y<< WHERE >>MYTHINGY!<< = :MYTHINGY!_1"
         )
+    
+    def test_types(self):
+        class MyType(TypeEngine):
+            pass
+        
+        @compiles(MyType, 'sqlite')
+        def visit_type(type, compiler, **kw):
+            return "SQLITE_FOO"
+
+        @compiles(MyType, 'postgres')
+        def visit_type(type, compiler, **kw):
+            return "POSTGRES_FOO"
+
+        from sqlalchemy.dialects.sqlite import base as sqlite
+        from sqlalchemy.dialects.postgres import base as postgres
 
+        self.assert_compile(
+            MyType(),
+            "SQLITE_FOO",
+            dialect=sqlite.dialect()
+        )
+
+        self.assert_compile(
+            MyType(),
+            "POSTGRES_FOO",
+            dialect=postgres.dialect()
+        )
+        
+        
     def test_stateful(self):
         class MyThingy(ColumnClause):
             def __init__(self):