-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: When executing subqueries with the same conditions, the number of elements in the binding parameter array is different. The first subquery executes successfully, but the second subquery results in an error due to inconsistent binding parameter counts. #16652
Comments
Steps to Reproducesequential execution
$query = Tabel::query();
$subQuery = (new Tabel)->getModelsManager()->createBuilder()
->from(Tabel::class)->columns('id')
->andWhere('id IN ({ids:array})')->getPhql();
$query->andWhere("id IN ($subQuery)", ['ids' => [1, 2]]);
$data = $query->limit(1)->execute()->toArray(); $query = Tabel::query();
$subQuery = (new Tabel)->getModelsManager()->createBuilder()
->from(Tabel::class)->columns('id')
->andWhere('id IN ({ids:array})')->getPhql();
$query->andWhere("id IN ($subQuery)", ['ids' => [1,2,3]]);
$data = $query->limit(1)->execute()->toArray(); |
reference resources #16573 , |
I've tested this as well, it seems the query string somehow gets cached or something
This here is the second query which has 3 query bound parameters. And technically if I dump the |
Tinkering with it, I learn bit more. @tingleiwuyan it seems this was made like that by design for performance reasons, and indeed only triggers whenever you do queries that have the same PHQL code. Meaning that whenever the PHQL remains the same, thus having the same uniqueId in the There is one simple solution when doing duplicate queries like this when the bound parameters changes, but the PHQL remains the same, and that's by clearing the
|
I tried |
You're welcome! Can probably close the issue since it is not a bug? |
Error Description
When executing subqueries with the same conditions, the number of elements in the binding parameter array is different. The first subquery executes successfully, but the second subquery results in an error due to inconsistent binding parameter counts.
Steps to Reproduce
sequential execution
2. Unsuccessful Query:
Expected Behavior
Both subqueries should execute successfully without errors related to the number of binding parameters.
Details
Additional Context
"In Phalcon 5.6.1, no exception is thrown, but the SQL isn't executed. In Phalcon 3.4, there's an error:
[2024-09-29 14:56:09] SYSTEM.ERROR: PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
."
For both queries, the SQL statements should be as follows:
2. Second Query:
The text was updated successfully, but these errors were encountered: