-
-
Notifications
You must be signed in to change notification settings - Fork 23
Ensure tag name and relationship uniqueness #1124
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
base: main
Are you sure you want to change the base?
Conversation
3cb8685
to
f456f22
Compare
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
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.
LGTM 👍🏼
@sahibamittal Had to rebase this PR to resolve a merge conflict caused by #1126. Please have another look when you get the chance! |
<!-- | ||
Disable deferred constraint checking during this transaction. | ||
Without this, we would not be able to add primary keys after | ||
having deleted records from a table before. | ||
--> | ||
<sql>SET CONSTRAINTS ALL IMMEDIATE</sql> |
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 did a final test run with duplicate records across all tag tables, and the migration ended up failing with:
cannot ALTER TABLE "NOTIFICATIONRULE_TAGS" because it has pending trigger events
This happened when the migration tried to add primary keys. It turns out that, if a table has deferred foreign key constraints, you cannot modify rows and alter the table schema in the same transaction: https://github.com/friek/til/blob/master/postgres/alter-table-pending-triggers.md
The solution is to disable deferred constraints during the transaction, such that foreign keys are checked immediately and cannot block table altering.
a7e1750
to
65734f8
Compare
Signed-off-by: nscuro <[email protected]>
Description
Ensures tag name and relationship uniqueness.
List
s toSet
s. We don't need ordering here, and it only adds overhead.equals
andhashCode
ofTag
to be based onname
, rather thanid
.Addressed Issue
Fixes DependencyTrack/hyades#1755
Additional Details
N/A
Checklist
This PR implements an enhancement, and I have provided tests to verify that it works as intendedThis PR introduces new or alters existing behavior, and I have updated the documentation accordingly