From 6327c59d4f34947128bd9b2860a1732a6932b4d7 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 29 Jul 2016 18:17:43 -0400 Subject: Index should extract __clause_element__() early Fixed bug where :class:`.Index` would fail to extract columns from compound SQL expressions if those SQL expressions were wrapped inside of an ORM-style ``__clause_element__()`` construct. This bug exists in 1.0.x as well, however in 1.1 is more noticeable as hybrid_property @expression now returns a wrapped element. Fixes: #3763 Change-Id: I992536386503a1fb3f2305790abe008d72c44c4a --- lib/sqlalchemy/sql/schema.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql/schema.py') diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 55d0b74e6..2c5daa17c 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -2505,7 +2505,10 @@ class ColumnCollectionMixin(object): for expr in expressions: strname = None column = None - if not isinstance(expr, ClauseElement): + if hasattr(expr, '__clause_element__'): + expr = expr.__clause_element__() + + if not isinstance(expr, (ColumnElement, TextClause)): # this assumes a string strname = expr else: -- cgit v1.2.1