-
Notifications
You must be signed in to change notification settings - Fork 124
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 all 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 | ||
---|---|---|---|---|
@@ -0,0 +1,11 @@ | ||||
# frozen_string_literal: true | ||||
|
||||
module Exceptions | ||||
class DisallowedPolicyOperation < RuntimeError | ||||
|
||||
def initialize | ||||
super("Updating existing resource disallowed in additive policy operation") | ||||
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. Thanks for addressing this. I was thinking it might be useful to provide any meaningful context around the error like how it's done here.
Specifically I had in mind
|
||||
end | ||||
|
||||
end | ||||
end |
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) | ||
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 has boolean parameter 'reject_duplicates' |
||
removed_duplicates_count = eliminate_duplicates_pk | ||
raise Exceptions::DisallowedPolicyOperation 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' |
||
|
||
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.
ApplicationController#disallowed_policy_operation has the parameter name 'e'