summaryrefslogtreecommitdiff
path: root/test/sql/test_select.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/sql/test_select.py')
-rw-r--r--test/sql/test_select.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/sql/test_select.py b/test/sql/test_select.py
index 96c6abd07..1dfb4cd19 100644
--- a/test/sql/test_select.py
+++ b/test/sql/test_select.py
@@ -82,6 +82,54 @@ class FutureSelectTest(fixtures.TestBase, AssertsCompiledSQL):
"WHERE mytable.myid = myothertable.otherid",
)
+ def test_new_calling_style_clauseelement_thing_that_has_iter(self):
+ class Thing(object):
+ def __clause_element__(self):
+ return table1
+
+ def __iter__(self):
+ return iter(["a", "b", "c"])
+
+ stmt = select(Thing())
+ self.assert_compile(
+ stmt,
+ "SELECT mytable.myid, mytable.name, "
+ "mytable.description FROM mytable",
+ )
+
+ def test_new_calling_style_inspectable_ce_thing_that_has_iter(self):
+ class Thing(object):
+ def __iter__(self):
+ return iter(["a", "b", "c"])
+
+ class InspectedThing(object):
+ def __clause_element__(self):
+ return table1
+
+ from sqlalchemy.inspection import _inspects
+
+ @_inspects(Thing)
+ def _ce(thing):
+ return InspectedThing()
+
+ stmt = select(Thing())
+ self.assert_compile(
+ stmt,
+ "SELECT mytable.myid, mytable.name, "
+ "mytable.description FROM mytable",
+ )
+
+ def test_new_calling_style_thing_ok_actually_use_iter(self):
+ class Thing(object):
+ def __iter__(self):
+ return iter([table1.c.name, table1.c.description])
+
+ stmt = select(Thing())
+ self.assert_compile(
+ stmt,
+ "SELECT mytable.name, mytable.description FROM mytable",
+ )
+
def test_kw_triggers_old_style(self):
assert_raises_message(