On 12/06/2012 16:02, Julien Cigar wrote:
On 12/06/2012 15:45, Michael Bayer wrote:
On Dec 6, 2012, at 7:47 AM, Julien Cigar wrote:

Hello,

Any idea why the following doesn't work ? :

Topic2=  orm.aliased(Topic)
q=  Occurrence.query.\
    join(Occurrence.datasheet).\
    options(orm.contains_eager(Occurrence.datasheet)).\
    join(Topic2).\
    options(orm.contains_eager(DataSheet.topic,alias=Topic2)).\
    outerjoin(Occurrence.species).\
    options(orm.contains_eager(Occurrence.species))

I get a:

ArgumentError: Can't find property 'topic' on any entity specified in this Query. Note the full path from root (Mapper|Occurrence|occurrences) to target entity must be specified.


and I don't understand why ..

so "paths" work like this:

query(Occurence).join(Occurrence.datasheet).join(Datasheet.topic).join(Occurrence.species)

here are the major "paths" we've cerated:

    (Occurence, Occurrence.datasheet, )

    (Occurence, Occurrence.datasheet, Datasheet, Datasheet.topic)

    (Occurence, Occurrence.species)

There's actually "paths" for every attribute on all three of those classes worked up too, but for the purpose of relationship loading, what you send as an "eager loading" option has to match one of those paths.

so:

    contains_eager(Occurrence.datasheet, Datasheet.topic, alias=Topic2)

Thank you, it looks like I misunderstood how those "paths" worked


Another thing I wondered is if there is a shortcut (not joinedload()) for:

Bar.query.join(Foo).options(orm.contains_eager(Bar.foo)).filter(Foo.id==1)

I thought something like:

Bar.query.join(Foo, prop='foo').filter(Foo.id==1)

(to be able to specify the property directly in the join)











Thanks,
Julien

--
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.

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

<jcigar.vcf>




--
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.

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

<<attachment: jcigar.vcf>>

Reply via email to