doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.92k stars 2.51k forks source link

Cannot use parameter in Select Group Concat with BIT_AND IF condition #11518

Open CabanesThibault opened 3 months ago

CabanesThibault commented 3 months ago

Hi,

I encountered an issue while trying to build a query with a BIT_AND condition on a parameter in a Group Concat select statement.

The problematic line is:

Capture d’écran de 2024-06-21 14-39-07

The query (the aidant parameter is set later in a simple where clause, so it does exists in the query):

Capture d’écran de 2024-06-21 15-30-25

If I execute the query, I get an exception "the query define 1 parameter but you bound 2"

If I comment the "setParameter("teacherLeaved", STATUT)", I get an exception "the query define 2 parameters but you only bound 1"

If I explicitly define the value in the select BIT_AND and remove the "setParameter("teacherLeaved")", everything works well.

Capture d’écran de 2024-06-21 14-43-13

I'd tried to use BIT_AND(aa.status, (:teacherLeaved param)) as described here, for param in a select but it don't work neither (i also tried without the "param" at the end of the parenthesis).

I don't really get the point here, is there a reason or is it a lack of support for this kind of usage?

Right now to make it work, i'm just concatenating my value in the select clause and it works like a charm, but i would like to understand the problem.

Capture d’écran de 2024-06-21 15-19-56