diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-12-06 12:49:39 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-12-06 12:49:39 -0500 |
commit | 5c9d53fb02effed81329ca7964f99777f2ab6ec4 (patch) | |
tree | 3039aba6b3aaebf7a85d1a11457b426f76b7c82f /lib/sqlalchemy/ext/compiler.py | |
parent | 1dea4c1f87a43e668525b4c917cdc9eb4b56f218 (diff) | |
download | sqlalchemy-5c9d53fb02effed81329ca7964f99777f2ab6ec4.tar.gz |
- [bug] the @compiles decorator raises an
informative error message when no "default"
compilation handler is present, rather
than KeyError.
Diffstat (limited to 'lib/sqlalchemy/ext/compiler.py')
-rw-r--r-- | lib/sqlalchemy/ext/compiler.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py index cb126c374..daa9e1551 100644 --- a/lib/sqlalchemy/ext/compiler.py +++ b/lib/sqlalchemy/ext/compiler.py @@ -367,6 +367,7 @@ Example usage:: ) """ +from sqlalchemy import exc def compiles(class_, *specs): def decorate(fn): @@ -399,6 +400,11 @@ class _dispatcher(object): # TODO: yes, this could also switch off of DBAPI in use. fn = self.specs.get(compiler.dialect.name, None) if not fn: - fn = self.specs['default'] + try: + fn = self.specs['default'] + except KeyError: + raise exc.CompileError( + "%s construct has no default " + "compilation handler." % type(element)) return fn(element, compiler, **kw) |