Hello,
I have the following query:
entity = orm.with_polymorphic(
Content, [Event, News]
)
q = db.Session.query(entity)
The "Event" class has a "country" property:
orm.mapper(Event, table['event'], inherits = Content,
polymorphic_identity = _get_type_id('event'),
properties = {
'country' : orm.relationship(
Country, lazy = 'joined'
)
})
I would like to order my query above with .order_by(Country.name)
So I tried:
q = q.outerjoin(Event.country).options(
orm.contains_eager(Event.country)
).order_by(
Country.name
)
but SQLAlchemy complains with:
ArgumentError: Can't find property 'country' on any entity
specified in this Query. Note the full path from root
(Mapper|Content|content) to target entity must be specified.
if I remove the orm.contains_eager() it works, but the "country" table is joined
twice (one for the lazy='joined' and one for my outerjoin())
The problem is that with a polymorphic AliasedClass I can't specify the full
path from root as the target is not a property of the base entity ...
Any idea how to resolve that ? :-)
Thank you,
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.