Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BasicEntityPersister::exists() was not supporting identifiers that ar…

…e associations. Fixes DDC-1382.
  • Loading branch information...
commit 24042863acbabdcd0fa1432135a9836467f3bce7 1 parent ebe9338
Guilherme Blanco guilhermeblanco authored
Showing with 15 additions and 4 deletions.
  1. +15 −4 lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
19 lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
View
@@ -747,6 +747,7 @@ public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = n
*
* @param array $assoc
* @param Doctrine\DBAL\Statement $stmt
+ *
* @return array
*/
private function loadArrayFromStatement($assoc, $stmt)
@@ -771,6 +772,8 @@ private function loadArrayFromStatement($assoc, $stmt)
* @param array $assoc
* @param Doctrine\DBAL\Statement $stmt
* @param PersistentCollection $coll
+ *
+ * @return array
*/
private function loadCollectionFromStatement($assoc, $stmt, $coll)
{
@@ -784,7 +787,8 @@ private function loadCollectionFromStatement($assoc, $stmt, $coll)
}
$hydrator = $this->_em->newHydrator(Query::HYDRATE_OBJECT);
- $hydrator->hydrateAll($stmt, $rsm, $hints);
+
+ return $hydrator->hydrateAll($stmt, $rsm, $hints);
}
/**
@@ -1179,6 +1183,7 @@ protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r
$sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias)
. '.' . $class->getQuotedColumnName($field, $this->_platform);
$columnAlias = $this->_platform->getSQLResultCasing($columnName . $this->_sqlAliasCounter++);
+
$this->_rsm->addFieldResult($alias, $columnAlias, $field);
return $sql . ' AS ' . $columnAlias;
@@ -1228,7 +1233,9 @@ public function lock(array $criteria, $lockMode)
$sql = 'SELECT 1 '
. $this->_platform->appendLockHint($this->getLockTablesSql(), $lockMode)
. ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' ' . $lockSql;
+
list($params, $types) = $this->expandParameters($criteria);
+
$stmt = $this->_conn->executeQuery($sql, $params, $types);
}
@@ -1320,7 +1327,8 @@ public function getOneToManyCollection(array $assoc, $sourceEntity, $offset = nu
public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentCollection $coll)
{
$stmt = $this->getOneToManyStatement($assoc, $sourceEntity);
- $this->loadCollectionFromStatement($assoc, $stmt, $coll);
+
+ return $this->loadCollectionFromStatement($assoc, $stmt, $coll);
}
/**
@@ -1478,6 +1486,7 @@ private function getIndividualValue($value)
public function exists($entity, array $extraConditions = array())
{
$criteria = $this->_class->getIdentifierValues($entity);
+
if ($extraConditions) {
$criteria = array_merge($criteria, $extraConditions);
}
@@ -1485,7 +1494,9 @@ public function exists($entity, array $extraConditions = array())
$sql = 'SELECT 1'
. ' FROM ' . $this->_class->getQuotedTableName($this->_platform) . ' ' . $this->_getSQLTableAlias($this->_class->name)
. ' WHERE ' . $this->_getSelectConditionSQL($criteria);
-
- return (bool) $this->_conn->fetchColumn($sql, array_values($criteria));
+
+ list($params, $types) = $this->expandParameters($criteria);
+
+ return (bool) $this->_conn->fetchColumn($sql, $params);
}
}

1 comment on commit 2404286

Guilherme Blanco

@beberlei Please merge in 2.1 =)

Please sign in to comment.
Something went wrong with that request. Please try again.