bug in internal annotations of an "IN" clause, i.e. single table inheritance

Issue #1731 resolved
Mike Bayer repo owner created an issue

i.e. fails:

import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

employee = sa.Table("employee", Base.metadata,
    sa.Column("id", sa.Integer, primary_key=True),
    sa.Column("type", sa.Integer, nullable=False))

class Employee(Base):
    __table__ = employee
    __mapper_args__ = {"polymorphic_identity": 0,
                       "polymorphic_on": employee.c.type}

class Engineer(Employee):
    __mapper_args__ = {"polymorphic_identity": 1}

class Other(Base):
    __tablename__ = "other"

    # Fields
    id = sa.Column(sa.Integer, primary_key=True)
    engineer_id = sa.Column(sa.Integer,
                            sa.ForeignKey("employee.id"))

    # Relations
    engineer = orm.relation("Engineer")

print Other.engineer.has()

Comments (2)

  1. Log in to comment