[英]Sqlalchemy. How to set the defaul polymorphic innerjoin?
How to set the defaul polymorphic innerjoin? 如何设置默认多态的innerjoin?
class Some(Base):
__tablename__ = 'some'
@declared_attr
def __mapper_args__(cls):
return {'polymorphic_identity': '%s' % cls.__tablename__,
'polymorphic_on': cls._type,
'with_polymorphic': '*',
'polymorphic_innerjoin': True # how to do it?
}
an INNER join is used if you actually query for that type specifically, no with_polymorphic
needed: 如果实际专门查询该类型,则使用INNER
with_polymorphic
,不需要with_polymorphic
:
sess.query(MySubClass).all()
If you are querying for Some
objects (ie your base), that means you want objects that are also not of type MySubClass
, so an OUTER join is necessary there. 如果要查询
Some
对象(即基础对象),则意味着您想要的对象也不是MySubClass
类型,因此在那里需要OUTER连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.