"version" is only on your Container table since it will always have a row 
corresponding to each Box row, so "box.version" is not necessary.  You can 
change this by changing:

    if not super_history_mapper:
        cls.version = Column('version', Integer, default=1, nullable=False)

to:

        cls.version = Column('version', Integer, default=1, nullable=False)

then ensuring that Box.version is also written on update.





On Aug 31, 2011, at 10:28 AM, JPLaverdure wrote:

> I just realised the following issue:
> 
> When I create the following relationship:
> 
> class Container(Base):
>     __metaclass__ = VersionedMeta
>     __tablename__ = 'container'
>     __table_args__ = {'schema':'storage'}
> 
>     id = Column(Integer, primary_key=True)
>     discriminator = Column('type', String(64))
>     token = Column(String(128), nullable=False)
>     description = Column(String)
>     
>     __mapper_args__ = {'polymorphic_on': discriminator, 
> 'polymorphic_identity':'container'}
> 
> class Box(Container):
>     __metaclass__ = VersionedMeta
>     __tablename__ = 'box'
>     __table_args__ = {'schema':'storage'}
>     __mapper_args__ = {'polymorphic_identity': 'box'}
>     
>     id = Column(Integer, ForeignKey('storage.container.id', 
> onupdate="cascade", ondelete="cascade"), primary_key=True)
>     barcode = Column(String(64))
> 
> Even though box_history gets created, no "version" column is added to the box 
> table and any modification to a Box entity does not log the change in the 
> _history table.
> Could anyone please point out what I'm doing wrong ?
> 
> I tried removing the metaclass declaration from the Box entity since it would 
> basically inherit it from Container but that didn't help in solving my issue.
> 
> Thank you !!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/sqlalchemy/-/PK3kVAsuh5QJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

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

Reply via email to