Collections/ExpressionBuilder::contains generate CONTAINS instead of LIKE in MySQL #5874

Open
opened 2026-01-22 15:20:47 +01:00 by admin · 6 comments
Owner

Originally created by @holantomas on GitHub (Feb 6, 2018).

Hi,
I found that if I try to filter over PersistentCollection using contains(there's no LIKE like in query builder) it throws SQL Error cause used key word CONTAINS instead of LIKE in WHERE conditions.

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CONTAINS '%dsadas%' ...' at line 1

https://github.com/doctrine/doctrine2/pull/7042

Originally created by @holantomas on GitHub (Feb 6, 2018). Hi, I found that if I try to filter over PersistentCollection using contains(there's no `LIKE` like in query builder) it throws SQL Error cause used key word **CONTAINS** instead of **LIKE** in **WHERE** conditions. ``` SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CONTAINS '%dsadas%' ...' at line 1 ``` https://github.com/doctrine/doctrine2/pull/7042
Author
Owner

@Ocramius commented on GitHub (Feb 6, 2018):

Absolute ref to linked line: 6a205be3be/lib/Doctrine/Common/Collections/ExpressionBuilder.php (L145)

@Ocramius commented on GitHub (Feb 6, 2018): Absolute ref to linked line: https://github.com/doctrine/collections/blob/6a205be3bec4cb49e6a5adcb799a3c79a47aad38/lib/Doctrine/Common/Collections/ExpressionBuilder.php#L145
Author
Owner

@holantomas commented on GitHub (Feb 6, 2018):

@Ocramius I don't know how deal with this link 😆. I found that line, that's why I thought that's doctrine\collections bug.

@holantomas commented on GitHub (Feb 6, 2018): @Ocramius I don't know how deal with this link :laughing:. I found that line, that's why I thought that's **doctrine\collections** bug.
Author
Owner

@Ocramius commented on GitHub (Feb 6, 2018):

@holantomas #7042 seems to pass - so I guess you didn't yet reproduce it in isolation: is that the problem?

@Ocramius commented on GitHub (Feb 6, 2018): @holantomas #7042 seems to pass - so I guess you didn't yet reproduce it in isolation: is that the problem?
Author
Owner

@holantomas commented on GitHub (Feb 6, 2018):

Actually that's right. If I run same test code in my enviroment, it crash. I respond on PR topic.

https://github.com/doctrine/doctrine2/pull/7042#issuecomment-363384191

@holantomas commented on GitHub (Feb 6, 2018): Actually that's right. If I run same test code in my enviroment, it crash. I respond on PR topic. https://github.com/doctrine/doctrine2/pull/7042#issuecomment-363384191
Author
Owner

@holantomas commented on GitHub (Feb 6, 2018):

Ok, now it throwing right exception. I used ManyToOne before. Update test case to use ManyToMany collection and clear entity manager to force loading from DB.
https://travis-ci.org/doctrine/doctrine2/jobs/337967124#L1855

@holantomas commented on GitHub (Feb 6, 2018): Ok, now it throwing right exception. I used ManyToOne before. Update test case to use ManyToMany collection and clear entity manager to force loading from DB. https://travis-ci.org/doctrine/doctrine2/jobs/337967124#L1855
Author
Owner

@holantomas commented on GitHub (Feb 7, 2018):

@Ocramius @mikeSimonson Thanks to @vaniocz there is problem in ManyToManyPersister where operator is directly written instead of translate. So there should not work any operator like MEMBER_OF, CONTAINS, ...
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php#L283

@holantomas commented on GitHub (Feb 7, 2018): @Ocramius @mikeSimonson Thanks to @vaniocz there is problem in ManyToManyPersister where operator is directly written instead of translate. So there should not work any operator like MEMBER_OF, CONTAINS, ... https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php#L283
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5874