ponyorm / pony

Pony Object Relational Mapper
Apache License 2.0
3.64k stars 245 forks source link

AttributeError: 'Query' object has no attribute 'orderby' #8

Closed yetone closed 11 years ago

yetone commented 11 years ago

AttributeError: 'Query' object has no attribute 'orderby'

amalashkevich commented 11 years ago

What are the steps to reproduce this error?

On May 25, 2013, at 7:31 AM, yetone notifications@github.com wrote:

AttributeError: 'Query' object has no attribute 'orderby'

— Reply to this email directly or view it on GitHub.

kozlovsky commented 11 years ago

This is a typo in documentation. Correct method name is order_by()

yetone commented 11 years ago

but order_by method can not use lambda

kozlovsky commented 11 years ago

order_by method have full support for lambda:

>>> from pony.orm.examples.estore import *
>>> select(c for c in Customer).order_by(lambda c: sum(c.orders.total_price))[:]
SELECT "c"."id"
FROM "Customer" "c"
  LEFT JOIN "Order" "order-1"
    ON "c"."id" = "order-1"."customer"
GROUP BY "c"."id"
ORDER BY coalesce(SUM("order-1"."total_price"), 0)

If something doesn't work for you, please send query example which produces an error.

yetone commented 11 years ago

thank u very much!!!

amalashkevich commented 11 years ago

The documentation at http://doc.ponyorm.com/ was updated.