Skip to content

Commit

Permalink
add extra flatten step to improve "or eq" -> "in" optimization
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Feb 7, 2024
1 parent 3547a4d commit 18b5963
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/private/Files/Search/QueryOptimizer/QueryOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function __construct() {
new PathPrefixOptimizer(),
new MergeDistributiveOperations(),
new FlattenSingleArgumentBinaryOperation(),
new FlattenNestedBool(),
new OrEqualsToIn(),
new FlattenNestedBool(),
new SplitLargeIn(),
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Files/Search/QueryOptimizer/OrEqualsToInTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ public function testOrSomeEq() {
ISearchBinaryOperator::OPERATOR_OR,
[
new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
new SearchComparison(ISearchComparison::COMPARE_LIKE, "path", "foo%"),
new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
new SearchComparison(ISearchComparison::COMPARE_LIKE, "path", "asd%"),
]
);
$this->assertEquals('(path eq "foo" or path eq "bar" or path like "asd%")', $operator->__toString());
$this->assertEquals('(path eq "foo" or path like "foo%" or path eq "bar")', $operator->__toString());

$this->optimizer->processOperator($operator);
$this->simplifier->processOperator($operator);

$this->assertEquals('(path in ["foo","bar"] or path like "asd%")', $operator->__toString());
$this->assertEquals('(path in ["foo","bar"] or path like "foo%")', $operator->__toString());
}

public function testOrsInside() {
Expand Down

0 comments on commit 18b5963

Please sign in to comment.