From 30b75768f5862f04131a2ef8c3808901e68ed083 Mon Sep 17 00:00:00 2001 From: Tomas Coufal Date: Mon, 5 Feb 2018 16:34:21 +0100 Subject: [PATCH] Fix reason scope for MiqRequest --- app/models/miq_request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/miq_request.rb b/app/models/miq_request.rb index 30e24b09928..597648f5587 100644 --- a/app/models/miq_request.rb +++ b/app/models/miq_request.rb @@ -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(?\*?)(?.*?)(?\*?)\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