Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Database/Validator/IndexedQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ public function isValid($value): bool
$filters = $grouped['filters'];

foreach ($filters as $filter) {
if ($filter->getMethod() === Query::TYPE_SEARCH) {
if (
$filter->getMethod() === Query::TYPE_SEARCH ||
$filter->getMethod() === Query::TYPE_NOT_SEARCH
) {
Comment on lines +94 to +97
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Add/verify tests for NOT_SEARCH requiring FTS

Please ensure we have coverage that fails validation when using notSearch without a fulltext index and passes when the index exists.

Run this to check for existing tests; I can help add them if missing:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Look for notSearch usage in tests and any assertion on the FTS requirement
rg -n -S "TYPE_NOT_SEARCH|notSearch"
rg -n -S "requires a fulltext index"

Length of output: 4482


Add tests for notSearch requiring fulltext index
We need to cover the new Query::TYPE_NOT_SEARCH path in the fulltext‐index validator to ensure it fails when no FTS index exists and passes when one does.

Please add test cases in:

  • tests/unit/Validator/IndexedQueriesTest.php
    • A test that $validator->isValid(Query::notSearch('name', 'foo')) returns false and $validator->getDescription() equals
      "Searching by attribute \"name\" requires a fulltext index." when no fulltext index is defined.
    • A test that the same query returns true when the mock index list includes a fulltext index on “name.”

(Optional) Extend your end-to-end suite as well:

  • tests/e2e/Adapter/Scopes/GeneralTests.php – cover notSearch against a table without and with an FTS index.

Sample snippet for IndexedQueriesTest.php:

public function testNotSearchRequiresFulltextIndex(): void
{
    $validator = new IndexedQueries(['description'], []); // no fulltext index on 'name'
    $filter    = Query::notSearch('name', 'foo');

    $this->assertFalse($validator->isValid($filter));
    $this->assertEquals(
        'Searching by attribute "name" requires a fulltext index.',
        $validator->getDescription()
    );

    // Now allow fulltext on 'name'
    $validatorWithFTS = new IndexedQueries(['description'], ['name']);
    $this->assertTrue($validatorWithFTS->isValid($filter));
}
🤖 Prompt for AI Agents
In src/Database/Validator/IndexedQueries.php around lines 94-97 the branch
handling Query::TYPE_NOT_SEARCH was added but lacks unit coverage; add tests in
tests/unit/Validator/IndexedQueriesTest.php that create an IndexedQueries
instance without a fulltext index for 'name', assert
$validator->isValid(Query::notSearch('name','foo')) returns false and
$validator->getDescription() equals "Searching by attribute \"name\" requires a
fulltext index.", then create a second IndexedQueries instance that includes
'name' in the FTS list and assert isValid returns true; optionally add
corresponding e2e cases in tests/e2e/Adapter/Scopes/GeneralTests.php to exercise
notSearch against a table without and with an FTS index.

$matched = false;

foreach ($this->indexes as $index) {
Expand Down