mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
[PR #7197] added possibility to create custom boolean function to use on where clause #10367
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/7197
State: closed
Merged: No
There is special cases on some platforms where you have functions on where clause wich are not part of comparisons. Instead they do some sort of boolean filtering internaly and use special indexes inside the engine itself.
That's the case for example spatial indexes in mysql:
and postgres:
And its also the case for full-text serach on mysql:
Doctrine itself has a custom function registry wich allows a parser for such functions to be registered, but if you use it on a WHERE clause, an exception is thrown saying a comparison operator is expected after the function, which is not desirable for boolean functions, that means doctrine orm does not support full text search os spatial indexes (at least i couldn't find a way to do it, maybe using doctrine filters?).
On my project i had to drop DQL and use natural query with the result set mapper, however that made impossible to create a custom filter for the api-platform bundle (and problably would have to for other cool abstractions out there). So i made this PR to fix that problem.
However, i think there's some uglyness on the ParserTest, but i couldn't think of a better way to test this fix, if necessary, i can take all feedback and do something better. Also, i dont know of the code on the parser is on the correct design for this context, if not, i will be glad to fix that too.
PS: One last thing, i've created a new registry key for custom functions called customBooleanFunctions, wich would possible lead to documentations change and the addition of that registry on doctrine bundle configuration, let me know if thats undesirable.