Skip to content

Commit

Permalink
Merge pull request #16950 from tumido/miq_requests_scopes2
Browse files Browse the repository at this point in the history
Fix reason scope for MiqRequest
  • Loading branch information
martinpovolny authored Feb 13, 2018
2 parents 8aea84d + 30b7576 commit 7c91f6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/miq_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def self.class_from_request_data(data)
def self.with_reason_like(reason)
# Reason string uses * wildcard, scope is required to convert it into % wildcard for LIKE statement
reason = reason.match(/\A(?<start>\*?)(?<content>.*?)(?<end>\*?)\z/)
where("reason LIKE (?)", "#{reason[:start] ? '%' : ''}#{sanitize_sql_like(reason[:content])}#{reason[:end] ? '%' : ''}")
joins(:miq_approvals).where("miq_approvals.reason LIKE (?)", "#{reason[:start] ? '%' : ''}#{sanitize_sql_like(reason[:content])}#{reason[:end] ? '%' : ''}")
end

# Supports old-style requests where specific request was a seperate table connected as a resource
Expand Down

0 comments on commit 7c91f6e

Please sign in to comment.