In fact the problem is more that, with the following: http://pastie.org/5489005 I don't know how to tell SQLAlchemy that it should join the DataSheet relation only once for the query and not once per join(). One option could be to add a .options(orm.noload(MyObject.datasheet)) for every mapped object but it seems a bit lame.

I thought doing somehting like:

Foo = orm.aliased(DataSheet)

q = Occurrence.query.\
join(Foo).\
join(DataSheet.topic).\
outerjoin(Occurrence.species).\
outerjoin(Occurrence.site).\
options(
  orm.contains_eager(Occurrence.datasheet, alias=Foo),
  orm.contains_eager(Species.datasheet, alias=Foo),
  orm.contains_eager(Site.datasheet, alias=Foo),
  orm.contains_eager(Occurrence.species, Occurrence.site)
)

but it doesn't seems to work ...

Any idea ? :)

Thank you,

Julien

On 12/06/2012 13:47, 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 ..

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.

<<attachment: jcigar.vcf>>

Reply via email to