Skip to content

Column onupdate clause erroneously copied to history table #47

Closed

Description

@karih

If I have a datetime (or any other column type) column in a table with onupdate= and include this in the history table, the onupdate clause gets erroneously (I'd argue) "copied" to the history table.

Example:

class Article(Base):
    __versioned__ = {'include' : ['last_update', ]}

    id = sa.Column(sa.Integer, primary_key=True)
    body = sa.Column(sa.UnicodeText)
    last_update = sa.Column(sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False)

The articles table behaves correctly, in that the last_update column is updated each time a record is changed. However, the _history table, due to the update of end_transaction_id (I presume) fails to preserve the value of the column, so the second latest row effectively has the last_update value of the most recent update.

Thanks for an otherwise wonderful extension!

Activity

  1. kvesteri commented on Feb 27, 2014

    @kvesteri
    Collaborator

    Hi, could you make a simple test case for this one which outlines the expected behaviour?

  2. kvesteri commented on Feb 27, 2014

    @kvesteri
    Collaborator

    Don't worry about the test case, made it already there. Fixed as of 0.10.3.

  3. karih commented on Feb 27, 2014

    @karih
    ContributorAuthor

    That was fast, thanks!

  4. added a commit that references this issue on Mar 1, 2014
    47b4f48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions