-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
MBS-13564: Correctly override primary on alias locale change #3398
Conversation
Attempting to change the locale of an alias marked as primary to one which already had a primary alias crashed with an ISE. I noticed the issue is that we were not clearing the previous primary value first for this case, since we were only looking for a changed primary_for_locale. In this case the locale changes, not the primary flag. This ensures primary is cleared upon either primary or locale changes if primary is being set or if it was already set and was not overriden by the row changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit does what it says it does, but there seems to be an issue with silently clearing the primary flag.
@mwiencek wrote in description of the related MBS-11896:
Avoiding duplicate primary locales can be handled by the application (and already is). If it wasn't, it even seems better to have the application fail with a unique index violation (since that indicates it's not accounting the changes properly) than silently change the data.
So it seems that the ISE is still the best to have until we make such data change visible in the editing process.
I didn’t check the tests for now but thank you still as it is always some amount of work.
I think this is what was meant by "can be handled by the application (and already is)." In every other case, we already do this with the primary flag, this just fixes one edge case where it crashed. |
Yes, I think I meant being changed silently by a database trigger (which is hard to debug unless you already know the trigger exists) vs. being changed by SQL queries in the application (so all the update logic is in one place).
That is a good point, it'd be nice to indicate in the edit display data when any existing primary alias is being overridden. But we should fix this ISE, since we already unset the old primary alias when setting a new one, and this is just a special case of that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally and it fixes the ISE for me (was trivial to reproduce). I opened MBS-13898 for the edit display improvement. Test changes look nice too.
Fix MBS-13564
Problem
Attempting to change the locale of an alias marked as primary to one which already has a primary alias crashes with an ISE.
Solution
I noticed the issue is that we were not clearing the previous primary value first for this case, since we were only looking for a changed
primary_for_locale
. In this case thelocale
changes, not theprimary_for_locale
flag. This change ensuresprimary_for_locale
is cleared upon eitherprimary_for_locale
orlocale
changes ifprimary_for_locale
is being set or if it was already set and was not overriden by the row changes.Testing
Manually, plus I added a test to Data::Alias. I'm also making Data::Alias less of a mess in a subsequent commit.