From 581c638517ccae46eeeffee59fe695c4469dc60d Mon Sep 17 00:00:00 2001 From: orpheusohms Date: Tue, 25 Nov 2025 21:01:57 +0100 Subject: [PATCH 1/2] add support no mode in postgres full text search --- src/Illuminate/Database/Query/Grammars/PostgresGrammar.php | 4 ++++ tests/Database/DatabaseQueryBuilderTest.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php index 3a2a7b425f3c..f45ea7add671 100755 --- a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php +++ b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php @@ -181,6 +181,10 @@ public function whereFullText(Builder $query, $where) $mode = 'websearch_to_tsquery'; } + if (($where['options']['mode'] ?? []) === 'none') { + $mode = 'to_tsquery'; + } + return "({$columns}) @@ {$mode}('{$language}', {$this->parameter($where['value'])})"; } diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index 53629cdff191..b85404708e3e 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -1557,6 +1557,11 @@ public function testWhereFulltextPostgres() $builder->select('*')->from('users')->whereFullText(['body', 'title'], 'Car Plane'); $this->assertSame('select * from "users" where (to_tsvector(\'english\', "body") || to_tsvector(\'english\', "title")) @@ plainto_tsquery(\'english\', ?)', $builder->toSql()); $this->assertEquals(['Car Plane'], $builder->getBindings()); + + $builder = $this->getPostgresBuilderWithProcessor(); + $builder->select('*')->from('users')->whereFullText(['body', 'title'], 'Air | Plan:* -Car', ['mode' => 'none']); + $this->assertSame('select * from "users" where (to_tsvector(\'english\', "body") || to_tsvector(\'english\', "title")) @@ to_tsquery(\'english\', ?)', $builder->toSql()); + $this->assertEquals(['Air | Plan:* -Car'], $builder->getBindings()); } public function testWhereAll() From 356526fe740125742093a3850482aa8ca504f11a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 25 Nov 2025 16:09:33 -0600 Subject: [PATCH 2/2] formatting --- src/Illuminate/Database/Query/Grammars/PostgresGrammar.php | 2 +- tests/Database/DatabaseQueryBuilderTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php index f45ea7add671..41cc1df618eb 100755 --- a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php +++ b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php @@ -181,7 +181,7 @@ public function whereFullText(Builder $query, $where) $mode = 'websearch_to_tsquery'; } - if (($where['options']['mode'] ?? []) === 'none') { + if (($where['options']['mode'] ?? []) === 'raw') { $mode = 'to_tsquery'; } diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index b85404708e3e..534623a4db31 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -1559,7 +1559,7 @@ public function testWhereFulltextPostgres() $this->assertEquals(['Car Plane'], $builder->getBindings()); $builder = $this->getPostgresBuilderWithProcessor(); - $builder->select('*')->from('users')->whereFullText(['body', 'title'], 'Air | Plan:* -Car', ['mode' => 'none']); + $builder->select('*')->from('users')->whereFullText(['body', 'title'], 'Air | Plan:* -Car', ['mode' => 'raw']); $this->assertSame('select * from "users" where (to_tsvector(\'english\', "body") || to_tsvector(\'english\', "title")) @@ to_tsquery(\'english\', ?)', $builder->toSql()); $this->assertEquals(['Air | Plan:* -Car'], $builder->getBindings()); }