On Nov 28, 2012, at 6:02 PM, Conor wrote: > I'm using SQLAlchemy 0.7.9 with PostgreSQL. > > I have a column_property that I'm having trouble with (test case at > http://pastebin.com/hm5CDiV4, reformatted rendered SQL at > http://pastebin.com/hztBvLUU). The column_property is included twice in the > SELECT columns clause with the same alias, causing a 'column reference > "anon_2" is ambiguous' error when executed. > I can only get this to happen if: > > The column_property expression is Boolean-typed, e.g. somecol = > column_property(othercol > 0). I get no problems with a regular boolean > column or if the column_property is an arithmetic expression, e.g. somecol = > column_property(othercol + 1). > I order the query by the column property, e.g. q = q.order_by(somecol) > The query uses LIMIT + joinedload, which causes a subquery to be used and > forces the ORDER BY clause to be included in the subquery's SELECT columns > clause. > It seems like SQLAlchemy's "is this property already in the columns clause" > code fails to detect Boolean-typed column_property objects. Does this sound > right? > yes that is right. the code that's failing here is roughly in the method Query._compound_eager_statement. some ways to maybe force this into working would be to put a label on it, (x > 0).label(None), but that's just a guess. Or it seems you have a workaround, so great this isn't a rush :). http://www.sqlalchemy.org/trac/ticket/2621
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
