Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/action_set/filter_instructions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def klass_for_keypath(keypath, value, set)
if @controller.respond_to?(:filter_set_types, true)
type_declarations = @controller.public_send(:filter_set_types)
types = type_declarations['types'] || type_declarations[:types]
klass = types[keypath.join('.')]
klass = types.fetch(keypath.join('.'), nil)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DuplicateMethodCall: ActionSet::FilterInstructions#klass_for_keypath calls 'keypath.join('.')' 2 times. More info.

return klass if klass
end

if set.is_a?(ActiveRecord::Relation) || set.view.is_a?(ActiveRecord::Relation)
klass_type = set.model.columns_hash.fetch(keypath, nil)&.type
klass_type = set.model.columns_hash.fetch(keypath.join('.'), nil)&.type
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NilCheck: ActionSet::FilterInstructions#klass_for_keypath performs a nil-check. More info.

return klass_type.class if klass_type
end

Expand Down