Closed Alikont closed 2 years ago
Thank you for the issue, and for the example!
Hello, thanks for the quick fix.
We've noticed a degradation in 1.0.22.
Multiple joins are not applied in PDO query builder.
I've updated the repo on the link. It fails with
Peachpie.Library.PDO.PDOException: 'The multi-part identifier "r2.name" could not be bound.'
Because query skips second join.
$builder->from('manager' . ' t')
->leftJoin('role' . ' r ON r.id=t.role_id')
->leftJoin('role' . ' r2 ON r2.id=t.role_id')
->select('r.is_admin, r2.name as role')
->where('t.login', $login)->where('t.archived', 0);
SELECT t.*, r.is_admin, r2.name as role
FROM manager t
LEFT JOIN role r ON r.id=t.role_id
WHERE t.login = ?
AND t.archived = ?
1.0.21 works fine.
Should I create a new issue?
@Alikont I'm thinking about two possible causes:
rowCount
changed https://github.com/peachpiecompiler/peachpie/commit/2d1b45d1f61e23e87828ca6f31b8f20baa0aa559PHP_VERSION
changed to 8.0 (this can be changed using <LangVersion>
property)It fails before query even executes, it's somewhere inside query builder, so it's definitely not the rowCount
fix.
Our main PHP project uses 7.2, but setting it also doesn't work.
I narrowed it down to specific line of code.
this regex should fill $maches
variable by ref, it correctly parses the expression, but the &$matches
parameter is empty after method exits. Then FluentPDO thinks that SQL is invalid and fails to build it correctly.
1.0.21:
1.0.22:
I see! Ok, I'll prepare a unit test, and fix it.
When using Fluent PDO some queries return TypeError during execution. But they work fine in PHP 7
Exception
Pchp.Library.Spl.TypeError: ''
Callstack
Database creation script:
Generated SQL (it expects zero entries on return)
Full reproduce repository: https://github.com/Alikont/Peachpie-FluentPDO-Issue-TypeError