The following script no longer works in 1.0.6, but does in 0.9.9:
from sqlalchemy.ext.declarative import declarative_base, AbstractConcreteBase
from sqlalchemy.ext.declarative.api import declared_attr
from sqlalchemy.orm.mapper import configure_mappers
from sqlalchemy.orm.session import Session
from sqlalchemy.sql.schema import Column, ForeignKey
from sqlalchemy.sql.sqltypes import 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].
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.