Hi All,

I'm trying to query more than one class at the same time, and order
the result by date (both classes have a .date property), using the
following query:

        c.items = meta.Session.query(model.ArkEmail, model.ArkNote).\
                filter(model.ArkEmail.is_thread_parent == True).\
                filter(model.ArkEmail.project == c.project).\
                filter(model.ArkEmail.is_duplicate == False).\
                filter(model.ArkNote.project.contains(c.project)).\
                order_by(sa.desc(model.ArkEmail.date),
sa.desc(model.ArkNote.date)).\
                all()

There's not really any mapping between these two classes, I jsut want
a list ordered by date of the two class instances that match the
filter criteria.

I'm hitting some wierdness with this in so much as on some queries the
results return nothing (when they should do according to what's in the
database), I'm also fairly certain the ordering is not working.

It's also returning the result inside a tuple:

>>> c.items
[(<ark.model.clientprojectshot.ArkEmail object at 0x00000000073FF208>,
<ark.model.utilities.ArkNote object at 0x00000000073FF278>)]

So generally, I think I'm doing quite a lot wrong. Any pointers as to
the correct way of doing this?

Many thanks,

Jules

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to