1
0
mirror of synced 2025-02-20 06:03:15 +03:00

Merge branch 'master' into DDC-117

This commit is contained in:
Benjamin Eberlei 2010-08-08 14:07:24 +02:00
commit 7b07a17886
31 changed files with 387 additions and 170 deletions

View File

@ -1,3 +1,11 @@
# Update from 2.0-BETA3 to 2.0-BETA4
## XML Driver <change-tracking-policy /> element demoted to attribute
We changed how the XML Driver allows to define the change-tracking-policy. The working case is now:
<entity change-tracking-policy="DEFERRED_IMPLICT" />
# Update from 2.0-BETA2 to 2.0-BETA3
## Serialization of Uninitialized Proxies

View File

@ -75,6 +75,7 @@
<xs:attribute name="schema" type="xs:NMTOKEN" />
<xs:attribute name="repository-class" type="xs:NMTOKEN"/>
<xs:attribute name="inheritance-type" type="orm:inheritance-type"/>
<xs:attribute name="change-tracking-policy" type="orm:change-tracking-policy" />
</xs:complexType>
<xs:complexType name="mapped-superclass" >
@ -82,6 +83,14 @@
<xs:extension base="orm:entity"/>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="change-tracking-policy">
<xs:restriction base="xs:token">
<xs:enumeration value="DEFERRED_IMPLICIT"/>
<xs:enumeration value="DEFERRED_EXPLICIT"/>
<xs:enumeration value="NOTIFY"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="inheritance-type">
<xs:restriction base="xs:token">

View File

@ -239,29 +239,6 @@ class Configuration extends \Doctrine\DBAL\Configuration
$this->_attributes['metadataCacheImpl'] = $cacheImpl;
}
/**
* Gets a boolean flag that indicates whether Doctrine should make use of the
* C extension.
*
* @return boolean TRUE if Doctrine is configured to use the C extension, FALSE otherwise.
*/
public function getUseCExtension()
{
return isset($this->_attributes['useCExtension']) ?
$this->_attributes['useCExtension'] : false;
}
/**
* Sets a boolean flag that indicates whether Doctrine should make use of the
* C extension.
*
* @param boolean $boolean Whether to make use of the C extension or not.
*/
public function setUseCExtension($boolean)
{
$this->_attributes['useCExtension'] = $boolean;
}
/**
* Adds a named DQL query to the configuration.
*

View File

@ -169,23 +169,30 @@ class AnnotationDriver implements Driver
if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) {
$inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType'];
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
// Evaluate DiscriminatorColumn annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'])) {
$discrColumnAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'];
$metadata->setDiscriminatorColumn(array(
'name' => $discrColumnAnnot->name,
'type' => $discrColumnAnnot->type,
'length' => $discrColumnAnnot->length
));
} else {
throw MappingException::missingDiscriminatorColumn($className);
}
// Evaluate DiscriminatorMap annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorMap'])) {
$discrMapAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorMap'];
$metadata->setDiscriminatorMap($discrMapAnnot->value);
} else {
throw MappingException::missingDiscriminatorMap($className);
}
}
}
// Evaluate DiscriminatorColumn annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'])) {
$discrColumnAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'];
$metadata->setDiscriminatorColumn(array(
'name' => $discrColumnAnnot->name,
'type' => $discrColumnAnnot->type,
'length' => $discrColumnAnnot->length
));
}
// Evaluate DiscriminatorMap annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorMap'])) {
$discrMapAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorMap'];
$metadata->setDiscriminatorMap($discrMapAnnot->value);
}
// Evaluate DoctrineChangeTrackingPolicy annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'])) {

View File

@ -77,31 +77,38 @@ class XmlDriver extends AbstractFileDriver
if (isset($xmlRoot['inheritance-type'])) {
$inheritanceType = (string)$xmlRoot['inheritance-type'];
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType));
}
// Evaluate <discriminator-column...>
if (isset($xmlRoot->{'discriminator-column'})) {
$discrColumn = $xmlRoot->{'discriminator-column'};
$metadata->setDiscriminatorColumn(array(
'name' => (string)$discrColumn['name'],
'type' => (string)$discrColumn['type'],
'length' => (string)$discrColumn['length']
));
}
if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
// Evaluate <discriminator-column...>
if (isset($xmlRoot->{'discriminator-column'})) {
$discrColumn = $xmlRoot->{'discriminator-column'};
$metadata->setDiscriminatorColumn(array(
'name' => (string)$discrColumn['name'],
'type' => (string)$discrColumn['type'],
'length' => (string)$discrColumn['length']
));
} else {
throw MappingException::missingDiscriminatorColumn($className);
}
// Evaluate <discriminator-map...>
if (isset($xmlRoot->{'discriminator-map'})) {
$map = array();
foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} AS $discrMapElement) {
$map[(string)$discrMapElement['value']] = (string)$discrMapElement['class'];
// Evaluate <discriminator-map...>
if (isset($xmlRoot->{'discriminator-map'})) {
$map = array();
foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} AS $discrMapElement) {
$map[(string)$discrMapElement['value']] = (string)$discrMapElement['class'];
}
$metadata->setDiscriminatorMap($map);
} else {
throw MappingException::missingDiscriminatorMap($className);
}
}
$metadata->setDiscriminatorMap($map);
}
// Evaluate <change-tracking-policy...>
if (isset($xmlRoot->{'change-tracking-policy'})) {
if (isset($xmlRoot['change-tracking-policy'])) {
$metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_'
. strtoupper((string)$xmlRoot->{'change-tracking-policy'})));
. strtoupper((string)$xmlRoot['change-tracking-policy'])));
}
// Evaluate <indexes...>

View File

@ -69,22 +69,29 @@ class YamlDriver extends AbstractFileDriver
if (isset($element['inheritanceType'])) {
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
// Evaluate discriminatorColumn
if (isset($element['discriminatorColumn'])) {
$discrColumn = $element['discriminatorColumn'];
$metadata->setDiscriminatorColumn(array(
'name' => $discrColumn['name'],
'type' => $discrColumn['type'],
'length' => $discrColumn['length']
));
} else {
throw MappingException::missingDiscriminatorColumn($className);
}
// Evaluate discriminatorMap
if (isset($element['discriminatorMap'])) {
$metadata->setDiscriminatorMap($element['discriminatorMap']);
} else {
throw MappingException::missingDiscriminatorMap($className);
}
}
}
// Evaluate discriminatorColumn
if (isset($element['discriminatorColumn'])) {
$discrColumn = $element['discriminatorColumn'];
$metadata->setDiscriminatorColumn(array(
'name' => $discrColumn['name'],
'type' => $discrColumn['type'],
'length' => $discrColumn['length']
));
}
// Evaluate discriminatorMap
if (isset($element['discriminatorMap'])) {
$metadata->setDiscriminatorMap($element['discriminatorMap']);
}
// Evaluate changeTrackingPolicy
if (isset($element['changeTrackingPolicy'])) {

View File

@ -190,6 +190,16 @@ class MappingException extends \Doctrine\ORM\ORMException
);
}
public static function missingDiscriminatorMap($className)
{
return new self("Entity class '$className' is using inheritance but no discriminator map was defined.");
}
public static function missingDiscriminatorColumn($className)
{
return new self("Entity class '$className' is using inheritance but no discriminator column was defined.");
}
/**
* @param string $className
* @param string $columnName

View File

@ -74,8 +74,12 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
$class = $this->_declaringClassMap[$column];
if ($class->name == $entityName || is_subclass_of($entityName, $class->name)) {
$field = $class->fieldNames[$realColumnName];
$data[$field] = Type::getType($class->fieldMappings[$field]['type'])
->convertToPHPValue($value, $this->_platform);
if (isset($data[$field])) {
$data[$realColumnName] = $value;
} else {
$data[$field] = Type::getType($class->fieldMappings[$field]['type'])
->convertToPHPValue($value, $this->_platform);
}
}
} else {
$data[$realColumnName] = $value;

View File

@ -800,8 +800,12 @@ class BasicEntityPersister
$column = $this->_resultColumnNames[$column];
if (isset($this->_class->fieldNames[$column])) {
$field = $this->_class->fieldNames[$column];
$data[$field] = Type::getType($this->_class->fieldMappings[$field]['type'])
->convertToPHPValue($value, $this->_platform);
if (isset($data[$field])) {
$data[$column] = $value;
} else {
$data[$field] = Type::getType($this->_class->fieldMappings[$field]['type'])
->convertToPHPValue($value, $this->_platform);
}
} else {
$data[$column] = $value;
}

View File

@ -105,6 +105,11 @@ class ProxyFactory
$proxyDir = $toDir ?: $this->_proxyDir;
$proxyDir = rtrim($proxyDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
foreach ($classes as $class) {
/* @var $class ClassMetadata */
if ($class->isMappedSuperclass) {
continue;
}
$proxyClassName = str_replace('\\', '', $class->name) . 'Proxy';
$proxyFileName = $proxyDir . $proxyClassName . '.php';
$this->_generateProxyClass($class, $proxyClassName, $proxyFileName, self::$_proxyClassTemplate);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class AbsFunction extends FunctionNode
{
@ -53,8 +51,6 @@ class AbsFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class ConcatFunction extends FunctionNode
{
@ -56,8 +54,6 @@ class ConcatFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class CurrentDateFunction extends FunctionNode
{
@ -49,8 +47,6 @@ class CurrentDateFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(Lexer::T_CLOSE_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class CurrentTimeFunction extends FunctionNode
{
@ -49,8 +47,6 @@ class CurrentTimeFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(Lexer::T_CLOSE_PARENTHESIS);

View File

@ -1,7 +1,20 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
/*
* 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
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST\Functions;
@ -11,7 +24,13 @@ use Doctrine\ORM\Query\Lexer;
/**
* "CURRENT_TIMESTAMP"
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class CurrentTimestampFunction extends FunctionNode
{
@ -28,8 +47,6 @@ class CurrentTimestampFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(Lexer::T_CLOSE_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\AST\Node;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
abstract class FunctionNode extends Node
{

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class LengthFunction extends FunctionNode
{
@ -52,8 +50,6 @@ class LengthFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class LocateFunction extends FunctionNode
{
@ -61,8 +59,6 @@ class LocateFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
@ -72,6 +68,7 @@ class LocateFunction extends FunctionNode
$this->secondStringPrimary = $parser->StringPrimary();
$lexer = $parser->getLexer();
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class LowerFunction extends FunctionNode
{
@ -52,8 +50,6 @@ class LowerFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class ModFunction extends FunctionNode
{
@ -57,8 +55,6 @@ class ModFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_MOD);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -29,7 +27,6 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class SqrtFunction extends FunctionNode
{
@ -52,8 +50,6 @@ class SqrtFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class SubstringFunction extends FunctionNode
{
@ -62,8 +60,6 @@ class SubstringFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
@ -73,6 +69,7 @@ class SubstringFunction extends FunctionNode
$this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
$lexer = $parser->getLexer();
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);

View File

@ -1,7 +1,5 @@
<?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
@ -30,10 +28,10 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class TrimFunction extends FunctionNode
{

View File

@ -1,7 +1,5 @@
<?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
@ -29,10 +27,10 @@ use Doctrine\ORM\Query\Lexer;
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class UpperFunction extends FunctionNode
{
@ -52,8 +50,6 @@ class UpperFunction extends FunctionNode
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -1,7 +1,5 @@
<?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
@ -172,6 +170,16 @@ class SchemaValidator
}
}
}
if (isset($assoc->orderBy) && $assoc->orderBy !== null) {
$targetClass = $cmf->getMetadataFor($assoc->targetEntityName);
foreach ($assoc->orderBy AS $orderField => $orientation) {
if (!$targetClass->hasField($orderField)) {
$ce[] = "The association " . $class->name."#".$fieldName." is ordered by a foreign field " .
$orderField . " that is not a field on the target entity " . $targetClass->name;
}
}
}
}
foreach ($class->reflClass->getProperties(\ReflectionProperty::IS_PUBLIC) as $publicAttr) {

View File

@ -200,15 +200,6 @@ class UnitOfWork implements PropertyChangedListener
* @var array
*/
private $collectionPersisters = array();
/**
* EXPERIMENTAL:
* Flag for whether or not to make use of the C extension which is an experimental
* library that aims to improve the performance of some critical code sections.
*
* @var boolean
*/
private $useCExtension = false;
/**
* The EventManager used for dispatching events.
@ -235,7 +226,6 @@ class UnitOfWork implements PropertyChangedListener
{
$this->em = $em;
$this->evm = $em->getEventManager();
$this->useCExtension = $this->em->getConfiguration()->getUseCExtension();
}
/**
@ -1812,13 +1802,13 @@ class UnitOfWork implements PropertyChangedListener
/**
* INTERNAL:
* Creates an entity. Used for reconstitution of entities during hydration.
* Creates an entity. Used for reconstitution of persistent entities.
*
* @ignore
* @param string $className The name of the entity class.
* @param array $data The data for the entity.
* @param array $hints Any hints to account for during reconstitution/lookup of the entity.
* @return object The entity instance.
* @return object The managed entity instance.
* @internal Highly performance-sensitive method.
*
* @todo Rename: getOrCreateEntity
@ -1874,13 +1864,9 @@ class UnitOfWork implements PropertyChangedListener
}
if ($overrideLocalValues) {
if ($this->useCExtension) {
doctrine_populate_data($entity, $data);
} else {
foreach ($data as $field => $value) {
if (isset($class->reflFields[$field])) {
$class->reflFields[$field]->setValue($entity, $value);
}
foreach ($data as $field => $value) {
if (isset($class->fieldMappings[$field])) {
$class->reflFields[$field]->setValue($entity, $value);
}
}
@ -1920,7 +1906,13 @@ class UnitOfWork implements PropertyChangedListener
// If it might be a subtype, it can not be lazy
$newValue = $assoc->load($entity, null, $this->em, $associatedId);
} else {
$newValue = $this->em->getProxyFactory()->getProxy($assoc->targetEntityName, $associatedId);
if ($assoc->fetchMode == Mapping\AssociationMapping::FETCH_EAGER) {
// TODO: Maybe it could be optimized to do an eager fetch with a JOIN inside
// the persister instead of this rather unperformant approach.
$newValue = $this->em->find($assoc->targetEntityName, $associatedId);
} else {
$newValue = $this->em->getProxyFactory()->getProxy($assoc->targetEntityName, $associatedId);
}
// PERF: Inlined & optimized code from UnitOfWork#registerManaged()
$newValueOid = spl_object_hash($newValue);
$this->entityIdentifiers[$newValueOid] = $associatedId;

View File

@ -0,0 +1,104 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\Models\Company\CompanyPerson;
require_once __DIR__ . '/../../../TestInit.php';
/**
* Tests that join columns (foreign keys) can be named the same as the association
* fields they're used on without causing issues.
*/
class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
try {
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522Customer'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522Cart'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522ForeignKeyTest')
));
} catch(\Exception $e) {
}
}
/**
* @group DDC-522
*/
public function testJoinColumnWithSameNameAsAssociationField()
{
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$cust = new DDC522Customer;
$cust->name = "name";
$cart = new DDC522Cart;
$cart->total = 0;
$cust->cart = $cart;
$cart->customer = $cust;
$this->_em->persist($cust);
$this->_em->persist($cart);
$this->_em->flush();
$this->_em->clear();
$r = $this->_em->createQuery("select ca,c from ".get_class($cart)." ca join ca.customer c")
->getResult();
$this->assertTrue($r[0] instanceof DDC522Cart);
$this->assertTrue($r[0]->customer instanceof DDC522Customer);
$this->assertFalse($r[0]->customer instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertEquals('name', $r[0]->customer->name);
$fkt = new DDC522ForeignKeyTest();
$fkt->cartId = $r[0]->id; // ignored for persistence
$fkt->cart = $r[0]; // must be set properly
$this->_em->persist($fkt);
$this->_em->flush();
$this->_em->clear();
$fkt2 = $this->_em->find(get_class($fkt), $fkt->id);
$this->assertEquals($fkt->cart->id, $fkt2->cartId);
$this->assertTrue($fkt2->cart instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertFalse($fkt2->cart->__isInitialized__);
}
}
/** @Entity */
class DDC522Customer {
/** @Id @Column(type="integer") @GeneratedValue */
public $id;
/** @Column */
public $name;
/** @OneToOne(targetEntity="DDC522Cart", mappedBy="customer") */
public $cart;
}
/** @Entity */
class DDC522Cart {
/** @Id @Column(type="integer") @GeneratedValue */
public $id;
/** @Column(type="integer") */
public $total;
/**
* @OneToOne(targetEntity="DDC522Customer", inversedBy="cart")
* @JoinColumn(name="customer", referencedColumnName="id")
*/
public $customer;
}
/** @Entity */
class DDC522ForeignKeyTest {
/** @Id @Column(type="integer") @GeneratedValue */
public $id;
/** @Column(type="integer", name="cart_id") */
public $cartId;
/**
* @OneToOne(targetEntity="DDC522Cart")
* @JoinColumn(name="cart_id", referencedColumnName="id")
*/
public $cart;
}

View File

@ -0,0 +1,69 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use DateTime;
require_once __DIR__ . '/../../../TestInit.php';
class DDC633Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
try {
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC633Patient'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC633Appointment'),
));
} catch(\Exception $e) {
}
}
public function testOneToOneEager()
{
$app = new DDC633Appointment();
$pat = new DDC633Patient();
$app->patient = $pat;
$pat->appointment = $app;
$this->_em->persist($app);
$this->_em->persist($pat);
$this->_em->flush();
$this->_em->clear();
$eagerAppointment = $this->_em->find(__NAMESPACE__ . '\DDC633Appointment', $app->id);
$this->assertNotType('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient);
}
}
/**
* @Entity
*/
class DDC633Appointment
{
/** @Id @Column(type="integer") @GeneratedValue */
public $id;
/**
* @OneToOne(targetEntity="DDC633Patient", inversedBy="appointment", fetch="EAGER")
*/
public $patient;
}
/**
* @Entity
*/
class DDC633Patient
{
/** @Id @Column(type="integer") @GeneratedValue */
public $id;
/**
* @OneToOne(targetEntity="DDC633Appointment", mappedBy="patient")
*/
public $appointment;
}

View File

@ -28,9 +28,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest
public function testColumnWithMissingTypeDefaultsToString()
{
$cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ColumnWithoutType');
$reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
$annotationDriver = $this->_loadDriver();
$annotationDriver->loadMetadataForClass('Doctrine\Tests\ORM\Mapping\InvalidColumn', $cm);
$this->assertEquals('string', $cm->fieldMappings['id']['type']);
@ -92,6 +90,24 @@ class AnnotationDriverTest extends AbstractMappingDriverTest
$this->assertNotContains($extraneousClassName, $classes);
}
public function testInheritenceWithoutDiscriminatorMap()
{
$cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ClassWithoutDiscriminatorMap');
$annotationDriver = $this->_loadDriver();
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException");
$annotationDriver->loadMetadataForClass($cm->name, $cm);
}
public function testInheritenceWithoutDiscriminatorColumn()
{
$cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ClassWithoutDiscriminatorColumn');
$annotationDriver = $this->_loadDriver();
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException");
$annotationDriver->loadMetadataForClass($cm->name, $cm);
}
protected function _loadDriverForCMSModels()
{
$annotationDriver = $this->_loadDriver();
@ -121,3 +137,25 @@ class ColumnWithoutType
/** @Id @Column */
public $id;
}
/**
* @Entity
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorMap({"a" = "ClassWithoutDiscriminatorColumn"})
*/
class ClassWithoutDiscriminatorColumn
{
/** @Id @Column */
public $id;
}
/**
* @Entity
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="discr", type="string")
*/
class ClassWithoutDiscriminatorMap
{
/** @Id @Column */
public $id;
}

View File

@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\ORM\Mapping\CTI">
<entity name="Doctrine\Tests\ORM\Mapping\CTI" inheritance-type="JOINED">
<discriminator-column name="discr" type="string" length="60"/>
<discriminator-map>
<discriminator-mapping value="foo" class="CTIFoo"/>