[sqlalchemy] How to order a many-to-many association_proxy?

2014-02-27 Thread Seth P
Apologies if I'm missing this is the docs somewhere, but I can't figure it out. Suppose I have a many-to-many relationship between A and B, and that I'd like have the various B's that a particular A points to ordered by B.ordinal (i.e. in the examples below, I'd like A.bs to be sorted to

Re: [sqlalchemy] How to order a many-to-many association_proxy?

2014-02-27 Thread Michael Bayer
Since this is the association object pattern, I’ll describe that first. The pattern there is a little complicated, but if you can go with a straight many-to-many, it is then much easier. The relationship as specified here is from A to A_to_B. If I have an “A” row loaded into some_a, and

Re: [sqlalchemy] How to order a many-to-many association_proxy?

2014-02-27 Thread Seth P
Thank you. This was very helpful. One non-trivial thing that stumped me for a while is that if B is derived from a B_base using joined-table inheritance, and the order variable is in the base table B_base, then it seems one must include B_base explicitly -- as highlighted below. from

Re: [sqlalchemy] How to order a many-to-many association_proxy?

2014-02-27 Thread Michael Bayer
On Feb 27, 2014, at 9:23 PM, Seth P spadow...@gmail.com wrote: Thank you. This was very helpful. One non-trivial thing that stumped me for a while is that if B is derived from a B_base using joined-table inheritance, and the order variable is in the base table B_base, then it seems one

Re: [sqlalchemy] How to order a many-to-many association_proxy?

2014-02-27 Thread Seth P
Good point, but unfortunately, unless I'm missing something, including only B_base and removing B from the join doesn't seem to work when A is also derived (using joined-table inheritance) from B_base (which is my actual situation, despite what the nomenclature here suggest). On Thursday,