I believe my problem is related to 
https://bitbucket.org/zzzeek/sqlalchemy/issues/4124.

I have an AbstractConcreteBase inheritance hierarchy that looks like this:

class AbstractBase(AbstractConcreteBase, Base):
    @declared_attr
    def column1(cls): 
        return Column(...)
    
    @declared_attr
    def column2(cls): 
        return Column(...)


class Concrete1(AbstractBase):
    __tablename__ = "concrete1"

    attribute1 = Column(...)

    __mapper_args__ = {
        'polymorphic_identity': 'concrete1',
        'concrete': True
    }

class Concrete2(AbstractBase):
    __tablename__ = "concrete2"

    @hybrid_property
    def attribute1(self):
        return ...

    @attribute1.expression
    def attribute1(cls):
        return ...

    __mapper_args__ = {
        'polymorphic_identity': 'concrete2',
        'concrete': True
    }

Then, if I refer to `attribute1` on an instance if Concrete2, I get an 
AttributeError:

  ...  
  File "/home/charles/PycharmProjects/MyProject/models/setup/model.py", 
line 350, in generate_seasonality
    x = concrete2_instance.attribute1
  File 
"/home/charles/PycharmProjects/Konversion_Platform-Back-End/.env/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py",
 
line 298, in __get__
    return self.descriptor.__get__(instance, owner)
  File 
"/home/charles/PycharmProjects/Konversion_Platform-Back-End/.env/lib/python3.6/site-packages/sqlalchemy/orm/descriptor_props.py",
 
line 512, in __get__
    warn()
  File 
"/home/charles/PycharmProjects/Konversion_Platform-Back-End/.env/lib/python3.6/site-packages/sqlalchemy/orm/descriptor_props.py",
 
line 500, in warn
    (self.parent, self.key, self.parent))
AttributeError: Concrete Mapper|Concrete2|concrete2 does not implement 
attribute 'attribute1' at the instance level.  Add this property explicitly 
to Mapper|Concrete2|concrete2.

I'm running SQLAlchemy 1.2.2. If the problem is indeed the same as in 
https://bitbucket.org/zzzeek/sqlalchemy/issues/4124 , then I believe it was 
supposed to have been fixed in 1.2.0.

Thanks for any help!

-- 
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 post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to