Commit db603547 authored by Roman S. Borschel's avatar Roman S. Borschel

Added failing test for DDC-388. Naming refactorings and comment cleanups.

parent cb616956
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......
......@@ -339,11 +339,11 @@ class ClassMetadata extends ClassMetadataInfo
$this->reflClass = new ReflectionClass($this->name);
foreach ($this->fieldMappings as $field => $mapping) {
if (isset($mapping['inherited'])) {
$reflField = new ReflectionProperty($mapping['inherited'], $field);
} else {
$reflField = $this->reflClass->getProperty($field);
}
if (isset($mapping['inherited'])) {
$reflField = new ReflectionProperty($mapping['inherited'], $field);
} else {
$reflField = $this->reflClass->getProperty($field);
}
$reflField->setAccessible(true);
$this->reflFields[$field] = $reflField;
}
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -21,8 +19,6 @@
namespace Doctrine\ORM;
use Doctrine\DBAL\Types\Type;
/**
* Represents a native SQL query.
*
......
......@@ -24,11 +24,8 @@ namespace Doctrine\ORM;
/**
* OptimisticLockException
*
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
class OptimisticLockException extends ORMException
{
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -33,19 +31,17 @@ use Doctrine\ORM\EntityManager,
abstract class AbstractCollectionPersister
{
/**
*
* @var EntityManager
*/
protected $_em;
/**
* @var \Doctrine\DBAL\Connection
* @var Doctrine\DBAL\Connection
*/
protected $_conn;
/**
*
* @var \Doctrine\ORM\UnitOfWork
* @var Doctrine\ORM\UnitOfWork
*/
protected $_uow;
......@@ -71,8 +67,8 @@ abstract class AbstractCollectionPersister
if ( ! $coll->getMapping()->isOwningSide) {
return; // ignore inverse side
}
$sql = $this->_getDeleteSql($coll);
$this->_conn->executeUpdate($sql, $this->_getDeleteSqlParameters($coll));
$sql = $this->_getDeleteSQL($coll);
$this->_conn->executeUpdate($sql, $this->_getDeleteSQLParameters($coll));
}
/**
......@@ -80,7 +76,7 @@ abstract class AbstractCollectionPersister
*
* @param PersistentCollection $coll
*/
abstract protected function _getDeleteSql(PersistentCollection $coll);
abstract protected function _getDeleteSQL(PersistentCollection $coll);
/**
* Gets the SQL parameters for the corresponding SQL statement to delete
......@@ -88,7 +84,7 @@ abstract class AbstractCollectionPersister
*
* @param PersistentCollection $coll
*/
abstract protected function _getDeleteSqlParameters(PersistentCollection $coll);
abstract protected function _getDeleteSQLParameters(PersistentCollection $coll);
/**
* Updates the given collection, synchronizing it's state with the database
......@@ -109,9 +105,9 @@ abstract class AbstractCollectionPersister
public function deleteRows(PersistentCollection $coll)
{
$deleteDiff = $coll->getDeleteDiff();
$sql = $this->_getDeleteRowSql($coll);
$sql = $this->_getDeleteRowSQL($coll);
foreach ($deleteDiff as $element) {
$this->_conn->executeUpdate($sql, $this->_getDeleteRowSqlParameters($coll, $element));
$this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element));
}
}
......@@ -121,9 +117,9 @@ abstract class AbstractCollectionPersister
public function insertRows(PersistentCollection $coll)
{
$insertDiff = $coll->getInsertDiff();
$sql = $this->_getInsertRowSql($coll);
$sql = $this->_getInsertRowSQL($coll);
foreach ($insertDiff as $element) {
$this->_conn->executeUpdate($sql, $this->_getInsertRowSqlParameters($coll, $element));
$this->_conn->executeUpdate($sql, $this->_getInsertRowSQLParameters($coll, $element));
}
}
......@@ -132,7 +128,7 @@ abstract class AbstractCollectionPersister
*
* @param PersistentCollection $coll
*/
abstract protected function _getDeleteRowSql(PersistentCollection $coll);
abstract protected function _getDeleteRowSQL(PersistentCollection $coll);
/**
* Gets the SQL parameters for the corresponding SQL statement to delete the given
......@@ -141,21 +137,21 @@ abstract class AbstractCollectionPersister
* @param PersistentCollection $coll
* @param mixed $element
*/
abstract protected function _getDeleteRowSqlParameters(PersistentCollection $coll, $element);
abstract protected function _getDeleteRowSQLParameters(PersistentCollection $coll, $element);
/**
* Gets the SQL statement used for updating a row in the collection.
*
* @param PersistentCollection $coll
*/
abstract protected function _getUpdateRowSql(PersistentCollection $coll);
abstract protected function _getUpdateRowSQL(PersistentCollection $coll);
/**
* Gets the SQL statement used for inserting a row in the collection.
*
* @param PersistentCollection $coll
*/
abstract protected function _getInsertRowSql(PersistentCollection $coll);
abstract protected function _getInsertRowSQL(PersistentCollection $coll);
/**
* Gets the SQL parameters for the corresponding SQL statement to insert the given
......@@ -164,5 +160,5 @@ abstract class AbstractCollectionPersister
* @param PersistentCollection $coll
* @param mixed $element
*/
abstract protected function _getInsertRowSqlParameters(PersistentCollection $coll, $element);
abstract protected function _getInsertRowSQLParameters(PersistentCollection $coll, $element);
}
\ No newline at end of file
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -27,13 +25,10 @@ use Doctrine\ORM\Query\Parser,
/**
* A Query object represents a DQL query.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @since 1.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
final class Query extends AbstractQuery
{
......@@ -62,6 +57,7 @@ final class Query extends AbstractQuery
* partial objects.
*
* @var string
* @todo Rename: HINT_OPTIMIZE
*/
const HINT_FORCE_PARTIAL_LOAD = 'doctrine.forcePartialLoad';
/**
......@@ -149,10 +145,10 @@ final class Query extends AbstractQuery
*
* @param Doctrine\ORM\EntityManager $entityManager
*/
public function __construct(EntityManager $entityManager)
/*public function __construct(EntityManager $entityManager)
{
parent::__construct($entityManager);
}
}*/
/**
* Gets the SQL query/queries that correspond to this DQL query.
......@@ -162,7 +158,7 @@ final class Query extends AbstractQuery
*/
public function getSQL()
{
return $this->_parse()->getSqlExecutor()->getSqlStatements();
return $this->_parse()->getSQLExecutor()->getSQLStatements();
}
/**
......@@ -366,7 +362,7 @@ final class Query extends AbstractQuery
* @param string $dqlQuery DQL Query
* @return Doctrine\ORM\AbstractQuery
*/
public function setDql($dqlQuery)
public function setDQL($dqlQuery)
{
if ($dqlQuery !== null) {
$this->_dql = $dqlQuery;
......@@ -380,7 +376,7 @@ final class Query extends AbstractQuery
*
* @return string DQL query
*/
public function getDql()
public function getDQL()
{
return $this->_dql;
}
......@@ -408,7 +404,7 @@ final class Query extends AbstractQuery
*/
public function contains($dql)
{
return stripos($this->getDql(), $dql) === false ? false : true;
return stripos($this->getDQL(), $dql) === false ? false : true;
}
/**
......
......@@ -432,7 +432,7 @@ class SqlWalker implements TreeWalker
$class = $this->_em->getClassMetadata($class->fieldMappings[$fieldName]['inherited']);
}
return $this->getSqlTableAlias($class->table['name'], $identificationVariable);
return $this->getSQLTableAlias($class->table['name'], $identificationVariable);
}
/**
......@@ -789,6 +789,7 @@ class SqlWalker implements TreeWalker
$sql .= ' AND ' . $discrSql;
}
//FIXME: these should either be nested or all forced to be left joins (DDC-XXX)
if ($targetClass->isInheritanceTypeJoined()) {
$sql .= $this->_generateClassTableInheritanceJoins($targetClass, $joinedDqlAlias);
}
......
......@@ -168,7 +168,7 @@ class QueryBuilder
*
* @return string The DQL string
*/
public function getDql()
public function getDQL()
{
if ($this->_dql !== null && $this->_state === self::STATE_CLEAN) {
return $this->_dql;
......@@ -178,16 +178,16 @@ class QueryBuilder
switch ($this->_type) {
case self::DELETE:
$dql = $this->_getDqlForDelete();
$dql = $this->_getDQLForDelete();
break;
case self::UPDATE:
$dql = $this->_getDqlForUpdate();
$dql = $this->_getDQLForUpdate();
break;
case self::SELECT:
default:
$dql = $this->_getDqlForSelect();
$dql = $this->_getDQLForSelect();
break;
}
......@@ -211,7 +211,7 @@ class QueryBuilder
*/
public function getQuery()
{
return $this->_em->createQuery($this->getDql())
return $this->_em->createQuery($this->getDQL())
->setParameters($this->_params)
->setFirstResult($this->_firstResult)
->setMaxResults($this->_maxResults);
......@@ -613,7 +613,7 @@ class QueryBuilder
*/
public function andWhere($where)
{
$where = $this->getDqlPart('where');
$where = $this->getDQLPart('where');
$args = func_get_args();
if ($where instanceof Expr\Andx) {
......@@ -744,7 +744,7 @@ class QueryBuilder
array_unshift($args, $having);
$having = new Expr\Orx($args);
}
return $this->add('having', $having);
}
......@@ -779,7 +779,7 @@ class QueryBuilder
* @param string $queryPartName
* @return mixed $queryPart
*/
public function getDqlPart($queryPartName)
public function getDQLPart($queryPartName)
{
return $this->_dqlParts[$queryPartName];
}
......@@ -789,43 +789,43 @@ class QueryBuilder
*
* @return array $dqlParts
*/
public function getDqlParts()
public function getDQLParts()
{
return $this->_dqlParts;
}
private function _getDqlForDelete()
private function _getDQLForDelete()
{
return 'DELETE'
. $this->_getReducedDqlQueryPart('from', array('pre' => ' ', 'separator' => ', '))
. $this->_getReducedDqlQueryPart('where', array('pre' => ' WHERE '))
. $this->_getReducedDqlQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
. $this->_getReducedDQLQueryPart('from', array('pre' => ' ', 'separator' => ', '))
. $this->_getReducedDQLQueryPart('where', array('pre' => ' WHERE '))
. $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
}
private function _getDqlForUpdate()
private function _getDQLForUpdate()
{
return 'UPDATE'
. $this->_getReducedDqlQueryPart('from', array('pre' => ' ', 'separator' => ', '))
. $this->_getReducedDqlQueryPart('set', array('pre' => ' SET ', 'separator' => ', '))
. $this->_getReducedDqlQueryPart('where', array('pre' => ' WHERE '))
. $this->_getReducedDqlQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
. $this->_getReducedDQLQueryPart('from', array('pre' => ' ', 'separator' => ', '))
. $this->_getReducedDQLQueryPart('set', array('pre' => ' SET ', 'separator' => ', '))
. $this->_getReducedDQLQueryPart('where', array('pre' => ' WHERE '))
. $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
}
private function _getDqlForSelect()
private function _getDQLForSelect()
{
return 'SELECT'
. $this->_getReducedDqlQueryPart('select', array('pre' => ' ', 'separator' => ', '))
. $this->_getReducedDqlQueryPart('from', array('pre' => ' FROM ', 'separator' => ', '))
. $this->_getReducedDqlQueryPart('join', array('pre' => ' ', 'separator' => ' '))
. $this->_getReducedDqlQueryPart('where', array('pre' => ' WHERE '))
. $this->_getReducedDqlQueryPart('groupBy', array('pre' => ' GROUP BY ', 'separator' => ', '))
. $this->_getReducedDqlQueryPart('having', array('pre' => ' HAVING '))
. $this->_getReducedDqlQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
. $this->_getReducedDQLQueryPart('select', array('pre' => ' ', 'separator' => ', '))
. $this->_getReducedDQLQueryPart('from', array('pre' => ' FROM ', 'separator' => ', '))
. $this->_getReducedDQLQueryPart('join', array('pre' => ' ', 'separator' => ' '))
. $this->_getReducedDQLQueryPart('where', array('pre' => ' WHERE '))
. $this->_getReducedDQLQueryPart('groupBy', array('pre' => ' GROUP BY ', 'separator' => ', '))
. $this->_getReducedDQLQueryPart('having', array('pre' => ' HAVING '))
. $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
}
private function _getReducedDqlQueryPart($queryPartName, $options = array())
private function _getReducedDQLQueryPart($queryPartName, $options = array())
{
$queryPart = $this->getDqlPart($queryPartName);
$queryPart = $this->getDQLPart($queryPartName);
if (empty($queryPart)) {
return (isset($options['empty']) ? $options['empty'] : '');
......@@ -838,11 +838,6 @@ class QueryBuilder
public function __toString()
{
return $this->getDql();
return $this->getDQL();
}
/*public function __clone()
{
$this->_q = clone $this->_q;
}*/
}
\ No newline at end of file
......@@ -51,6 +51,20 @@ class BasicInheritanceMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue(empty($class->inheritedAssociationFields));
$this->assertTrue(isset($class->associationMappings['mappedRelated1']));
}
/**
* @group DDC-388
*/
public function testSerializationWithPrivateFieldsFromMappedSuperclass()
{
$class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\EntitySubClass2');
$class2 = unserialize(serialize($class));
$this->assertTrue(isset($class2->reflFields['mapped1']));
$this->assertTrue(isset($class2->reflFields['mapped2']));
}
}
class TransientBaseClass {
......
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