I'm getting a messy error that could be a bug, but is very likely
related to my setup of a set of 2 polymorphic classes I am attempting
to map.

One entity is a "transaction" and the other is a "transaction_archive"
record.  The table structure is therefore very similar for both tables
and it seems to fit Concrete Table Inheritance, except there is no
'parent' entity.  Rather, they are sister tables.

What I have mostly works until I get into loading this union as a
relation to another table... then I'm having problems.

I couldn't clearly see the "correct" way to set up this when there is
no real inheritance, but rather sister entities.

Can you suggest how to correctly map these 2 tables?

================================================
artran_union = polymorphic_union({
        'artran': artrans_table,
        'archive': artransarchive_table
    }, 'type', 'artran_union')

artranbase_mapper = mapper(ArTranBase, artran_union,
with_polymorphic=('*', artran_union),
    polymorphic_on=artran_union.c.type,
polymorphic_identity='ignored')


# ---------------------------- ArTran
--------------------------------------- #
mapper(ArTran, artrans_table, inherits=artranbase_mapper,
    concrete=True, polymorphic_identity='artran',
    properties={'trancode': relation(TranCode,
                    cascade='refresh-expire,expunge', lazy=False),
                'paymenttype': relation(PaymentType,
                    cascade='refresh-expire,expunge', lazy=False)}
    )


# ---------------------------- ArTranArchive
--------------------------------------- #
mapper(ArTranArchive, artransarchive_table,
inherits=artranbase_mapper,
    concrete=True, polymorphic_identity='archive',
    properties={'trancode': relation(TranCode,
                    cascade='refresh-expire,expunge', lazy=False),
                'paymenttype': relation(PaymentType,
                    cascade='refresh-expire,expunge', lazy=False)}
    )

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to