mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1277: BasicEntityPersister::expandParameters() will check associations #1607
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jul 14, 2011).
Originally assigned to: @guilhermeblanco on GitHub.
Jira issue originally created by user jasper@nerdsweide.nl:
When executing a
EntityRepository::findBy()orEntityRepository::findOnyBy()with criteria that contain a field/value pair where the field is an association-name and the value is an array, some (for me) unexpected behavior occurs.First an example to make my statement a bit more clear:
I have an entity
UserandGroupwhereGrouphas manyUsers(Usermany-to-oneGroup).When I call
UserRepository->findBy( array( 'group' => 1 )), all goes well.When I call
UserRepository->findBy( array( 'group' => array( 1, 2, 3 ))), I get an notice and no results (Notice: Array to string conversion in /opt/local/www/doctrine2/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php on line 613)I've tracked the "problem" down to the
BasicEntityPersister:BasicEntityPersister::*getSelectEntitiesSQL(), which usesBasicEntityPersister::_getSelectConditionSQL(), correctly creates a query containing something likeWHERE t0.group*id IN ( ? ).But
BasicEntityPersister::expandParameters()doesn't implode the array to some string that can be bound to the query. This is because it doesn't take into account that the field could be an association.I don't know if this is intended behavior, but I would think not. I've therefor altered the
BasicEntityPersister::expandParameters()a bit:I hope this bit of code also clarifies what I'm trying to explain a bit more...