Kevin S <[email protected]> wrote:

> 
> This particular summary is ordering model objects by a column_property. 
> Because of how our schema is setup, we use these column_properties often to 
> eager load a single column from a one-to-one relationship (or petal table). 
> The error is that sometimes it does the order by with a subquery, rather than 
> using the anonymous alias (e.g. anon_1, anon_2). 
> 
> 
> Here is a rough (abbreviated) example of the query:
> 
> 
> SELECT (SELECT mrk_status.status 
>     FROM mrk_status 
>     WHERE mrk_status._marker_status_key = mrk_marker._marker_status_key) AS 
> anon_1,
> mrk_marker._marker_key AS mrk_marker__marker_key, 
> mrk_marker._status_key AS mrk_marker__status_key, 
> mrk_marker._marker_type_key AS mrk_marker__marker_type_key, 
> 
> etc....
> 
> FROM mrk_marker 
> WHERE mrk_marker.symbol = ?
> ORDER BY (SELECT mrk_status.status 
>     FROM mrk_status 
>     WHERE mrk_status._marker_status_key = mrk_marker._marker_status_key), 
> mrk_marker.symbol
> 
> 
> See, it should be ordering by "anon_1, mrk_marker.symbol". And most of the 
> time it does! 

A variety of issues have been repaired in 1.0 regarding this area which you can 
review in 
http://docs.sqlalchemy.org/en/latest/changelog/migration_10.html#columnproperty-constructs-work-a-lot-better-with-aliases-order-by.
   you might want to see if pulling down master from git actually fixes this 
particular issue (and report it if not).

For now, you’d need to be very specific; give the column a label() and order by 
that name:

query(MyClass.my_column_prop.label(“my_label”)).order_by(“my_label”)


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to