Commit 56a70884 authored by romanb's avatar romanb

[2.0] Added missing detach cascade option.

parent 28ca2acb
...@@ -70,6 +70,7 @@ abstract class AssociationMapping ...@@ -70,6 +70,7 @@ abstract class AssociationMapping
public $isCascadePersist; public $isCascadePersist;
public $isCascadeRefresh; public $isCascadeRefresh;
public $isCascadeMerge; public $isCascadeMerge;
public $isCascadeDetach;
/** /**
* The fetch mode used for the association. * The fetch mode used for the association.
...@@ -188,6 +189,7 @@ abstract class AssociationMapping ...@@ -188,6 +189,7 @@ abstract class AssociationMapping
$this->isCascadePersist = in_array('persist', $this->cascades); $this->isCascadePersist = in_array('persist', $this->cascades);
$this->isCascadeRefresh = in_array('refresh', $this->cascades); $this->isCascadeRefresh = in_array('refresh', $this->cascades);
$this->isCascadeMerge = in_array('merge', $this->cascades); $this->isCascadeMerge = in_array('merge', $this->cascades);
$this->isCascadeDetach = in_array('detach', $this->cascades);
} }
/** /**
...@@ -234,6 +236,17 @@ abstract class AssociationMapping ...@@ -234,6 +236,17 @@ abstract class AssociationMapping
return $this->isCascadeMerge; return $this->isCascadeMerge;
} }
/**
* Whether the association cascades detach() operations from the source entity
* to the target entity/entities.
*
* @return boolean
*/
public function isCascadeDetach()
{
return $this->isCascadeDetach;
}
/** /**
* Whether the target entity/entities of the association are eagerly fetched. * Whether the target entity/entities of the association are eagerly fetched.
* *
......
...@@ -26,6 +26,8 @@ use Doctrine\Common\DoctrineException; ...@@ -26,6 +26,8 @@ use Doctrine\Common\DoctrineException;
/** /**
* A <tt>ClassMetadata</tt> instance holds all the ORM metadata of an entity and * A <tt>ClassMetadata</tt> instance holds all the ORM metadata of an entity and
* it's associations. It is the backbone of Doctrine's metadata mapping. * it's associations. It is the backbone of Doctrine's metadata mapping.
*
* Once populated, ClassMetadata instances are usually cached in a serialized form.
* *
* <b>IMPORTANT NOTE:</b> * <b>IMPORTANT NOTE:</b>
* *
......
...@@ -474,6 +474,9 @@ class SqlWalker implements TreeWalker ...@@ -474,6 +474,9 @@ class SqlWalker implements TreeWalker
} }
// Append foreign keys if necessary. // Append foreign keys if necessary.
//FIXME: Evaluate HINT_INCLUDE_META_COLUMNS
//FIXME: Needs to be done in the case of Class Table Inheritance, too
// (see upper block of the if/else)
if ( ! $this->_em->getConfiguration()->getAllowPartialObjects() && if ( ! $this->_em->getConfiguration()->getAllowPartialObjects() &&
! $this->_query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { ! $this->_query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) {
foreach ($class->associationMappings as $assoc) { foreach ($class->associationMappings as $assoc) {
...@@ -1003,7 +1006,6 @@ class SqlWalker implements TreeWalker ...@@ -1003,7 +1006,6 @@ class SqlWalker implements TreeWalker
if ($literal instanceof AST\InputParameter) { if ($literal instanceof AST\InputParameter) {
$dqlParamKey = $literal->isNamed() ? $literal->getName() : $literal->getPosition(); $dqlParamKey = $literal->isNamed() ? $literal->getName() : $literal->getPosition();
$this->_parserResult->addParameterMapping($dqlParamKey, $this->_sqlParamIndex++); $this->_parserResult->addParameterMapping($dqlParamKey, $this->_sqlParamIndex++);
//return ($literal->isNamed() ? ':' . $literal->getName() : '?');
return '?'; return '?';
} else { } else {
return $literal; //TODO: quote() ? return $literal; //TODO: quote() ?
...@@ -1045,7 +1047,6 @@ class SqlWalker implements TreeWalker ...@@ -1045,7 +1047,6 @@ class SqlWalker implements TreeWalker
$inputParam = $likeExpr->getStringPattern(); $inputParam = $likeExpr->getStringPattern();
$dqlParamKey = $inputParam->isNamed() ? $inputParam->getName() : $inputParam->getPosition(); $dqlParamKey = $inputParam->isNamed() ? $inputParam->getName() : $inputParam->getPosition();
$this->_parserResult->addParameterMapping($dqlParamKey, $this->_sqlParamIndex++); $this->_parserResult->addParameterMapping($dqlParamKey, $this->_sqlParamIndex++);
//$sql .= $inputParam->isNamed() ? ':' . $inputParam->getName() : '?';
$sql .= '?'; $sql .= '?';
} else { } else {
$sql .= $this->_conn->quote($likeExpr->getStringPattern()); $sql .= $this->_conn->quote($likeExpr->getStringPattern());
...@@ -1172,7 +1173,6 @@ class SqlWalker implements TreeWalker ...@@ -1172,7 +1173,6 @@ class SqlWalker implements TreeWalker
if (is_numeric($primary)) { if (is_numeric($primary)) {
$sql .= $primary; //TODO: quote() ? $sql .= $primary; //TODO: quote() ?
} else if (is_string($primary)) { } else if (is_string($primary)) {
//TODO: quote string according to platform
$sql .= $this->_conn->quote($primary); $sql .= $this->_conn->quote($primary);
} else if ($primary instanceof AST\SimpleArithmeticExpression) { } else if ($primary instanceof AST\SimpleArithmeticExpression) {
$sql .= '(' . $this->walkSimpleArithmeticExpression($primary) . ')'; $sql .= '(' . $this->walkSimpleArithmeticExpression($primary) . ')';
...@@ -1212,12 +1212,6 @@ class SqlWalker implements TreeWalker ...@@ -1212,12 +1212,6 @@ class SqlWalker implements TreeWalker
$qComp = $this->_queryComponents[$dqlAlias]; $qComp = $this->_queryComponents[$dqlAlias];
$class = $qComp['metadata']; $class = $qComp['metadata'];
/*if ($numParts > 2) {
for ($i = 1; $i < $numParts-1; ++$i) {
//TODO
}
}*/
if ($this->_useSqlTableAliases) { if ($this->_useSqlTableAliases) {
if ($class->isInheritanceTypeJoined() && isset($class->fieldMappings[$fieldName]['inherited'])) { if ($class->isInheritanceTypeJoined() && isset($class->fieldMappings[$fieldName]['inherited'])) {
$sql .= $this->getSqlTableAlias($this->_em->getClassMetadata( $sql .= $this->getSqlTableAlias($this->_em->getClassMetadata(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment