Closed
Description
Migrated issue, originally created by Alex Grönholm (@agronholm)
The following code fails with AttributeError: 'NoneType' object has no attribute 'concrete':
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import AbstractConcreteBase, declarative_base
Base = declarative_base()
class Document(Base, AbstractConcreteBase):
doctype = Column(Unicode, nullable=False)
class ContactDocument(Document):
__abstract__ = True
send_method = Column('sendmethod', Unicode)
class ActualDocument(ContactDocument):
__tablename__ = 'actual_documents'
__mapper_args__ = {'concrete': True, 'polymorphic_identity': 'actual'}
id = Column(Integer, primary_key=True)
configure_mappers()
This is caused by the declare_first() in AbstractConcreteBase not checking if the target subclass has a mapper or not. Attached is the patch I was given to remedy the issue.
Attachments: api.diff
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
sqlalchemy-bot commentedon Sep 9, 2014
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Oct 6, 2014
Michael Bayer (@zzzeek) wrote:
when using :class:
.AbstractConcreteBase
in conjunction witha subclass that declares
__abstract__
.fixes More than one level of abstract concrete base classes does not work #3185
→ 5a10b6a
sqlalchemy-bot commentedon Oct 6, 2014
Michael Bayer (@zzzeek) wrote:
when using :class:
.AbstractConcreteBase
in conjunction witha subclass that declares
__abstract__
.fixes More than one level of abstract concrete base classes does not work #3185
Conflicts:
test/ext/declarative/test_inheritance.py
→ 24cd39d
sqlalchemy-bot commentedon Oct 6, 2014
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Apr 24, 2015
Anatoly Bubenkov (@bubenkoff) wrote:
@zzzeek did it broke the former functionality of AbstractConcreteBase?
this fails with now:
and declared_attr now receives BaseLock class in cls instead of concrete class
sqlalchemy-bot commentedon Apr 24, 2015
Michael Bayer (@zzzeek) wrote:
@bubenkov - can you please provide a complete test case? at the moment it seems you are just hitting the same thing as #3383.