PB-1403: test and refactor the timestamp-updating trigger. - #644
Merged
Conversation
adk-swisstopo
marked this pull request as ready for review
May 29, 2026 11:57
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
force-pushed
the
PB-1403-refactor
branch
from
June 2, 2026 06:48
a61994a to
02f63bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updating any field of an Asset triggers an update of its timestamp as stored in the
updatedfield. 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.