Allow for custom Postgres operators to be added #53324
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Postgres custom operators can be defined. Currently there is no way, tho, to add these to the grammar. This PR addresses this issue.
For my particular use-case, I am maintaining a package that integrates the
pg_search
extension by ParadeDB into Laravel. This extension comes with a custom@@@
operator that allows for full-text search. Up until recently, using this operator had some drawbacks and there was another way to integrate the extension, which I initially used for my integration. The use of this operator has been greatly improved in the latest version, tho, and the alternative way has therefore been deprecated.I have added a static
PostgresGrammar::customOperators()
method that can be called in service providers to add any needed operators. I looked into adding this to some of the other grammars as well, but couldn't find much information, tbh, so I asked @tpetry about this and apparently Postgres is the only database that allows custom operators.