Skip to content

Commit

Permalink
Merge pull request ManageIQ#5503 from bmclaughlin/fix-expression-edit…
Browse files Browse the repository at this point in the history
…or-error

Use numeric comparison for IDs
  • Loading branch information
h-kataria authored Apr 29, 2019
2 parents 4c79865 + 4f7acd4 commit 85fa7e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/application_controller/filter/expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ def update_from_expression_editor(params)
self.exp_key = nil
else
# for date time fields we should show After/Before etc. options
chosen_field_col_type = MiqExpression.get_col_type(params[:chosen_field])
if exp_model != '_display_filter_' &&
MiqExpression::Field.parse(exp_field).plural? &&
!%i[date datetime].include?(MiqExpression.get_col_type(params[:chosen_field]))
!%i[date datetime].include?(chosen_field_col_type) &&
chosen_field_col_type.object_id != :integer.object_id
self.exp_key = 'CONTAINS' # CONTAINS is valid only for plural tables
else
self.exp_key = nil unless MiqExpression.get_col_operators(exp_field).include?(exp_key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
expect(controller).to receive(:render)
controller.send(:exp_changed)
expect(expression.exp_key).to eq('IS')
controller.instance_variable_set(:@expkey, :record_filter)
controller.instance_variable_set(:@_params, :chosen_field => "Flavor.cloud_tenants-id")
expect(controller).to receive(:render)
controller.send(:exp_changed)
expect(expression.exp_key).to_not eq('CONTAINS')
expect(expression.exp_key).to eq('=')
end
end
end
Expand Down

0 comments on commit 85fa7e5

Please sign in to comment.