the deannotation step is making a clone of the CTE and not maintaining
all the linkages properly. Likely a bug but a really deep one I could
use some help on.
if you can confirm the query is correct with this patch:
diff --git a/lib/sqlalchemy/orm/properties.py
b/lib/sqlalchemy/orm/properties.py
index f3dce75..45b9e83 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -118,8 +118,9 @@ class ColumnProperty(StrategizedProperty):
"""
super(ColumnProperty, self).__init__()
self._orig_columns = [expression._labeled(c) for c in columns]
- self.columns = [expression._labeled(_orm_full_deannotate(c))
- for c in columns]
+ #self.columns = [expression._labeled(_orm_full_deannotate(c))
+ # for c in columns]
+ self.columns = [expression._labeled(c) for c in columns]
self.group = kwargs.pop('group', None)
self.deferred = kwargs.pop('deferred', False)
self.instrument = kwargs.pop('_instrument', True)
then we know it's strictly the visit-clone step. isolated test case
would need to be constructed, the style we're looking for would be along
the lines of what we see in
https://bitbucket.org/zzzeek/sqlalchemy/src/31a0da32a8af2503c6b94123a0e869816d83c707/test/sql/test_generative.py?at=master&fileviewer=file-view-default#test_generative.py-299
though perhaps the CTE specific tests would be in test/sql/test_cte.py.