diff options
author | Robin Appelman <robin@icewind.nl> | 2024-02-05 18:56:43 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-02-15 17:55:43 +0100 |
commit | 7ca516773f2866b3a6bb2e8cb63b5df95d8da03e (patch) | |
tree | 8b9fa1fa362c542223b51fc218a8e735bb3c9924 /tests/lib/Files | |
parent | 2dcd0a875920be09944dc51f360303c11f3e858a (diff) | |
download | nextcloud-server-7ca516773f2866b3a6bb2e8cb63b5df95d8da03e.tar.gz nextcloud-server-7ca516773f2866b3a6bb2e8cb63b5df95d8da03e.zip |
add a search query step to split IN statements that are to large for oci
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/Files')
-rw-r--r-- | tests/lib/Files/Search/SearchIntegrationTest.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/lib/Files/Search/SearchIntegrationTest.php b/tests/lib/Files/Search/SearchIntegrationTest.php new file mode 100644 index 00000000000..74018a597d9 --- /dev/null +++ b/tests/lib/Files/Search/SearchIntegrationTest.php @@ -0,0 +1,44 @@ +<?php + +namespace Test\Files\Search; + +use OC\Files\Search\SearchBinaryOperator; +use OC\Files\Search\SearchComparison; +use OC\Files\Search\SearchQuery; +use OC\Files\Storage\Temporary; +use OCP\Files\Search\ISearchBinaryOperator; +use OCP\Files\Search\ISearchComparison; +use Test\TestCase; + +/** + * @group DB + */ +class SearchIntegrationTest extends TestCase { + private $cache; + private $storage; + + protected function setUp(): void { + parent::setUp(); + + $this->storage = new Temporary([]); + $this->cache = $this->storage->getCache(); + $this->storage->getScanner()->scan(''); + } + + + public function testThousandAndOneFilters() { + $id = $this->cache->put("file10", ['size' => 1, 'mtime' => 50, 'mimetype' => 'foo/folder']); + + $comparisons = []; + for($i = 1; $i <= 1001; $i++) { + $comparisons[] = new SearchComparison(ISearchComparison::COMPARE_EQUAL, "name", "file$i"); + } + $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, $comparisons); + $query = new SearchQuery($operator, 10, 0, []); + + $results = $this->cache->searchQuery($query); + + $this->assertCount(1, $results); + $this->assertEquals($id, $results[0]->getId()); + } +} |