thanks Michael, that's what i have in mind. since anon_N can't be used, i was thinking if they can be named or, in other cases, the sql that generates an anon_N can be extracted?
ps: the object that contains these anon_N columns is a orm.Query object created from a polymorphic mapper with multiple relationships. On Wed, Aug 4, 2010 at 12:29 PM, Michael Bayer <[email protected]>wrote: > > On Aug 4, 2010, at 10:07 AM, Richard Kuesters wrote: > > > hi all, > > > > in a polymorphic query, after a 'print' command i realized that SA > generates some columns named 'anon_X', which can be helpful for me. > > > > the question is: > > > > 1. is it safe to use those anon_X columns to refine my query? > > --- regarding this, my concern is that once the polymorphic query is done > by SA, will it anytime change it's name, or anything else in future > releases? > > it's not. When anonymous aliases are generated within the orm Query > against some entity that you've given it explicitly, you use the column > attributes on that entity to reference those columns, not strings. Never > use strings except for those that you've named explicitly, and at the same > level as where you named it. > > For example, you might use a string if you wanted to ORDER BY some > expression that's named in the columns clause: > > q = sess.query(func.myfunction(...).label('bar')).order_by('bar') > > However, once you nest "q" as a subquery, it gains a .c. collection, and > now you use that .c. collection for all future references to 'bar': > > q = q.subquery() > q2 = sess.query(MyEntity).join((q, q.c.bar==MyEntity.bar)) > > -- > 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]<sqlalchemy%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- 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.
