diff options
author | Robin Appelman <robin@icewind.nl> | 2023-09-21 13:49:16 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-02-15 17:55:40 +0100 |
commit | 2e14a7a4a6efb5444fb65e0c2368e3420d024d90 (patch) | |
tree | 6f68533daa5fb6ef10261bdc0034e7de910378b5 /lib/private/Files/Search/SearchBinaryOperator.php | |
parent | 1f0cba5f991a3c12d230284b3d96f91fb50312fd (diff) | |
download | nextcloud-server-2e14a7a4a6efb5444fb65e0c2368e3420d024d90.tar.gz nextcloud-server-2e14a7a4a6efb5444fb65e0c2368e3420d024d90.zip |
optimize query pattern used by storage filter
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Search/SearchBinaryOperator.php')
-rw-r--r-- | lib/private/Files/Search/SearchBinaryOperator.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/private/Files/Search/SearchBinaryOperator.php b/lib/private/Files/Search/SearchBinaryOperator.php index d7bba8f1b4e..2b01ad58e5f 100644 --- a/lib/private/Files/Search/SearchBinaryOperator.php +++ b/lib/private/Files/Search/SearchBinaryOperator.php @@ -28,7 +28,7 @@ use OCP\Files\Search\ISearchOperator; class SearchBinaryOperator implements ISearchBinaryOperator { /** @var string */ private $type; - /** @var ISearchOperator[] */ + /** @var (SearchBinaryOperator|SearchComparison)[] */ private $arguments; private $hints = []; @@ -36,7 +36,7 @@ class SearchBinaryOperator implements ISearchBinaryOperator { * SearchBinaryOperator constructor. * * @param string $type - * @param ISearchOperator[] $arguments + * @param (SearchBinaryOperator|SearchComparison)[] $arguments */ public function __construct($type, array $arguments) { $this->type = $type; @@ -57,6 +57,14 @@ class SearchBinaryOperator implements ISearchBinaryOperator { return $this->arguments; } + /** + * @param ISearchOperator[] $arguments + * @return void + */ + public function setArguments(array $arguments): void { + $this->arguments = $arguments; + } + public function getQueryHint(string $name, $default) { return $this->hints[$name] ?? $default; } @@ -64,4 +72,11 @@ class SearchBinaryOperator implements ISearchBinaryOperator { public function setQueryHint(string $name, $value): void { $this->hints[$name] = $value; } + + public function __toString(): string { + if ($this->type === ISearchBinaryOperator::OPERATOR_NOT) { + return '(not ' . $this->arguments[0] . ')'; + } + return '(' . implode(' ' . $this->type . ' ', $this->arguments) . ')'; + } } |