Thanks. What about my other question? Is it possible to have two layers of 
classes (Document and ContactDocument) mapped to polymorphic unions?

torstai 9. heinäkuuta 2015 18.31.36 UTC+3 Michael Bayer kirjoitti:
>
>  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.declarative import declarative_base, 
> AbstractConcreteBasefrom sqlalchemy.ext.declarative.api import 
> declared_attrfrom sqlalchemy.orm.mapper import configure_mappersfrom 
> sqlalchemy.orm.session import Sessionfrom sqlalchemy.sql.schema import 
> Column, ForeignKeyfrom 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 sqlalchemy+...@googlegroups.com <javascript:>.
> To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>.
> 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to