mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Documentation for 'IN' with query builder is misleading #5626
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 @gbirke on GitHub (Aug 2, 2017).
The documentation for the query builder and building
INandNOT INexpression saysRelying on that comment I tried code like this:
This lead to the error message
Too many parameters: the query defines 0 parameters and you bound 2When I specified the strings directly, the query worked as expected:
Looking at the code in the expression builder it looks like my strings will be quoted correctly.
Is the comment in the documentation still relevant? Maybe it hints at a different use case (e.g. subqueries)?
I'm not sure how the text could be improved.
@Dormilich commented on GitHub (Dec 9, 2024):
Expr::in()will quote all values contained in the second argument if it is iterable (i.e. when it assumes it is a list of values for the IN() clause). For binding parameters you just pass in the placeholder as is (e.g.$expr->in('e.id', '?1')).Insofar the documentaion is incorrect when it comes to using placeholders.
@greg0ire commented on GitHub (Dec 9, 2024):
Since
4adc289596, there even is a test showing that it's fine to use$qb->expr()->in('value', array('stringvalue'))@Dormilich can you send a PR to fix the docs?