dont crash for add_columns() when subqueryload=True

Issue #4033 resolved
Mike 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('a.id'))

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. Mike 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. Mike 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 (cherry picked from commit 3d41ea09a899b06feedd02864a69b8dc833f5a6b)

    → <<cset 23565166f1e1>>

  3. Log in to comment