On Fri, Feb 14, 2020 at 5:35 PM Mark Aquino <maquino1...@gmail.com> wrote: > > I have a polymorphic class structure like this, with a lot of classes > extending the parent class. > In reality I'm using a Mixin that declares the visible_id column and it's > defined with @declared_attr.cascading, but for simplicity: > > > > class A(Base): > __tablename__ = 'a' > id = Column(Integer, primary_key=True) > visible_id = Column(Integer) > > class B(A): > __tablename__ = 'b' > id = Column(Integer, ForeignKey("A.id"), primary_key=True) > visible_id = Column(Integer) > > > What I need for my application is to query A.visible_id and return the CHILD > values for B.visible_id (and all the others). > > The inheritance works fine, i.e. if i query all As in the database, my > response is a list of [B] objects, but unless I directly query B the > visible_id from A takes precedence and I cannot query A.visible_id if I > remove it from A. > > Can anyone tell me how to configure this? >
Out of interest, what is the point of having a visible_id column in the B table? I'm having difficulty imagining what it would mean to have an instance of B (which due to inheritance is also an instance of A) which has different values in A.visible_id and B.visible_id. Simon -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAFHwexf305mqE_NRqxF2Pv1H9j9ngt6wVHpLmWaVRHi2Ot4o2g%40mail.gmail.com.