Thanks for reporting. Issue
https://bitbucket.org/zzzeek/sqlalchemy/issues/3480/abstractconcretebase-regression-with
is created, create the Column objects with an explicit key for now:
class Document(object):
date = Column(Date)
documentType = Column('documenttype', String, key="documentType")
class ContactDocument(AbstractConcreteBase, Base, Document):
contactPersonName = Column('contactpersonname', String,
key="contactPersonName")
salesPersonName = Column(String)
sendMethod = Column('sendmethod', String, key="sendMethod")
@declared_attr
def company_id(self):
return Column(ForeignKey('companies.id'))
On 7/9/15 11:18 AM, Alex Grönholm wrote:
The following script no longer works in 1.0.6, but does in 0.9.9:
from sqlalchemy.ext.declarativeimport declarative_base, AbstractConcreteBase
from sqlalchemy.ext.declarative.apiimport declared_attr
from sqlalchemy.orm.mapperimport configure_mappers
from sqlalchemy.orm.sessionimport Session
from sqlalchemy.sql.schemaimport Column, ForeignKey
from sqlalchemy.sql.sqltypesimport Date, String, Integer
Base = declarative_base()
class Company(Base):
__tablename__ ='companies' id = Column(Integer,primary_key=True)
class Document(object):
date = Column(Date)
documentType = Column('documenttype', String)
class ContactDocument(AbstractConcreteBase, Base, Document):
contactPersonName = Column('contactpersonname', String)
salesPersonName = Column(String)
sendMethod = Column('sendmethod', String)
@declared_attr def company_id(self):
return Column(ForeignKey('companies.id'))
class Offer(ContactDocument):
__tablename__ ='offers' id = Column(Integer,primary_key=True)
class SalesOrder(ContactDocument):
__tablename__ ='orders' id = Column(Integer,primary_key=True)
configure_mappers()
session = Session()
query = session.query(ContactDocument)
print(query)
On 1.0.6, I get an error: sqlalchemy.exc.ArgumentError: When
configuring property 'documentType' on Mapper|ContactDocument|pjoin,
column 'documenttype' is not represented in the mapper's table. Use
the `column_property()` function to force this column to be mapped as
a read-only attribute.
Why am I getting this? Is this a bug or am I not understanding something?
Also, is it possible to have both Document and ContactDocument as
abstract concrete base classes (ie. I want the union from Document to
include both the direct concrete subclasses of Document and all
concrete subclasses of ContactDocument as well)?
--
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 [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.