add a hook to allow new Table columns to propagate to derived selectables, at least manually

Issue #2549 resolved
Mike Bayer repo owner created an issue

test case:

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)


class B(A):
    __tablename__ = 'b'
    id = Column(Integer, ForeignKey('a.id'), primary_key=True)

class C(B):
    new_col = Column(Integer)

configure_mappers()

b_join = B.__mapper__.mapped_table
assert b_join.c.b_new_col is B.__table__.c.new_col
assert C.__mapper__.column_attrs['new_col']('new_col').columns[0](0) is B.__table__.c.new_col

Comments (3)

  1. Mike Bayer reporter

    tests in sql/test_selectable:

    1. join of table A and B. add column to A
    2. join of table A and B. add column to B.
    3. join of table A and B. add column to B, however A has a column with that key as well. the patch probably needs adjustment here and we probably need to pass the Column in - the base selectable returns the col only if the one given is the same col.
    4. join of (join of table A and B) and C. add cols to A, B, C, etc.
    5. select of table A and B
    6. alias of table A
    7. select of join of alias of table A, just to test propagation.
    8. unions - need to implement.
  2. Log in to comment