orm: comparison sub-query

This commit is contained in:
Yuri Kuznetsov
2023-03-10 12:03:46 +02:00
parent 3dc239acc5
commit 6edce56ca7
4 changed files with 120 additions and 33 deletions
@@ -2462,6 +2462,7 @@ abstract class BaseQueryComposer implements QueryComposer
return $this->quote(false);
}
// @todo Operators (<s, >s, <=s, =>s) producing 'operator ANY (sub-query)'.
if ($operatorOrm === '=s' || $operatorOrm === '!=s') {
if ($value instanceof Select) {
$subSql = $this->composeSelect($value);
@@ -2494,6 +2495,16 @@ abstract class BaseQueryComposer implements QueryComposer
return "{$leftPart} {$operator} ({$subSql})";
}
if ($value instanceof Select) {
if ($operatorOrm === '*' || $operatorOrm === '!*') {
throw new RuntimeException("LIKE operator is not compatible with sub-query.");
}
$subQueryPart = $this->composeSelect($value);
return "{$leftPart} {$operator} ({$subQueryPart})";
}
if (is_array($value)) {
$valuePartList = $value;