Skip to content

PB-1403: test and refactor the timestamp-updating trigger. - #644

Merged
adk-swisstopo merged 3 commits into
developfrom
PB-1403-refactor
Jun 2, 2026
Merged

PB-1403: test and refactor the timestamp-updating trigger.#644
adk-swisstopo merged 3 commits into
developfrom
PB-1403-refactor

Conversation

@adk-swisstopo

Copy link
Copy Markdown
Member

Updating any field of an Asset triggers an update of its timestamp as stored in the updated field. There is no test for that trigger.

In PB-1403 we want to change this behaviour and for the trigger to become conditional.

This change updates the trigger generator to allow it to be conditional. It also adds tests. There is no actual change in behaviour. A future change will make use of this new parametre.

@adk-swisstopo
adk-swisstopo marked this pull request as ready for review May 29, 2026 11:57
@adk-swisstopo
adk-swisstopo requested a review from benschs May 29, 2026 11:57

@benschs benschs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.
@adk-swisstopo
adk-swisstopo merged commit e9fa4a3 into develop Jun 2, 2026
3 checks passed
@adk-swisstopo
adk-swisstopo deleted the PB-1403-refactor branch June 2, 2026 13:37
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.

2 participants