-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
AIP-84 Refactor Handling of Insert Duplicates #44322
AIP-84 Refactor Handling of Insert Duplicates #44322
Conversation
In summary, this PR will only add
I will still explore the regex or string-matching approach in a follow-up PR. |
da86894
to
e7c68b3
Compare
Hi @pierrejeambrun, @ephraimbuddy, I’ve refactored the I’ve also added tests for the unique constraint handler, covering the following cases:
Looking forward to your feedback and suggestions! |
1498fc1
to
99de599
Compare
Rebase to latest main, looking forward to feedback. |
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.
I think there are a lot of hardcoded values, regexp and manual string manipulation etc.
This code will likely break when the db version update the message or when a column name / values contains special character that we did not account for. The parsing could still fail.
Also that's a lot of code to maintain, and it's not super welcoming.
I'm not in favour of this change.
I still think that at first just returning the plain orig
and statement
is enough for a user to understand. And for tests we just assert that those keys are present in the response.
Yup, I agree, it looks too brittle unfortunately. |
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.
Thanks for the effort @jason810496 in having these error messages parsed.
I don't think that's the best approach and I wouldn't invest more time trying to make this more reliable because it's very unlikely we do.
The best we can do at this point is to return the plain orig
and maybe also statement
in the response details. This will enable power users to actually understand why the resquest is conflicting. (parameters
fields should not be exposed in the response)
99de599
to
2880fe0
Compare
Thank you for the feedback, @pierrejeambrun and @kaxil! Just refactored the implementation to include only the |
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.
Thanks
* Refactor PostConnection handling insert duplicate * Add parsing error detail to error handler with test * Add parsing multiple columns case in unique constraint * Add multiple columns, parsing error cases in test * Fix public API already existed test cases * Refactor: remove parsing, return statement and orig * Refactor test_exceptions with statement and orign * Fix unique constriant violation response in api test
* Refactor PostConnection handling insert duplicate * Add parsing error detail to error handler with test * Add parsing multiple columns case in unique constraint * Add multiple columns, parsing error cases in test * Fix public API already existed test cases * Refactor: remove parsing, return statement and orig * Refactor test_exceptions with statement and orign * Fix unique constriant violation response in api test
related: #44121 (comment)
It seems that only the Post Connection endpoint has an extra query to handle duplicate entries. Other
409_CONFLICT
cases don't handle inserting duplicate entries on unique constraint columns.