summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_compiler.py40
-rw-r--r--test/sql/test_selectable.py13
2 files changed, 53 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index 8b9f9cfa4..bdfcccb22 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -2482,6 +2482,46 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
)
+class UnsupportedTest(fixtures.TestBase):
+ def test_unsupported_element_str_visit_name(self):
+ from sqlalchemy.sql.expression import ClauseElement
+ class SomeElement(ClauseElement):
+ __visit_name__ = 'some_element'
+
+ assert_raises_message(
+ exc.UnsupportedCompilationError,
+ r"Compiler <sqlalchemy.sql.compiler.SQLCompiler .*"
+ r"can't render element of type <class '.*SomeElement'>",
+ SomeElement().compile
+ )
+
+ def test_unsupported_element_meth_visit_name(self):
+ from sqlalchemy.sql.expression import ClauseElement
+ class SomeElement(ClauseElement):
+ @classmethod
+ def __visit_name__(cls):
+ return "some_element"
+
+ assert_raises_message(
+ exc.UnsupportedCompilationError,
+ r"Compiler <sqlalchemy.sql.compiler.SQLCompiler .*"
+ r"can't render element of type <class '.*SomeElement'>",
+ SomeElement().compile
+ )
+
+ def test_unsupported_operator(self):
+ from sqlalchemy.sql.expression import BinaryExpression
+ def myop(x, y):
+ pass
+ binary = BinaryExpression(column("foo"), column("bar"), myop)
+ assert_raises_message(
+ exc.UnsupportedCompilationError,
+ r"Compiler <sqlalchemy.sql.compiler.SQLCompiler .*"
+ r"can't render element of type <function.*",
+ binary.compile
+ )
+
+
class KwargPropagationTest(fixtures.TestBase):
@classmethod
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index 335083ce1..df174fb25 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -148,6 +148,19 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
s = select([t])._clone()
assert c in s.c.bar.proxy_set
+
+ def test_no_error_on_unsupported_expr_key(self):
+ from sqlalchemy.dialects.postgresql import ARRAY
+
+ t = table('t', column('x', ARRAY(Integer)))
+
+ expr = t.c.x[5]
+ s = select([t, expr])
+ eq_(
+ s.c.keys(),
+ ['x', expr.anon_label]
+ )
+
def test_cloned_intersection(self):
t1 = table('t1', column('x'))
t2 = table('t2', column('x'))