in your case, u'll get (tB1 join tB) and that would give u only the B1
instances, so no need for where-filter. If there is a B2 inheriting
B1, then u'll need the additional filtering on type, e.g.
- base level needs filtering .select(type==B)
- leaf levels needs join B2.join(B1).join(B)
- intermediate levels need both - B1.join(B).select(type=B1)
in general it's not that easy; this looks so only if all
class-inheritance is decomposed as multi-table-inheritance. To get
true polymorphic relations this is the only 100% working way, but if
one doesnt need them, one could use concrete tables here or there,
which makes the above scheme somewhat more complicated.
On Saturday 24 March 2007 03:15:51 Rick Morrison wrote:
> Given this:
>
> class A(object):
> pass
>
> class B(object):
> pass
>
> class B1(B):
> pass
>
> mb = mapper(B, tableB, polymorphic_on=tableB.c.typ)
>
> mb1 = mapper(B1, inherits=mb, polymorphic_identity="abc")
>
> ma = mapper(A, tableA,
> properties = {'mybee': relation(B1, lazy=False) }
> )
>
>
> Shouldn't a query like
>
> S.query(A).list()
>
> issue SQL that restricts the resulting join to where tableB.c.typ =
> "abc" ?
>
> or is it necessary to re-specify that
> polymorphic type condition in the relation for 'mybee'?
>
> Thanks,
> Rick
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---