diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-02 14:07:42 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-02 14:07:42 -0400 |
| commit | 0025a6a50eabe323c353681a1dd3949c8e57bb9b (patch) | |
| tree | 3a945c6e5ea4d470436ab786b209f2ce95775332 /test/ext/test_compiler.py | |
| parent | 8548ca8cc596228f6d72107ac50efa1cf6f4347a (diff) | |
| download | sqlalchemy-0025a6a50eabe323c353681a1dd3949c8e57bb9b.tar.gz | |
- The 'default' compiler is automatically copied over
when overriding the compilation of a built in
clause construct, so no KeyError is raised if the
user-defined compiler is specific to certain
backends and compilation for a different backend
is invoked. [ticket:1838]
Diffstat (limited to 'test/ext/test_compiler.py')
| -rw-r--r-- | test/ext/test_compiler.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ext/test_compiler.py b/test/ext/test_compiler.py index fa1e3c162..3ed84fe61 100644 --- a/test/ext/test_compiler.py +++ b/test/ext/test_compiler.py @@ -125,7 +125,39 @@ class UserDefinedTest(TestBase, AssertsCompiledSQL): ) finally: Select._compiler_dispatch = dispatch + if hasattr(Select, '_compiler_dispatcher'): + del Select._compiler_dispatcher + def test_default_on_existing(self): + """test that the existing compiler function remains + as 'default' when overriding the compilation of an + existing construct.""" + + + t1 = table('t1', column('c1'), column('c2')) + + dispatch = Select._compiler_dispatch + try: + + @compiles(Select, 'sqlite') + def compile(element, compiler, **kw): + return "OVERRIDE" + + s1 = select([t1]) + self.assert_compile( + s1, "SELECT t1.c1, t1.c2 FROM t1", + ) + + from sqlalchemy.dialects.sqlite import base as sqlite + self.assert_compile( + s1, "OVERRIDE", + dialect=sqlite.dialect() + ) + finally: + Select._compiler_dispatch = dispatch + if hasattr(Select, '_compiler_dispatcher'): + del Select._compiler_dispatcher + def test_dialect_specific(self): class AddThingy(DDLElement): __visit_name__ = 'add_thingy' |
