diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-14 11:18:58 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-14 11:29:50 -0500 |
commit | b4c6cfc2fde6c652e79ca157f8023a3f8941bc3c (patch) | |
tree | 8d494f71cb634060584555e6bc0aadbc8e3dfa3a /lib/sqlalchemy/ext/compiler.py | |
parent | 0a41f9bea6602c52c59af0f7b572308b2c2b27ab (diff) | |
download | sqlalchemy-b4c6cfc2fde6c652e79ca157f8023a3f8941bc3c.tar.gz |
Use UnsupportedCompilationError for no default compiler
Fixed issue where the stringification that is sometimes called when
attempting to generate the "key" for the ``.c`` collection on a selectable
would fail if the column were an unlabeled custom SQL construct using the
``sqlalchemy.ext.compiler`` extension, and did not provide a default
compilation form; while this seems like an unusual case, it can get invoked
for some ORM scenarios such as when the expression is used in an "order by"
in combination with joined eager loading. The issue is that the lack of a
default compiler function was raising :class:`.CompileError` and not
:class:`.UnsupportedCompilationError`.
Fixes: #5836
Change-Id: I5af243b2c70c7dcca4b212a3869c3017a50c132b
Diffstat (limited to 'lib/sqlalchemy/ext/compiler.py')
-rw-r--r-- | lib/sqlalchemy/ext/compiler.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py index 5a31173ec..47fb6720b 100644 --- a/lib/sqlalchemy/ext/compiler.py +++ b/lib/sqlalchemy/ext/compiler.py @@ -425,9 +425,11 @@ def compiles(class_, *specs): return existing_dispatch(element, compiler, **kw) except exc.UnsupportedCompilationError as uce: util.raise_( - exc.CompileError( - "%s construct has no default " - "compilation handler." % type(element) + exc.UnsupportedCompilationError( + compiler, + type(element), + message="%s construct has no default " + "compilation handler." % type(element), ), from_=uce, ) @@ -476,9 +478,11 @@ class _dispatcher(object): fn = self.specs["default"] except KeyError as ke: util.raise_( - exc.CompileError( - "%s construct has no default " - "compilation handler." % type(element) + exc.UnsupportedCompilationError( + compiler, + type(element), + message="%s construct has no default " + "compilation handler." % type(element), ), replace_context=ke, ) |