From 0025a6a50eabe323c353681a1dd3949c8e57bb9b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 2 Jul 2010 14:07:42 -0400 Subject: - 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] --- lib/sqlalchemy/ext/compiler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy') 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 -- cgit v1.2.1