Hi,

I am new in this group. I'm trying to make a query ordering by a ManyToMany
field.
I have for example the classes below:

class Address(Entity):
    street = Field(Unicode())
    state = Field(Unicode())
    city = Field(Unicode())
    # relationships
    persons = ManyToMany('Person')

class Person(Entity):
    name = Field(unicode())
    email = Field(unicode())
    # relationships
    addresses = ManyToMany('Address')

I know I can do this:
 >> Person.query.all().order_by('email')

But, how can I make a query ordering by a field from Address?
 >> Person.query.all().order_by('state')  # of course this will not work

I case of some person have more than 1 address, the sort can be made
considering the first address. Or any solution.

Somebody can help me please?

Thanks,

Rogerio Hilbert

-- 
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en.

Reply via email to