[Syntax Error] line 0, col 94: Error: Expected Doctrine\\ORM\\Query\\Lexer::T_COMMA, got 'AND'" Upgrade to 2.6 #6040

Closed
opened 2026-01-22 15:25:15 +01:00 by admin · 6 comments
Owner

Originally created by @mayro on GitHub (Aug 20, 2018).

Originally assigned to: @Ocramius on GitHub.

Hello,
I used REGEXP, and i have this error.
Here is the produced DQL:

SELECT t FROM Test t WHERE t.account = :account AND REGEXP(t.labels AND :excludetag0) = false AND REGEXP(t.labels AND :excludetag1) = false ORDER BY t.id DESC

This was perfectly working with the same code for v2.5, not after upgrading to 2.6.
Rolling back to v2.5 was the only thing I did to make it working again.

Originally created by @mayro on GitHub (Aug 20, 2018). Originally assigned to: @Ocramius on GitHub. Hello, I used REGEXP, and i have this error. Here is the produced DQL: ```sql SELECT t FROM Test t WHERE t.account = :account AND REGEXP(t.labels AND :excludetag0) = false AND REGEXP(t.labels AND :excludetag1) = false ORDER BY t.id DESC ``` This was perfectly working with the same code for v2.5, not after upgrading to 2.6. Rolling back to v2.5 was the only thing I did to make it working again.
admin added the BugInvalidMissing TestsRegression labels 2026-01-22 15:25:15 +01:00
admin closed this issue 2026-01-22 15:25:17 +01:00
Author
Owner

@Ocramius commented on GitHub (Aug 20, 2018):

Went through https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#conditional-expressions, seems OK, so this is probably a bug, not a BC break.

I don't see a REGEXP() function in ORM though: where is that coming from?

Can you try reproducing the bug in a DQL test to be added to 7b261676d2/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php please?

@Ocramius commented on GitHub (Aug 20, 2018): Went through https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#conditional-expressions, seems OK, so this is probably a bug, not a BC break. I don't see a `REGEXP()` function in ORM though: where is that coming from? Can you try reproducing the bug in a DQL test to be added to https://github.com/doctrine/doctrine2/blob/7b261676d2356cb5ff0287e13fea331d463ac67a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php please?
Author
Owner

@mayro commented on GitHub (Aug 20, 2018):

Hello @Ocramius,
Thank you for your quick response.
You are right it seems to be a bug, i'm blocked by match() in Orm/Query/Parser.php.
I'm using the string_functions REGEXP. DoctrineExtensions\Query\Mysql\Regexp

@mayro commented on GitHub (Aug 20, 2018): Hello @Ocramius, Thank you for your quick response. You are right it seems to be a bug, i'm blocked by match() in Orm/Query/Parser.php. I'm using the string_functions REGEXP. DoctrineExtensions\Query\Mysql\Regexp
Author
Owner

@Ocramius commented on GitHub (Aug 20, 2018):

Can you print out a full trace, please?

@Ocramius commented on GitHub (Aug 20, 2018): Can you print out a full trace, please?
Author
Owner

@Ocramius commented on GitHub (Aug 20, 2018):

@mayro from your screenshots, it seems evident that you need a REGEXP(SOMETHING, SOMETHING) (notice the comma).

Closing as invalid here.

@Ocramius commented on GitHub (Aug 20, 2018): @mayro from your screenshots, it seems evident that you need a `REGEXP(SOMETHING, SOMETHING)` (notice the comma). Closing as `invalid` here.
Author
Owner

@mayro commented on GitHub (Aug 20, 2018):

@Ocramius
I don't understand whey you have closed quickly this issue.
This is my query $qb
->andWhere('REGEXP('labels', ':' . $attributeKey.') = true')
->setParameter($attributeKey, $this->regexTag($tag))

You can see that I'm using the comma ',' with my REGEXP. the "AND" is in the DQL transformation This was perfectly working with the same code for v2.5, not after upgrading to 2.6.

@mayro commented on GitHub (Aug 20, 2018): @Ocramius I don't understand whey you have closed quickly this issue. This is my query $qb ->andWhere('REGEXP('labels', ':' . $attributeKey.') = true') ->setParameter($attributeKey, $this->regexTag($tag)) You can see that I'm using the comma ',' with my REGEXP. the "AND" is in the DQL transformation This was perfectly working with the same code for v2.5, not after upgrading to 2.6.
Author
Owner

@Ocramius commented on GitHub (Aug 20, 2018):

The query you pasted above is following:

SELECT t
FROM Test t
WHERE t.account = :account 
AND REGEXP(t.labels AND :excludetag0) = false
AND REGEXP(t.labels AND :excludetag1) = false
ORDER BY t.id DESC

The transformation should be an SQL transformation, not a DQL one. The DQL parser is correctly throwing an exception, and your traces show that the failure is precisely in the handling of the custom DQL function.

@Ocramius commented on GitHub (Aug 20, 2018): The query you pasted above is following: ```sql SELECT t FROM Test t WHERE t.account = :account AND REGEXP(t.labels AND :excludetag0) = false AND REGEXP(t.labels AND :excludetag1) = false ORDER BY t.id DESC ``` The transformation should be an SQL transformation, not a DQL one. The DQL parser is correctly throwing an exception, and your traces show that the failure is precisely in the handling of the custom DQL function.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6040