[Sqlalchemy-tickets] Issue #4326: Inherited declared_attr hybrid_property looses extension_type (zz
Brought to you by:
zzzeek
From: Dmytro S. <iss...@bi...> - 2018-08-23 11:17:37
|
New issue 4326: Inherited declared_attr hybrid_property looses extension_type https://bitbucket.org/zzzeek/sqlalchemy/issues/4326/inherited-declared_attr-hybrid_property Dmytro Starosud: This is using sqlalchemy 1.2.11. Please consider following code snippet. ``` #!python from sqlalchemy import inspect, Column, String from sqlalchemy.ext.declarative import declarative_base, declared_attr from sqlalchemy.ext.hybrid import hybrid_property class Mixin: @hybrid_property def hp1(cls): return 42 @declared_attr def hp2(cls): @hybrid_property def hp2(self): return 42 return hp2 class Base(declarative_base(), Mixin): __tablename__ = 'test' id = Column(String, primary_key=True) class Derived(Base): pass print(inspect(Base).mapper.all_orm_descriptors['hp1'].extension_type) print(inspect(Base).mapper.all_orm_descriptors['hp2'].extension_type) print(inspect(Derived).mapper.all_orm_descriptors['hp1'].extension_type) print(inspect(Derived).mapper.all_orm_descriptors['hp2'].extension_type) # prints # symbol('HYBRID_PROPERTY') # symbol('HYBRID_PROPERTY') # symbol('HYBRID_PROPERTY') # symbol('NOT_EXTENSION') ``` Should I use another way to determine type of orm descriptor? Thanks a lot in advance! |