dont crash for add_columns() when subqueryload=True

Issue #4033 resolved
Michael Bayer
repo owner created an issue

issue #4032 fixes this for the .exists() case, however at the moment a simple call to add_columns() makes subqueryload break:

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

Base = declarative_base()

class A(Base):
    __tablename__ = 'a'
    id = Column(Integer, primary_key=True)
    bs = relationship("B", lazy="subquery")

class B(Base):
    __tablename__ = 'b'
    id = Column(Integer, primary_key=True)
    a_id = Column(ForeignKey(''))

s = Session()

print s.query(A).add_columns('1').statement

for the test, make sure all of .exists() and .subquery() can succeed; do for all eager load styles.

Comments (4)

  1. Michael Bayer reporter

    Check for non-entity when inspecting for subqueryload

    Fixed issue where adding additional non-entity columns to a query that includes an entity with subqueryload relationships would fail, due to an inspection added in 1.1.11 as a result of 🎫4011.

    Change-Id: I8ef082be649125bdc07b428cb9b0a77a65d73671 Fixes: #4033

    → <<cset 3d41ea09a899>>

  2. Log in to comment