postgresql-for-doctrine icon indicating copy to clipboard operation
postgresql-for-doctrine copied to clipboard

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

Open allan-simon opened this issue 2 years ago • 3 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

allan-simon avatar May 31 '23 07:05 allan-simon

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

TomLorenzi avatar Aug 10 '23 10:08 TomLorenzi

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

klobastov avatar Oct 07 '23 07:10 klobastov