Skip to content

Commit b9eed6e

Browse files
feat: Avoid xand composite clause with only one child expression
The extra lazy collection used to wrap its where clause in XAND expressions for every subsequent "getCriteria()", which resulted in a couple of layers of AND calculations, usually only having a single EQUALS comparison. This change only wraps multipe WHERE expressions into an XOR cluase and uses the existing clause "as is" if there's only one condition.
1 parent 7a09d4b commit b9eed6e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Classes/Doctrine/ExtraLazyPersistentCollection.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,13 @@ protected function getCriteria(): Criteria
9191
$cloneData[$getter] = array_filter($cloneData[$getter]);
9292
}
9393

94+
$getWhereExpression = match(count($cloneData['getWhereExpression'])) {
95+
0 => null,
96+
1 => array_shift($cloneData['getWhereExpression']),
97+
default => Criteria::expr()->andX(... $cloneData['getWhereExpression'])
98+
};
9499
return new Criteria(
95-
$cloneData['getWhereExpression']
96-
? Criteria::expr()->andX(... $cloneData['getWhereExpression'])
97-
: null,
100+
$getWhereExpression,
98101
array_shift($cloneData['getOrderings']),
99102
array_shift($cloneData['getFirstResult']),
100103
array_shift($cloneData['getMaxResults'])

0 commit comments

Comments
 (0)