Hi,

I'm using polymorphism for some of my models and I'm wondering how I
should use the with_polymorphic query method.

Consider the following:
"""
class A(Base):
   type_ = Column(Integer, nullable=False)
   arg = Column(String(20))
  __mapper_args__ = {'polymorphic_on': type_, 'polymorphic_identity': 0}

class B(A):
    __mapper_args__ = {'polymorphic_identity': 1}

class C(A):
    __mapper_args__ = {'polymorphic_identity': 2}

class D(A):
    __mapper_args__ = {'polymorphic_identity': 3}
"""

When I query :

"""
session.query(A).with_polymorphic([B,C]).filter(A.arg == 'test')
"""

I get D elements in my result.
I've tried :

"""
session.query(A).with_polymorphic([B,C]).filter(or_(B.arg=='test',
C.arg=='test'))
"""

But it doesn't work neither.

Could somebody explain me what I did wrong and how I should do ?

Regards

Gaston

-- 
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.

Reply via email to