doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.9k stars 2.5k forks source link

[BUG] No results when adding more than 2 parameters to the querybuilder #6012

Open chris-bot-lab opened 7 years ago

chris-bot-lab commented 7 years ago

Package version

laravel-doctrine/orm v1.2.5 using -> doctrine/orm v2.5.4 Lumen v5.2.7. Oracle database.

$conn = $this->getEntityManager()->getConnection();
$queryBuilder = $conn->createQueryBuilder();
$queryBuilder->select('*')
    ->from('SYNCHS')
    ->where('SYNCHS.CLIENT_ID = :clientId')
    ->andWhere('SYNCHS.TOP_CLIENT_ID = :topClientId')
    ->andWhere('SYNCHS.ID = :synchId');

$queryBuilder->setParameter('clientId', $clientId)
    ->setParameter('topClientId', $topClientId)
    ->setParameter('synchId', $synchId);

echo $queryBuilder->getSQL();
var_dump($queryBuilder->getParameters());

$stmt = $queryBuilder->execute();
var_dump($stmt);

$results = $stmt->fetchAll();
dd($results);

If I comment any one of the where/addwhere clause, I end up with the expected result set, but if I have more than 2 parameters bound, it returns an empty array instead of 1 row. $queryBuilder->getParameters() is returning all 3 parameters. When using the 3 parameters, if I copy / paste the string returned by $queryBuilder->getSQL(); into Toad and run the query against the database with the parameter values returned by $queryBuilder->getParameters(), I get 1 row.

Same thing happens when I use the setParameters() function instead of setParameter().

Expected behaviour

$results contains 1 row.

Actual behaviour

$results is an empty array.

Link of the issue opened in doctrine-laravel/orm github: https://github.com/laravel-doctrine/orm/issues/179

Ocramius commented 7 years ago

This seems to be a DBAL issue. Do you have a reproducible test case for it?