diff --git a/composer.lock b/composer.lock index bc2dcd0a4..3ab0753d4 100644 --- a/composer.lock +++ b/composer.lock @@ -839,16 +839,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.32", + "version": "1.10.35", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44" + "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c47e47d3ab03137c0e121e77c4d2cb58672f6d44", - "reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e730e5facb75ffe09dfb229795e8c01a459f26c3", + "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3", "shasum": "" }, "require": { @@ -897,20 +897,20 @@ "type": "tidelift" } ], - "time": "2023-08-24T21:54:50+00:00" + "time": "2023-09-19T15:27:56+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "version": "9.2.29", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", "shasum": "" }, "require": { @@ -967,7 +967,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" }, "funding": [ { @@ -975,7 +975,7 @@ "type": "github" } ], - "time": "2023-07-26T13:44:30+00:00" + "time": "2023-09-19T04:57:46+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1220,16 +1220,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.11", + "version": "9.6.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", "shasum": "" }, "require": { @@ -1244,7 +1244,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -1303,7 +1303,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13" }, "funding": [ { @@ -1319,7 +1319,7 @@ "type": "tidelift" } ], - "time": "2023-08-19T07:10:56+00:00" + "time": "2023-09-19T05:39:22+00:00" }, { "name": "psr/container", @@ -2608,5 +2608,5 @@ "php": ">=8.0" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index d4e9d9320..8525d2738 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -725,6 +725,10 @@ protected function getFulltextValue(string $value): string $value = preg_replace('/\s+/', ' ', $value); // Remove multiple whitespaces $value = trim($value); + if (empty($value)) { + return ''; + } + if ($exact) { $value = '"' . $value . '"'; } else { diff --git a/tests/Database/Base.php b/tests/Database/Base.php index 738a801f0..26726a0ca 100644 --- a/tests/Database/Base.php +++ b/tests/Database/Base.php @@ -1290,10 +1290,7 @@ public function testFulltextIndexWithInteger(): void static::getDatabase()->createIndex('documents', 'fulltext_integer', Database::INDEX_FULLTEXT, ['string','integer']); } - /** - * @depends testCreateDocument - */ - public function testListDocumentSearch(Document $document): void + public function testListDocumentSearch(): void { $fulltextSupport = $this->getDatabase()->getAdapter()->getSupportForFulltextIndex(); if (!$fulltextSupport) { @@ -1328,6 +1325,30 @@ public function testListDocumentSearch(Document $document): void $this->assertEquals(1, count($documents)); } + public function testEmptySearch(): void + { + $fulltextSupport = $this->getDatabase()->getAdapter()->getSupportForFulltextIndex(); + if (!$fulltextSupport) { + $this->expectNotToPerformAssertions(); + return; + } + + $documents = static::getDatabase()->find('documents', [ + Query::search('string', ''), + ]); + $this->assertEquals(0, count($documents)); + + $documents = static::getDatabase()->find('documents', [ + Query::search('string', '*'), + ]); + $this->assertEquals(0, count($documents)); + + $documents = static::getDatabase()->find('documents', [ + Query::search('string', '<>'), + ]); + $this->assertEquals(0, count($documents)); + } + /** * @depends testGetDocument */