Skip to content

PB-1403: only update asset timestamp when the underlying file has changed. - #645

Closed
adk-swisstopo wants to merge 3 commits into
developfrom
PB-1403-update2
Closed

PB-1403: only update asset timestamp when the underlying file has changed.#645
adk-swisstopo wants to merge 3 commits into
developfrom
PB-1403-update2

Conversation

@adk-swisstopo

Copy link
Copy Markdown
Member

The updated field of Asset objects is updated when any field is updated. This causes unecessary churn and confusion when hidden metadata are updated.

This change ensures the updated field is only updated when the file, checksum_multihash or file_size field is updated.

This also adds a test to verify the timestamp is not updated when the description is updated.

We have a PostgreSQL trigger that updates the `updated` field of the Asset
objects whenever any field in the object is updated. AFAICT there is no test
covering this.

This change adds a test that verifies that updating the `checksum_multihash`
field of the Asset also updates the `updated` field.

This is in preparation of changes to that trigger.
The `auto_variables_triggers` function is used to generate PostgreSQL triggers
to update some fields automatically. Currently it is triggered when any field
changes. For PB-1403 we want at least one of these triggers to be conditional
on specific fields.

This change replaces the raw-SQL-based `Condition('OLD.* IS DISTINCT FROM NEW.*')`
with `AnyChange(fields)`. This is equivalent as long as `fields` is empty. We
also update `auto_variables_triggers` to take a new optional `fields` argument
(defaulting to empty). This allows callers to define the conditions that apply
for the trigger.

A later change will make use of this new parametre.
The `updated` field of `Asset` objects is updated when any field is updated.
This causes unecessary churn and confusion when hidden metadata are updated.

This change ensures the `updated` field is only updated when the `file`,
`checksum_multihash` or `file_size` field is updated.

This also adds a test to verify the timestamp is not updated when the
description is updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant