orm
orm copied to clipboard
QueryBuilder fails to return data with an array parameter
Bug Report
| Q | A |
|---|---|
| BC Break | no |
| Version | 2.11 |
Summary
The QueryBuilder returns no records when using an array parameter
Current behavior
getOneOrNullResult returns null
How to reproduce
$pdo = $em->getConnection();
$qe = $pdo->executeQuery( 'SELECT * FROM Edata_payment e0_ WHERE e0_.contract = ? AND e0_.a_status NOT IN (?)', [ $contractId, '0,1' ] );
$la = $qe->fetchAssociative();
$qe = $pdo->executeQuery( 'SELECT * FROM Edata_payment e0_ WHERE e0_.contract = ? AND e0_.a_status NOT IN (?)', [ $contractId, [ 0, 1 ] ], [ 'integer', \Doctrine\DBAL\ArrayParameterType::INTEGER ] );
$lb = $qe->fetchAssociative();
/** @var LoanInstalment $li */
$li = LoanInstalmentRepository::instance()->createQueryBuilder( 'LCI' )
->where( 'LCI.contract = :contract and LCI.status NOT IN ( :status )' )
->setParameter( 'contract', $contractId )
->setParameter( 'status', [ \C_Loan_Contract_Instalment::STATUS_PAID_OFF, \C_Loan_Contract_Instalment::STATUS_RECEIVED ] )
// ->setParameter( 'status', implode( ',', [ \C_Loan_Contract_Instalment::STATUS_PAID_OFF, \C_Loan_Contract_Instalment::STATUS_RECEIVED ] ) )
->setMaxResults( 1 )
->orderBy( 'LCI.id', 'ASC' )
->getQuery()->getOneOrNullResult();
Case 1 ($la): simply works, when parameter is a string
Case 2 ($lb): what's happening inside the DBAL/Connection code when passing the array parameter into a Query Builder
Case 3 ($lb): is the actual Query Builder usage that fails
Expected behavior
Either $li is not null
Or Doctrine throws when/if it cannot handle array parameters
If this was fixed in a later version, please point me to the change log entry
FWIW my composer versions are
doctrine/annotations 1.14.3 Docblock Annotations Parser
doctrine/cache 1.13.0 PHP Doctrine Cache library is a popular cache implementation that supports many diff...
doctrine/collections 1.8.0 PHP Doctrine Collections library that adds additional functionality on top of PHP ar...
doctrine/common 3.4.4 PHP Doctrine Common project is a library that provides additional functionality that...
doctrine/dbal 3.9.0 Powerful PHP database abstraction layer (DBAL) with many features for database schem...
doctrine/deprecations 0.5.3 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with optio...
doctrine/event-manager 1.2.0 The Doctrine Event Manager is a simple PHP event system that was built to be used wi...
doctrine/inflector 2.0.10 PHP Doctrine Inflector is a small library that can perform string manipulations with...
doctrine/instantiator 1.5.0 A small, lightweight utility to instantiate objects in PHP without invoking their co...
doctrine/lexer 1.2.3 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Pa...
doctrine/orm 2.11.3 Object-Relational-Mapper for PHP
doctrine/persistence 2.5.7 The Doctrine Persistence project is a set of shared interfaces and functionality tha...
And the DB server is
mysql Ver 15.1 Distrib 10.6.19-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper