hes right.  you wouldnt get any "B"s in this case since they wouldnt  
have a join on B1's table.

if you query for single-table inheritance relations, there is a  
little bit of logic in Query to add the polymorphic identity to the  
query if you are only querying a subclass, which also should take  
effect on lazy loads, probably not eager loads right now (all the  
inheritance work with relationships has been with joined-table  
inheritance so far).

i would also say its slightly better in the case of joined table  
inheritance to *not* query for the type column as well since it can  
add weight to the query.

On Mar 24, 2007, at 3:08 AM, [EMAIL PROTECTED] wrote:

>
> 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 sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to