From 51b3d811e180656f7cc3ca75e071ceaef2d5bd46 Mon Sep 17 00:00:00 2001 From: Rafael de Camargo Date: Sun, 25 Aug 2019 01:49:52 -0300 Subject: Changes filters from in array to in subqueries Fixes #3280 --- app/Filter/TaskCommentFilter.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'app/Filter/TaskCommentFilter.php') diff --git a/app/Filter/TaskCommentFilter.php b/app/Filter/TaskCommentFilter.php index 1bb230e9..e5d91117 100644 --- a/app/Filter/TaskCommentFilter.php +++ b/app/Filter/TaskCommentFilter.php @@ -55,13 +55,7 @@ class TaskCommentFilter extends BaseFilter implements FilterInterface */ public function apply() { - $task_ids = $this->getTaskIdsWithGivenComment(); - - if (empty($task_ids)) { - $task_ids = array(-1); - } - - $this->query->in(TaskModel::TABLE.'.id', $task_ids); + $this->query->inSubquery(TaskModel::TABLE.'.id', $this->getSubQuery()); return $this; } @@ -72,11 +66,11 @@ class TaskCommentFilter extends BaseFilter implements FilterInterface * @access public * @return array */ - protected function getTaskIdsWithGivenComment() + protected function getSubQuery() { return $this->db ->table(CommentModel::TABLE) - ->ilike(CommentModel::TABLE.'.comment', '%'.$this->value.'%') - ->findAllByColumn(CommentModel::TABLE.'.task_id'); + ->columns(CommentModel::TABLE.'.task_id') + ->ilike(CommentModel::TABLE.'.comment', '%'.$this->value.'%'); } } -- cgit v1.2.3