From 0ca7b53b4235c2fbabfbb6a4e2df2f7a369df6f2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 12 Jul 2013 11:32:34 -0400 Subject: Fixed bug where the expression system relied upon the ``str()`` form of a some expressions when referring to the ``.c`` collection on a ``select()`` construct, but the ``str()`` form isn't available since the element relies on dialect-specific compilation constructs, notably the ``__getitem__()`` operator as used with a Postgresql ``ARRAY`` element. The fix also adds a new exception class :class:`.UnsupportedCompilationError` which is raised in those cases where a compiler is asked to compile something it doesn't know how to. Also in 0.8.3. [ticket:2780] --- lib/sqlalchemy/sql/compiler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 93dc3fc4d..a5f545de9 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -696,8 +696,12 @@ class SQLCompiler(engine.Compiled): if disp: return disp(binary, operator, **kw) else: - return self._generate_generic_binary(binary, - OPERATORS[operator], **kw) + try: + opstring = OPERATORS[operator] + except KeyError: + raise exc.UnsupportedCompilationError(self, operator) + else: + return self._generate_generic_binary(binary, opstring, **kw) def visit_custom_op_binary(self, element, operator, **kw): return self._generate_generic_binary(element, -- cgit v1.2.1