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 /lib/sqlalchemy/ext/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 'lib/sqlalchemy/ext/compiler.py')
-rw-r--r-- | lib/sqlalchemy/ext/compiler.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py index 68c434fd9..12f1e443d 100644 --- a/lib/sqlalchemy/ext/compiler.py +++ b/lib/sqlalchemy/ext/compiler.py @@ -198,9 +198,13 @@ A big part of using the compiler extension is subclassing SQLAlchemy expression def compiles(class_, *specs): def decorate(fn): existing = class_.__dict__.get('_compiler_dispatcher', None) + existing_dispatch = class_.__dict__.get('_compiler_dispatch') if not existing: existing = _dispatcher() - + + if existing_dispatch: + existing.specs['default'] = existing_dispatch + # TODO: why is the lambda needed ? setattr(class_, '_compiler_dispatch', lambda *arg, **kw: existing(*arg, **kw)) setattr(class_, '_compiler_dispatcher', existing) @@ -208,6 +212,7 @@ def compiles(class_, *specs): if specs: for s in specs: existing.specs[s] = fn + else: existing.specs['default'] = fn return fn |