new single inh polymorphic identity logic in query should skip if there's no actual identity

Issue #3462 resolved
Mike Bayer repo owner created an issue

e.g.

from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class Client(Base):
    __tablename__ = 'client'
    id = Column(Integer, primary_key=True)


class SubClient(Client):
    pass


class Thing(Base):
    __tablename__ = 'thing'
    id = Column(Integer, primary_key=True)
    cid = Column(ForeignKey('client.id'))

s = Session()

print s.query(Thing).join(SubClient, Thing.cid == SubClient.id)

produces:

SELECT thing.id AS thing_id, thing.cid AS thing_cid 
FROM thing JOIN client ON thing.cid = client.id AND NULL

Comments (1)

  1. Mike Bayer reporter
    • Fixed 1.0 regression where the enhanced behavior of single-inheritance joins of 🎫3222 takes place inappropriately for a JOIN along explicit join criteria with a single-inheritance subclass that does not make use of any discriminator, resulting in an additional "AND NULL" clause. fixes #3462

    → <<cset 9f4149766c93>>

  2. Log in to comment