diff --git a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php index 3a2a7b425f3c..41cc1df618eb 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'] ?? []) === 'raw') { + $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..534623a4db31 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' => '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()); } public function testWhereAll()