Merge branch 'DDC-949'
This commit is contained in:
commit
ed7ec261d0
@ -525,7 +525,8 @@ class BasicEntityPersister
|
|||||||
public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = 0)
|
public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = 0)
|
||||||
{
|
{
|
||||||
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc, $lockMode);
|
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc, $lockMode);
|
||||||
$stmt = $this->_conn->executeQuery($sql, array_values($criteria));
|
list($params, $types) = $this->expandParameters($criteria);
|
||||||
|
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
@ -608,7 +609,8 @@ class BasicEntityPersister
|
|||||||
public function refresh(array $id, $entity)
|
public function refresh(array $id, $entity)
|
||||||
{
|
{
|
||||||
$sql = $this->_getSelectEntitiesSQL($id);
|
$sql = $this->_getSelectEntitiesSQL($id);
|
||||||
$stmt = $this->_conn->executeQuery($sql, array_values($id));
|
list($params, $types) = $this->expandParameters($id);
|
||||||
|
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
@ -694,7 +696,8 @@ class BasicEntityPersister
|
|||||||
{
|
{
|
||||||
$entities = array();
|
$entities = array();
|
||||||
$sql = $this->_getSelectEntitiesSQL($criteria);
|
$sql = $this->_getSelectEntitiesSQL($criteria);
|
||||||
$stmt = $this->_conn->executeQuery($sql, array_values($criteria));
|
list($params, $types) = $this->expandParameters($criteria);
|
||||||
|
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
@ -742,7 +745,8 @@ class BasicEntityPersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc);
|
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc);
|
||||||
$stmt = $this->_conn->executeQuery($sql, array_values($criteria));
|
list($params, $types) = $this->expandParameters($criteria);
|
||||||
|
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||||
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$coll->hydrateAdd($this->_createEntity($result));
|
$coll->hydrateAdd($this->_createEntity($result));
|
||||||
}
|
}
|
||||||
@ -1084,8 +1088,8 @@ class BasicEntityPersister
|
|||||||
$sql = 'SELECT 1 '
|
$sql = 'SELECT 1 '
|
||||||
. $this->_platform->appendLockHint($this->getLockTablesSql(), $lockMode)
|
. $this->_platform->appendLockHint($this->getLockTablesSql(), $lockMode)
|
||||||
. ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' ' . $lockSql;
|
. ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' ' . $lockSql;
|
||||||
$params = array_values($criteria);
|
list($params, $types) = $this->expandParameters($criteria);
|
||||||
$this->_conn->executeQuery($sql, $params);
|
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1169,14 +1173,35 @@ class BasicEntityPersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc);
|
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc);
|
||||||
$params = array_values($criteria);
|
list($params, $types) = $this->expandParameters($criteria);
|
||||||
$stmt = $this->_conn->executeQuery($sql, $params);
|
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||||
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$coll->hydrateAdd($this->_createEntity($result));
|
$coll->hydrateAdd($this->_createEntity($result));
|
||||||
}
|
}
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand the parameters from the given criteria and use the correct binding types if found.
|
||||||
|
*
|
||||||
|
* @param array $criteria
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function expandParameters($criteria)
|
||||||
|
{
|
||||||
|
$params = $types = array();
|
||||||
|
|
||||||
|
foreach ($criteria AS $field => $value) {
|
||||||
|
$type = null;
|
||||||
|
if (isset($this->_class->fieldMappings[$field])) {
|
||||||
|
$type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
|
||||||
|
}
|
||||||
|
$params[] = $value;
|
||||||
|
$types[] = $type;
|
||||||
|
}
|
||||||
|
return array($params, $types);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the given managed entity exists in the database.
|
* Checks whether the given managed entity exists in the database.
|
||||||
*
|
*
|
||||||
|
43
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php
Normal file
43
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Tests\Models\Generic\BooleanModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../TestInit.php';
|
||||||
|
|
||||||
|
class DDC949Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->useModelSet('generic');
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-949
|
||||||
|
*/
|
||||||
|
public function testBooleanThroughRepository()
|
||||||
|
{
|
||||||
|
$true = new BooleanModel();
|
||||||
|
$true->booleanField = true;
|
||||||
|
|
||||||
|
$false = new BooleanModel();
|
||||||
|
$false->booleanField = false;
|
||||||
|
|
||||||
|
$this->_em->persist($true);
|
||||||
|
$this->_em->persist($false);
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$true = $this->_em->getRepository('Doctrine\Tests\Models\Generic\BooleanModel')->findOneBy(array('booleanField' => true));
|
||||||
|
$false = $this->_em->getRepository('Doctrine\Tests\Models\Generic\BooleanModel')->findOneBy(array('booleanField' => false));
|
||||||
|
|
||||||
|
$this->assertType('Doctrine\Tests\Models\Generic\BooleanModel', $true);
|
||||||
|
$this->assertTrue($true->booleanField, "True Boolean Model should be true.");
|
||||||
|
|
||||||
|
$this->assertType('Doctrine\Tests\Models\Generic\BooleanModel', $false);
|
||||||
|
$this->assertFalse($false->booleanField, "False Boolean Model should be false.");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user