Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Erroneous Audit Info Update #127

Merged
merged 3 commits into from
Oct 24, 2024
Merged

Fix Erroneous Audit Info Update #127

merged 3 commits into from
Oct 24, 2024

Conversation

meksor
Copy link
Contributor

@meksor meksor commented Oct 24, 2024

As described by @danielhuppmann, when setting a run as the default, ixmp4 accidentally also updates that info for all other runs with the same model/scenario combination.

This happens because the set_as_default function sets all the other runs to is_default = False before setting True on the singular subject run. The query is adjusted to only update rows which are actually not already is_default = False and I implemented a way to pause the event listeners to avoid setting that field on the previous default run as well.

A repository can now pause the event listeners for a few lines like this:

with self.backend.event_handler.pause():
    # we dont want to trigger the
    # updated_at fields for this operation.
    self.session.execute(exc)
    self.session.commit()

Test is also adjusted to break if any of this ever happens again.

fixes #126

Copy link
Member

@danielhuppmann danielhuppmann left a comment

Choose a reason for hiding this comment

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

This is very elegant! Thanks!

@meksor meksor merged commit 2785183 into main Oct 24, 2024
12 checks passed
@meksor meksor deleted the bugfix/erroneous-audit-info branch October 24, 2024 12:22
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.

Bug when setting the updated_at/by audit info
2 participants