single table inheritance and primary key problem

Issue #1478 resolved
Former user created an issue

With such scheme:

exportables = sa.Table(
    't_exportable', meta,
    sa.Column('object_id', OracleNumber, primary_key=True),
    sa.Column('type', sa.String(20), primary_key=True),
    sa.Column('state', sa.Integer),
)

and class hierarchy:

class Exportable(Base):
    __table__ = exportables

    __mapper_args__ = {
        'polymorphic_on': exportables.c.type,
    }

class ExportableTEST(Exportable):
    __mapper_args__ = {
        'polymorphic_identity': 'TEST',
    }

When updating attributes of ExportableTEST object error "''ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1''" acquired. Because of primary key is not passed to update query:

''INFO:sqlalchemy.engine.base.Engine.0x...fdac:UPDATE t_exportable SET state=:state WHERE t_exportable.opcode = :t_exportable_opcode AND t_exportable.object_id = :t_exportable_object_id AND t_exportable.type = :t_exportable_type
INFO:sqlalchemy.engine.base.Engine.0x...fdac:{'t_exportable_object_id': Decimal("8756"), 'state': 3, 't_exportable_type': None, 't_exportable_opcode': 18}''

Comments (5)

  1. Mike Bayer repo owner

    can you please attach a full test case to this one and ensure its against trunk ? this test doesn't fully show what you're doing. thanks.

  2. Log in to comment