From 5ef20533b2226fbdcfbf7a61d57372b5379b021a Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Sat, 14 Jan 2023 02:22:14 +0000 Subject: [PATCH] - Fixed a bug with the IN query --- src/Query/Where.php | 4 ++-- src/Repository/ConditionTrait.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Query/Where.php b/src/Query/Where.php index 4159ea2..11d9e58 100644 --- a/src/Query/Where.php +++ b/src/Query/Where.php @@ -110,11 +110,11 @@ class Where extends Fragment { protected function operator() : string { if ( is_array($this->value) ) { - return (in_array($this->operator, [ '!=', '<>' ]) ? Where::CONDITION_NOT . " " : "") . Where::COMPARISON_IN; + return Where::COMPARISON_IN; } # whitelisting operators - return in_array(strtoupper($this->operator), [ '=', '!=', '>', '>=', '<', '<=', '<>', 'LIKE', 'IS', 'IS NOT', 'REGEXP' ]) ? $this->operator : "="; + return in_array(strtoupper($this->operator), [ '=', '!=', '>', '>=', '<', '<=', '<>', 'LIKE', 'IS', 'IS NOT', 'REGEXP', 'IN' ]) ? $this->operator : "="; } protected function value() diff --git a/src/Repository/ConditionTrait.php b/src/Repository/ConditionTrait.php index 89447df..38366c0 100644 --- a/src/Repository/ConditionTrait.php +++ b/src/Repository/ConditionTrait.php @@ -95,14 +95,14 @@ trait ConditionTrait return $this; } - public function in($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self + public function in($field, $value, string $operator = Query\Where::COMPARISON_IN) : self { $this->queryBuilder->where($field, $value, $operator); return $this; } - public function orIn($field, $value, string $operator = Query\Where::OPERATOR_EQUAL) : self + public function orIn($field, $value, string $operator = Query\Where::COMPARISON_IN) : self { $this->queryBuilder->where($field, $value, $operator, Query\Where::CONDITION_OR); @@ -111,14 +111,14 @@ trait ConditionTrait public function notIn($field, $value) : self { - $this->queryBuilder->where($field, $value, Query\Where::OPERATOR_NOT_EQUAL); + $this->queryBuilder->where($field, $value, Query\Where::COMPARISON_IN, true); return $this; } public function orNotIn($field, $value) : self { - return $this->orNot($field, $value, Query\Where::OPERATOR_NOT_EQUAL, Query\Where::CONDITION_OR, true); + return $this->orNot($field, $value, Query\Where::COMPARISON_IN, Query\Where::CONDITION_OR, true); } public function like($field, $value) : self