Hi List,

I'm inexperienced with DBs so please bear with me.

I would like to return a list of all invoices that are assigned to a
specific client. However the relationships are built so that an
invoice has a foreign key to a project, which in turn has a foreign
key to a client:

Invoice.project > project.client > client

or in reverse

client.projects > project.invoices > invoice[s]

I've really been struggling as how to implement this, from what I've
been reading I want to join these relationships so that I can actually
filter the results, but Im having no luck at implementing this, my
nasty code is below:

       invoices = query(ArkInvoice).\
                 join(ArkInvoice.project).\
                 join(ArkProject.client).\

options(sa.orm.contains_eager(model.ArkInvoice.project.client)).\
                 filter(model.ArkInvoice.project.client.id == id)

Which fails on the instrumented list of 'client' on the contains_eager.

-- 
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