-
Notifications
You must be signed in to change notification settings - Fork 123
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
Spike: adding/updating annotations via PUT/POST/PATCH #2888
Changes from 4 commits
7f2be27
c50cdea
36c8dbe
9141a2d
b1028a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -120,8 +120,9 @@ def delete_shadowed_and_duplicate_rows | |||
end | ||||
|
||||
# TODO: consider renaming this method | ||||
def store_policy_in_db | ||||
eliminate_duplicates_pk | ||||
def store_policy_in_db(reject_duplicates: false) | ||||
removed_duplicates_count = eliminate_duplicates_pk | ||||
raise ApplicationController::BadRequest, "Updating existing resource disallowed in additive policy operation" if removed_duplicates_count.positive? && reject_duplicates | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Loader::Orchestrate#store_policy_in_db is controlled by argument 'reject_duplicates' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to raise a local exception to avoid coupling the loader to the somewhat global
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created |
||||
|
||||
insert_new | ||||
|
||||
|
@@ -243,8 +244,9 @@ def eliminate_duplicates_exact | |||
end | ||||
|
||||
# Delete rows from the new policy which have the same primary keys as existing rows. | ||||
# Returns the total number of deleted rows. | ||||
def eliminate_duplicates_pk | ||||
TABLES.each do |table| | ||||
TABLES.sum do |table| | ||||
eliminate_duplicates(table, Array(model_for_table(table).primary_key) + [ :policy_id ]) | ||||
end | ||||
end | ||||
|
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.
Loader::Orchestrate#store_policy_in_db has boolean parameter 'reject_duplicates'