From 1c6ae364df4aade915be2f4e5e25b41cdf5aa81c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 31 May 2009 14:56:56 +0000 Subject: [PATCH] the compiler works for types ! heh --- test/ext/compiler.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/ext/compiler.py b/test/ext/compiler.py index c8fefdf06f..71a7c8821e 100644 --- a/test/ext/compiler.py +++ b/test/ext/compiler.py @@ -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): -- 2.47.3