|
|
@@ -687,36 +687,40 @@ class QueryExpression implements ExpressionInterface, Countable
|
|
|
foreach ($conditions as $k => $c) {
|
|
|
$numericKey = is_numeric($k);
|
|
|
|
|
|
- if ($numericKey && empty($c)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
if ($this->isCallable($c)) {
|
|
|
$expr = new static([], $typeMap);
|
|
|
$c = $c($expr, $this);
|
|
|
}
|
|
|
|
|
|
- if ($numericKey && is_string($c)) {
|
|
|
- $this->_conditions[] = $c;
|
|
|
+ if ($numericKey && empty($c)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if ($numericKey && is_array($c) || in_array(strtolower($k), $operators)) {
|
|
|
- $this->_conditions[] = new static($c, $typeMap, $numericKey ? 'AND' : $k);
|
|
|
+ $isArray = is_array($c);
|
|
|
+ $isOperator = in_array(strtolower($k), $operators);
|
|
|
+ $isNot = strtolower($k) === 'not';
|
|
|
+
|
|
|
+ if (($isOperator || $isNot) && ($isArray || $c instanceof Countable) && count($c) === 0) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (strtolower($k) === 'not') {
|
|
|
- $this->_conditions[] = new UnaryExpression('NOT', new static($c, $typeMap));
|
|
|
+ if ($numericKey && $c instanceof ExpressionInterface) {
|
|
|
+ $this->_conditions[] = $c;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if ($c instanceof self && count($c) === 0) {
|
|
|
+ if ($numericKey && is_string($c)) {
|
|
|
+ $this->_conditions[] = $c;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if ($numericKey && $c instanceof ExpressionInterface) {
|
|
|
- $this->_conditions[] = $c;
|
|
|
+ if ($numericKey && $isArray || $isOperator) {
|
|
|
+ $this->_conditions[] = new static($c, $typeMap, $numericKey ? 'AND' : $k);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($isNot) {
|
|
|
+ $this->_conditions[] = new UnaryExpression('NOT', new static($c, $typeMap));
|
|
|
continue;
|
|
|
}
|
|
|
|