martin-georgiev / postgresql-for-doctrine

PostgreSQL enhancements for Doctrine. Provides support for advanced data types (json, jssnb, arrays), text search, array operators and jsonb specific functions.

Home Page:https://packagist.org/packages/martin-georgiev/postgresql-for-doctrine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`ANY` should accept `text[]` field, currently throw a `Expected Doctrine\ORM\Query\Lexer::T_SELECT`

allan-simon opened this issue · comments

i.e if I have a field featureFlags which is declared as text[]

and I try to do

       $this->em->createQuery("

            SELECT u FROM App\Entity\EndUser u
            WHERE 'something' = ANY(u.featureFlags)
        ");

I got Expected Doctrine\ORM\Query\Lexer::T_SELECT, got 'u'

whereas if i type directly in postgresql

SELECT * FROM end_users WHERE 'something' = ANY (feature_flags)

it works

As I'm working with my own DQL, the best solution for that would be to change the name of the called function.
Doctrine only expect sub select as parameters, so it will trigger your error.
Renaming ANY() to CUSTOM_ANY() as an example would allow you in your request to have something like this SELECT * FROM end_users WHERE 'something' = CUSTOM_ANY(feature_flags);

This will bypass the doctrine verification of ANY parameters and work

EDIT: looking at the docs, you should use ANY_OF() here, and it will do what I said above. @allan-simon

same deprecatino for MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Cast