I'm updating "sqlalchemy_django_query" for SQLAlchemy 1.4 and aside of that 
I found a peculiar problem - when I call get_mapper on  a table 
(AnnotatedTable) I get a ValueError due to multiple mappers found.

The model is inherited by two other models and get_mapper finds mappers for 
all 3 models due to this:


class Conversation(db.Base):
    __tablename__ = 'conversation'
    id = sqlalchemy.Column(postgres_dialect.UUID(as_uuid=True), 
primary_key=True, default=uuid.uuid4)
    ...
    type = sqlalchemy.Column(sqlalchemy.Text, nullable=False)

    __mapper_args__ = {
        'polymorphic_identity': 'conversation',
        'polymorphic_on': type,
    }


...


class ContactFormConversation(Conversation):
    __tablename__ = 'contact_form_conversation'
    id = sqlalchemy.Column(sqlalchemy.ForeignKey('conversation.id'), 
primary_key=True, nullable=False)
    ...

    __mapper_args__ = {
        'polymorphic_identity': 'contact_form_conversation',
    }


...


class RatingConversation(Conversation):
    __tablename__ = 'rating_conversation'
    id = sqlalchemy.Column(sqlalchemy.ForeignKey('conversation.id'), 
primary_key=True, nullable=False)
    ...

    __mapper_args__ = {
        'polymorphic_identity': 'rating_conversation',
    }


Should the model structure be done differently? 

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/8a86ddb1-329c-41d2-9f23-0147f8c68316n%40googlegroups.com.

Reply via email to