-
Notifications
You must be signed in to change notification settings - Fork 898
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
Adding helper for unique index columns to inventory collection #15141
Adding helper for unique index columns to inventory collection #15141
Conversation
@miq-bot add_label enhancement |
This pull request is not mergeable. Please rebase and repush. |
Helper for getting unique_index_columns of IC table from a DB, asking for explicit definition if there is more than 1 index and asking for adding unique index if there is none.
2ec34e6
to
1b68262
Compare
@@ -280,13 +280,16 @@ class InventoryCollection | |||
# inventory_object[:label] = inventory_object[:name] | |||
# So by using inventory_object_attributes, we will be guarding the allowed attributes and will have an | |||
# explicit list of allowed attributes, that can be used also for documentation purposes. | |||
# @param unique_index_columns [Array] Array of symbols identifying a columns of a DB unique index we will be using. |
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.
identifying a columns
just need identifying columns of a DB ...
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.
done
def unique_index_columns | ||
return @unique_index_columns if @unique_index_columns | ||
|
||
unique_indexes = model_class.connection.indexes(model_class.table_name).select { |x| x.unique } |
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.
could you do select(&:unique)
?
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.
done
Two small things the rest looks good |
Fix rubocop and grammar issues
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.
👍 will merge when green
Checked commits Ladas/manageiq@1b68262~...b0dbd9e with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Depends on:
Helper for getting unique_index_columns of IC table from a DB,
asking for explicit definition if there is more than 1
index and asking for adding unique index if there is none.