Thanks.  That works.  The order_by=None is something I never would
have thought of.

On 4/20/07, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
>
> On Apr 20, 2007, at 11:14 PM, Paul Kippes wrote:
>
> >
> > I had been using an order_by with the AssociationProxy since 0.3.4.
> > In 0.3.6, this has been broken or else no longer supported.  Since
> > this is an extension, it has no unit tests (is this the norm?)
> >
>
> extensions do have unit tests in some cases, the association proxy
> was a real fast idea I had one day, and its also a pretty small set
> of code, so it hasnt acquired any as of yet.
>
> > The resulting SQL fails with "no such column: items.description"
>
> this error is not related to the association proxy and is because the
> "items" table is not used to load OrderItem objects, so the OrderItem
> eager loader leaves the column alone.  there is a line in the 0.3.5
> version and earlier that runs the "alias" step unconditionally on all
> the ORDER BY clauses attached to the statement and thats why it works
> there...but this was removed because it could affect elements which
> the user didnt intend to be lumped into the eager clause for that
> relationship.
>
> the appropriate way to set up this ordering is like:
>
> mapper(Order, orders, properties={
>      'itemassociations':relation(OrderItem, cascade="all, delete-
> orphan", lazy=False, order_by=None)
> })
> mapper(Item, items)
> mapper(OrderItem, orderitems, properties={
>      'item':relation(Item, lazy=False, order_by=items.c.description)
> })
>
> the "order_by=None" on itemassociations is so no ORDER BY clause is
> generated for that relationship, allowing the order by on the "item"
> relationship to take effect.
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to