summaryrefslogtreecommitdiff
path: root/test/sql/test_generative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-06-09 23:39:14 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-06-09 23:39:14 -0400
commita9030d0241964c919b099e4bdb75d38fd420b546 (patch)
tree36e714c1999c6e02e40f63e975c1d6fc241de52a /test/sql/test_generative.py
parent1cc50c81b9d3507e9bcefc625dd07b12a8178e9c (diff)
downloadsqlalchemy-a9030d0241964c919b099e4bdb75d38fd420b546.tar.gz
- Fixed a bug where clause adaption as applied to a :class:`.Label`
object would fail to accommodate the labeled SQL expression in all cases, such that any SQL operation that made use of :meth:`.Label.self_group` would use the original unadapted expression. One effect of this would be that an ORM :func:`.aliased` construct would not fully accommodate attributes mapped by :obj:`.column_property`, such that the un-aliased table could leak out when the property were used in some kinds of SQL comparisons. fixes #3445
Diffstat (limited to 'test/sql/test_generative.py')
-rw-r--r--test/sql/test_generative.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py
index 12bfdfa9d..9cf1ef612 100644
--- a/test/sql/test_generative.py
+++ b/test/sql/test_generative.py
@@ -454,6 +454,27 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL):
str(f1), str(f2)
)
+ def test_labeled_expression_adapt(self):
+ lbl_x = (t3.c.col1 == 1).label('x')
+ t3_alias = t3.alias()
+
+ adapter = sql_util.ColumnAdapter(t3_alias)
+
+ lblx_adapted = adapter.traverse(lbl_x)
+ is_not_(lblx_adapted._element, lbl_x._element)
+
+ lblx_adapted = adapter.traverse(lbl_x)
+ self.assert_compile(
+ select([lblx_adapted.self_group()]),
+ "SELECT (table3_1.col1 = :col1_1) AS x FROM table3 AS table3_1"
+ )
+
+ self.assert_compile(
+ select([lblx_adapted.is_(True)]),
+ "SELECT (table3_1.col1 = :col1_1) IS 1 AS anon_1 "
+ "FROM table3 AS table3_1"
+ )
+
def test_text(self):
clause = text(
"select * from table where foo=:bar",