Commit b5401ee1 authored by romanb's avatar romanb

checkin of occasional work from the past weeks.

parent 9c1c82ca
...@@ -103,13 +103,21 @@ class Doctrine_Association implements Serializable ...@@ -103,13 +103,21 @@ class Doctrine_Association implements Serializable
protected $_sourceFieldName; protected $_sourceFieldName;
/** /**
* Identifies the field on the owning side that has the mapping for the * Identifies the field on the owning side that controls the mapping for the
* association. This is only set on the inverse side of an association. * association. This is only set on the inverse side of an association.
* *
* @var string * @var string
*/ */
protected $_mappedByFieldName; protected $_mappedByFieldName;
/**
* Identifies the field on the inverse side of a bidirectional association.
* This is only set on the owning side of an association.
*
* @var string
*/
//protected $_inverseSideFieldName;
/** /**
* The name of the join table, if any. * The name of the join table, if any.
* *
...@@ -127,7 +135,16 @@ class Doctrine_Association implements Serializable ...@@ -127,7 +135,16 @@ class Doctrine_Association implements Serializable
*/ */
public function __construct(array $mapping) public function __construct(array $mapping)
{ {
/*$this->_mapping = array( //$this->_initMappingArray();
//$mapping = $this->_validateAndCompleteMapping($mapping);
//$this->_mapping = array_merge($this->_mapping, $mapping);*/
$this->_validateAndCompleteMapping($mapping);
}
protected function _initMappingArray()
{
$this->_mapping = array(
'fieldName' => null, 'fieldName' => null,
'sourceEntity' => null, 'sourceEntity' => null,
'targetEntity' => null, 'targetEntity' => null,
...@@ -137,10 +154,8 @@ class Doctrine_Association implements Serializable ...@@ -137,10 +154,8 @@ class Doctrine_Association implements Serializable
'accessor' => null, 'accessor' => null,
'mutator' => null, 'mutator' => null,
'optional' => true, 'optional' => true,
'cascade' => array() 'cascades' => array()
); );
$this->_mapping = array_merge($this->_mapping, $mapping);*/
$this->_validateAndCompleteMapping($mapping);
} }
/** /**
...@@ -342,6 +357,36 @@ class Doctrine_Association implements Serializable ...@@ -342,6 +357,36 @@ class Doctrine_Association implements Serializable
return $this->_mappedByFieldName; return $this->_mappedByFieldName;
} }
/*public function getInverseSideFieldName()
{
return $this->_inverseSideFieldName;
}*/
/**
* Marks the association as bidirectional, specifying the field name of
* the inverse side.
* This is called on the owning side, when an inverse side is discovered.
* This does only make sense to call on the owning side.
*
* @param string $inverseSideFieldName
*/
/*public function setBidirectional($inverseSideFieldName)
{
if ( ! $this->_isOwningSide) {
return; //TODO: exception?
}
$this->_inverseSideFieldName = $inverseSideFieldName;
}*/
/**
* Whether the association is bidirectional.
*
* @return boolean
*/
/*public function isBidirectional()
{
return $this->_mappedByFieldName || $this->_inverseSideFieldName;
}*/
/** /**
* Whether the source field of the association has a custom accessor. * Whether the source field of the association has a custom accessor.
* *
......
...@@ -65,6 +65,12 @@ class Doctrine_Association_OneToOne extends Doctrine_Association ...@@ -65,6 +65,12 @@ class Doctrine_Association_OneToOne extends Doctrine_Association
parent::__construct($mapping); parent::__construct($mapping);
} }
protected function _initMappingArray()
{
parent::_initMappingArray();
$this->_mapping['deleteOrphans'] = false;
}
/** /**
* Validates & completes the mapping. Mapping defaults are applied here. * Validates & completes the mapping. Mapping defaults are applied here.
* *
......
...@@ -666,7 +666,7 @@ END; ...@@ -666,7 +666,7 @@ END;
*/ */
public function buildRecord(array $definition) public function buildRecord(array $definition)
{ {
if ( !isset($definition['className'])) { if ( ! isset($definition['className'])) {
throw new Doctrine_Builder_Exception('Missing class name.'); throw new Doctrine_Builder_Exception('Missing class name.');
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
* The Configuration is the container for all configuration options of Doctrine. * The Configuration is the container for all configuration options of Doctrine.
* It combines all configuration options from DBAL & ORM. * It combines all configuration options from DBAL & ORM.
* *
* INTERNAL: When adding a new configuration option just write a getter/setter
* combination and add the option to the _attributes array with a proper default value.
*
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
*/ */
...@@ -36,6 +39,8 @@ class Doctrine_Configuration ...@@ -36,6 +39,8 @@ class Doctrine_Configuration
/** /**
* The attributes that are contained in the configuration. * The attributes that are contained in the configuration.
* Values are default values. PHP null is replaced by a reference to the Null
* object on instantiation in order to use isset() instead of array_key_exists().
* *
* @var array * @var array
*/ */
...@@ -44,12 +49,9 @@ class Doctrine_Configuration ...@@ -44,12 +49,9 @@ class Doctrine_Configuration
'indexNameFormat' => '%s_idx', 'indexNameFormat' => '%s_idx',
'sequenceNameFormat' => '%s_seq', 'sequenceNameFormat' => '%s_seq',
'tableNameFormat' => '%s', 'tableNameFormat' => '%s',
'resultCache' => null, 'resultCacheImpl' => null,
'resultCacheLifeSpan' => null, 'queryCacheImpl' => null,
'queryCache' => null, 'metadataCacheImpl' => null,
'queryCacheLifeSpan' => null,
'metadataCache' => null,
'metadataCacheLifeSpan' => null
); );
/** /**
...@@ -78,45 +80,100 @@ class Doctrine_Configuration ...@@ -78,45 +80,100 @@ class Doctrine_Configuration
} }
/** /**
* Gets the value of a configuration attribute. * Checks whether the configuration contains/supports an attribute.
* *
* @param string $name * @param string $name
* @return mixed * @return boolean
*/ */
public function get($name) public function has($name)
{ {
if ( ! $this->has($name)) { return isset($this->_attributes[$name]);
throw Doctrine_Configuration_Exception::unknownAttribute($name);
} }
if ($this->_attributes[$name] === $this->_nullObject) {
return null; public function getQuoteIdentifiers()
{
return $this->_attributes['quoteIdentifiers'];
} }
return $this->_attributes[$name];
public function setQuoteIdentifiers($bool)
{
$this->_attributes['quoteIdentifiers'] = (bool)$bool;
} }
/** public function getIndexNameFormat()
* Sets the value of a configuration attribute.
*
* @param string $name
* @param mixed $value
*/
public function set($name, $value)
{ {
if ( ! $this->has($name)) { return $this->_attributes['indexNameFormat'];
throw Doctrine_Configuration_Exception::unknownAttribute($name);
} }
// TODO: do some value checking depending on the attribute
$this->_attributes[$name] = $value; public function setIndexNameFormat($format)
{
//TODO: check format?
$this->_attributes['indexNameFormat'] = $format;
} }
/** public function getSequenceNameFormat()
* Checks whether the configuration contains/supports an attribute.
*
* @param string $name
* @return boolean
*/
public function has($name)
{ {
return isset($this->_attributes[$name]); return $this->_attributes['sequenceNameFormat'];
}
public function setSequenceNameFormat($format)
{
//TODO: check format?
$this->_attributes['sequenceNameFormat'] = $format;
}
public function getTableNameFormat()
{
return $this->_attributes['tableNameFormat'];
}
public function setTableNameFormat($format)
{
//TODO: check format?
$this->_attributes['tableNameFormat'] = $format;
}
public function getResultCacheImpl()
{
return $this->_attributes['resultCacheImpl'];
}
public function setResultCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['resultCacheImpl'] = $cacheImpl;
}
public function getQueryCacheImpl()
{
return $this->_attributes['queryCacheImpl'];
}
public function setQueryCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['queryCacheImpl'] = $cacheImpl;
}
public function getMetadataCacheImpl()
{
return $this->_attributes['metadataCacheImpl'];
}
public function setMetadataCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['metadataCacheImpl'] = $cacheImpl;
}
public function setCustomTypes(array $types)
{
foreach ($types as $name => $typeClassName) {
Doctrine_DataType::addCustomType($name, $typeClassName);
}
}
public function setTypeOverrides(array $overrides)
{
foreach ($override as $name => $typeClassName) {
Doctrine_DataType::overrideType($name, $typeClassName);
}
} }
} }
\ No newline at end of file
...@@ -180,13 +180,26 @@ abstract class Doctrine_Connection ...@@ -180,13 +180,26 @@ abstract class Doctrine_Connection
* *
* @param array $params The connection parameters. * @param array $params The connection parameters.
*/ */
public function __construct(array $params) public function __construct(array $params, $config = null, $eventManager = null)
{ {
if (isset($params['pdo'])) { if (isset($params['pdo'])) {
$this->_pdo = $params['pdo']; $this->_pdo = $params['pdo'];
$this->_isConnected = true; $this->_isConnected = true;
} }
$this->_params = $params; $this->_params = $params;
// Create default config and event manager if none given
if ( ! $config) {
$this->_config = new Doctrine_Configuration();
}
if ( ! $eventManager) {
$this->_eventManager = new Doctrine_EventManager();
}
// create platform
$class = "Doctrine_DatabasePlatform_" . $this->_driverName . "Platform";
$this->_platform = new $class();
$this->_platform->setQuoteIdentifiers($this->_config->getQuoteIdentifiers());
} }
/** /**
...@@ -242,8 +255,7 @@ abstract class Doctrine_Connection ...@@ -242,8 +255,7 @@ abstract class Doctrine_Connection
*/ */
public function getDatabasePlatform() public function getDatabasePlatform()
{ {
throw new Doctrine_Connection_Exception("No DatabasePlatform available " return $this->_platform;
. "for connection " . get_class($this));
} }
/** /**
...@@ -558,10 +570,12 @@ abstract class Doctrine_Connection ...@@ -558,10 +570,12 @@ abstract class Doctrine_Connection
* @param bool $checkOption check the 'quote_identifier' option * @param bool $checkOption check the 'quote_identifier' option
* *
* @return string quoted identifier string * @return string quoted identifier string
* @todo Moved to DatabasePlatform
* @deprecated
*/ */
public function quoteIdentifier($str, $checkOption = true) public function quoteIdentifier($str)
{ {
if (is_null($this->_quoteIdentifiers)) { /*if (is_null($this->_quoteIdentifiers)) {
$this->_quoteIdentifiers = $this->_config->get('quoteIdentifiers'); $this->_quoteIdentifiers = $this->_config->get('quoteIdentifiers');
} }
if ( ! $this->_quoteIdentifiers) { if ( ! $this->_quoteIdentifiers) {
...@@ -579,7 +593,8 @@ abstract class Doctrine_Connection ...@@ -579,7 +593,8 @@ abstract class Doctrine_Connection
$c = $this->_platform->getIdentifierQuoteCharacter(); $c = $this->_platform->getIdentifierQuoteCharacter();
$str = str_replace($c, $c . $c, $str); $str = str_replace($c, $c . $c, $str);
return $c . $str . $c; return $c . $str . $c;*/
return $this->getDatabasePlatform()->quoteIdentifier($str);
} }
/** /**
...@@ -590,6 +605,7 @@ abstract class Doctrine_Connection ...@@ -590,6 +605,7 @@ abstract class Doctrine_Connection
* *
* @param array $item * @param array $item
* @return void * @return void
* @deprecated Moved to DatabasePlatform
*/ */
public function convertBooleans($item) public function convertBooleans($item)
{ {
......
...@@ -191,17 +191,4 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common ...@@ -191,17 +191,4 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
return $dsn; return $dsn;
} }
/**
* Gets the DatabasePlatform for the connection.
*
* @return Doctrine::DBAL::Platforms::MySqlPlatform
*/
public function getDatabasePlatform()
{
if ( ! $this->_platform) {
$this->_platform = new Doctrine_DatabasePlatform_MySqlPlatform();
}
return $this->_platform;
}
} }
...@@ -71,6 +71,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common ...@@ -71,6 +71,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
* *
* @param array $item * @param array $item
* @return void * @return void
* @deprecated Moved to PostgreSqlPlatform
*/ */
public function convertBooleans($item) public function convertBooleans($item)
{ {
...@@ -94,7 +95,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common ...@@ -94,7 +95,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
* @param string $native determines if the raw version string should be returned * @param string $native determines if the raw version string should be returned
* @return array|string an array or string with version information * @return array|string an array or string with version information
*/ */
public function getServerVersion($native = false) /*public function getServerVersion($native = false)
{ {
$query = 'SHOW SERVER_VERSION'; $query = 'SHOW SERVER_VERSION';
...@@ -124,5 +125,5 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common ...@@ -124,5 +125,5 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
} }
} }
return $serverInfo; return $serverInfo;
} }*/
} }
\ No newline at end of file
...@@ -47,11 +47,45 @@ class Doctrine_ConnectionFactory ...@@ -47,11 +47,45 @@ class Doctrine_ConnectionFactory
'informix' => 'Doctrine_Connection_Informix', 'informix' => 'Doctrine_Connection_Informix',
'mock' => 'Doctrine_Connection_Mock'); 'mock' => 'Doctrine_Connection_Mock');
/**
* The EventManager that is injected into all created Connections.
*
* @var EventManager
*/
private $_eventManager;
/**
* The Configuration that is injected into all created Connections.
*
* @var Configuration
*/
private $_config;
public function __construct() public function __construct()
{ {
} }
/**
* Sets the Configuration that is injected into all Connections.
*
* @param Doctrine_Configuration $config
*/
public function setConfiguration(Doctrine_Configuration $config)
{
$this->_config = $config;
}
/**
* Sets the EventManager that is injected into all Connections.
*
* @param Doctrine_EventManager $eventManager
*/
public function setEventManager(Doctrine_EventManager $eventManager)
{
$this->_eventManager = $eventManager;
}
/** /**
* Creates a connection object with the specified parameters. * Creates a connection object with the specified parameters.
* *
...@@ -60,6 +94,14 @@ class Doctrine_ConnectionFactory ...@@ -60,6 +94,14 @@ class Doctrine_ConnectionFactory
*/ */
public function createConnection(array $params) public function createConnection(array $params)
{ {
// create default config and event manager, if not set
if ( ! $this->_config) {
$this->_config = new Doctrine_Configuration();
}
if ( ! $this->_eventManager) {
$this->_eventManager = new Doctrine_EventManager();
}
// check for existing pdo object // check for existing pdo object
if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) { if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) {
throw Doctrine_ConnectionFactory_Exception::invalidPDOInstance(); throw Doctrine_ConnectionFactory_Exception::invalidPDOInstance();
...@@ -70,7 +112,7 @@ class Doctrine_ConnectionFactory ...@@ -70,7 +112,7 @@ class Doctrine_ConnectionFactory
} }
$className = $this->_drivers[$params['driver']]; $className = $this->_drivers[$params['driver']];
return new $className($params); return new $className($params, $this->_config, $this->_eventManager);
} }
/** /**
......
<?php
#namespace Doctrine::DBAL::Types;
abstract class Doctrine_DataType
{
private static $_typeObjects = array();
private static $_typesMap = array(
'integer' => 'Doctrine_DataType_IntegerType',
'string' => 'Doctrine_DataType_StringType',
'text' => 'Doctrine_DataType_TextType',
'datetime' => 'Doctrine_DataType_DateTimeType',
'decimal' => 'Doctrine_DataType_DecimalType',
'double' => 'Doctrine_DataType_DoubleType'
);
public function convertToDatabaseValue($value, Doctrine_DatabasePlatform $platform)
{
return $value;
}
public function convertToObjectValue($value)
{
return $value;
}
abstract public function getDefaultLength(Doctrine_DatabasePlatform $platform);
abstract public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform);
abstract public function getName();
/**
* Factory method.
*
* @param string $name The name of the type (as returned by getName()).
* @return Doctrine::DBAL::Types::Type
*/
public static function getType($name)
{
if ( ! isset(self::$_typeObjects[$name])) {
if ( ! isset(self::$_typesMap[$name])) {
throw Doctrine_Exception::unknownType($name);
}
self::$_typeObjects[$name] = new self::$_typesMap[$name]();
}
return self::$_typeObjects[$name];
}
/**
* Adds a custom type to the type map.
*
* @param string $name Name of the type. This should correspond to what
* getName() returns.
* @param string $className The class name of the custom type.
*/
public static function addCustomType($name, $className)
{
if (isset(self::$_typesMap[$name])) {
throw Doctrine_Exception::typeExists($name);
}
self::$_typesMap[$name] = $className;
}
/**
* Overrides an already defined type to use a different implementation.
*
* @param string $name
* @param string $className
*/
public static function overrideType($name, $className)
{
if ( ! isset(self::$_typesMap[$name])) {
throw Doctrine_Exception::typeNotFound($name);
}
self::$_typesMap[$name] = $className;
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps PHP arrays to VARCHAR SQL type.
*
* @since 2.0
*/
class Doctrine_DataType_ArrayType extends Doctrine_DataType
{
public function getName()
{
return 'array';
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL boolean to a PHP boolean.
*
*/
class Doctrine_DataType_BooleanType extends Doctrine_DataType
{
/**
* Enter description here...
*
* @param unknown_type $value
* @override
*/
public function convertToDatabaseValue($value, Doctrine_DatabasePlatform $platform)
{
return $platform->convertBooleans($value);
}
/**
* Enter description here...
*
* @param unknown_type $value
* @return unknown
* @override
*/
public function convertToObjectValue($value)
{
return (bool)$value;
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL DATETIME to a PHP DateTime object.
*
* @since 2.0
*/
class Doctrine_DataType_DateTimeType extends Doctrine_DataType
{
/**
* Enter description here...
*
* @param unknown_type $value
* @param Doctrine_DatabasePlatform $platform
* @override
*/
public function convertToDatabaseValue($value, Doctrine_DatabasePlatform $platform)
{
//TODO: howto? dbms specific? delegate to platform?
}
/**
* Enter description here...
*
* @param string $value
* @return DateTime
* @override
*/
public function convertToObjectValue($value)
{
return new DateTime($value);
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL DECIMAL to a PHP double.
*
*/
class Doctrine_DataType_DecimalType extends Doctrine_DataType
{
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL INT/MEDIUMINT/BIGINT to a PHP integer.
*
*/
class Doctrine_DataType_IntegerType extends Doctrine_DataType
{
public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform)
{
}
}
?>
\ No newline at end of file
<?php
#namespace Doctrine::DBAL::Types;
/**
* Type that maps an SQL VARCHAR to a PHP string.
*
* @since 2.0
*/
class Doctrine_DataType_StringType extends Doctrine_DataType
{
public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform)
{
return $platform->getVarcharDeclaration($fieldDeclaration);
}
public function getDefaultLength(Doctrine_DatabasePlatform $platform)
{
return $platform->getVarcharDefaultLength();
}
public function getName()
{
return 'string';
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL CLOB to a PHP string.
*
* @since 2.0
*/
class Doctrine_DataType_TextType extends Doctrine_DataType
{
/**
* Enter description here...
*
* @param array $fieldDeclaration
* @param Doctrine_DatabasePlatform $platform
* @return unknown
* @override
*/
public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform)
{
return $platform->getClobDeclarationSql($fieldDeclaration);
}
}
?>
\ No newline at end of file
This diff is collapsed.
<?php
class Doctrine_DatabasePlatform_MockPlatform extends Doctrine_DatabasePlatform
{
public function getNativeDeclaration(array $field) {}
public function getPortableDeclaration(array $field) {}
}
?>
\ No newline at end of file
...@@ -429,8 +429,8 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable ...@@ -429,8 +429,8 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable
if ($this->_class->hasField($fieldName)) { if ($this->_class->hasField($fieldName)) {
$old = isset($this->_data[$fieldName]) ? $this->_data[$fieldName] : null; $old = isset($this->_data[$fieldName]) ? $this->_data[$fieldName] : null;
// NOTE: Common case: $old != $value. Special case: null == 0 (TRUE), which // NOTE: Common case: $old != $value. Special case: null == 0 (TRUE), which
// is addressed by the type comparison. // is addressed by xor.
if ($old != $value || gettype($old) != gettype($value)) { if ($old != $value || (is_null($old) xor is_null($value))) {
$this->_data[$fieldName] = $value; $this->_data[$fieldName] = $value;
$this->_dataChangeSet[$fieldName] = array($old => $value); $this->_dataChangeSet[$fieldName] = array($old => $value);
if ($this->isNew() && $this->_class->isIdentifier($fieldName)) { if ($this->isNew() && $this->_class->isIdentifier($fieldName)) {
...@@ -457,6 +457,9 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable ...@@ -457,6 +457,9 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable
} }
} }
/**
* Registers the entity as dirty with the UnitOfWork.
*/
private function _registerDirty() private function _registerDirty()
{ {
if ($this->_state == self::STATE_MANAGED && if ($this->_state == self::STATE_MANAGED &&
...@@ -531,35 +534,33 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable ...@@ -531,35 +534,33 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable
*/ */
final public function _internalSetReference($name, $value, $completeBidirectional = false) final public function _internalSetReference($name, $value, $completeBidirectional = false)
{ {
if ($value === Doctrine_Null::$INSTANCE) { if (is_null($value) || $value === Doctrine_Null::$INSTANCE) {
$this->_references[$name] = $value; $this->_references[$name] = $value;
return; return; // early exit!
} }
$rel = $this->_class->getAssociationMapping($name); $rel = $this->_class->getAssociationMapping($name);
if ($rel->isOneToOne() && ! $value instanceof Doctrine_Entity) { if ($rel->isOneToOne() && ! $value instanceof Doctrine_Entity) {
throw Doctrine_Entity_Exception::invalidValueForOneToOneReference(); throw Doctrine_Entity_Exception::invalidValueForOneToOneReference();
} } else if (($rel->isOneToMany() || $rel->isManyToMany()) && ! $value instanceof Doctrine_Collection) {
if ($rel->isOneToMany() && ! $value instanceof Doctrine_Collection) {
throw Doctrine_Entity_Exception::invalidValueForOneToManyReference(); throw Doctrine_Entity_Exception::invalidValueForOneToManyReference();
} }
if ($rel->isManyToMany() && ! $value instanceof Doctrine_Collection) {
throw Doctrine_Entity_Exception::invalidValueForManyToManyReference();
}
$this->_references[$name] = $value; $this->_references[$name] = $value;
if ($completeBidirectional && $rel->isOneToOne()) { if ($completeBidirectional && $rel->isOneToOne()) {
//TODO: check if $rel is bidirectional, if yes create the back-reference
if ($rel->isOwningSide()) { if ($rel->isOwningSide()) {
//TODO: how to check if its bidirectional? should be as efficient as possible // If there is an inverse mapping on the target class its bidirectional
/*$targetClass = $this->_em->getClassMetadata($rel->getTargetEntityName()); $targetClass = $this->_em->getClassMetadata($rel->getTargetEntityName());
if (($invAssoc = $targetClass->getInverseAssociation($name)) !== null) { if ($targetClass->hasInverseAssociationMapping($name)) {
$value->_internalSetReference($invAssoc->getSourceFieldName(), $this); $value->_internalSetReference(
}*/ $targetClass->getInverseAssociationMapping($name)->getSourceFieldName(),
$this
);
}
} else { } else {
// for sure bi-directional, as there is no inverse side in unidirectional // for sure bidirectional, as there is no inverse side in unidirectional
$value->_internalSetReference($rel->getMappedByFieldName(), $this); $value->_internalSetReference($rel->getMappedByFieldName(), $this);
} }
} }
......
...@@ -653,6 +653,35 @@ class Doctrine_EntityManager ...@@ -653,6 +653,35 @@ class Doctrine_EntityManager
return $this->_unitOfWork; return $this->_unitOfWork;
} }
/**
* Enter description here...
*
* @param unknown_type $type
* @param unknown_type $class
*/
/*public function getIdGenerator($class)
{
$type = $class->getIdGeneratorType();
if ($type == Doctrine_ClassMetadata::GENERATOR_TYPE_IDENTITY) {
if ( ! isset($this->_idGenerators[$type])) {
$this->_idGenerators[$type] = new Doctrine_Id_IdentityGenerator($this);
}
} else if ($type == Doctrine_ClassMetadata::GENERATOR_TYPE_SEQUENCE) {
if ( ! isset($this->_idGenerators[$type])) {
$this->_idGenerators[$type] = new Doctrine_Id_SequenceGenerator($this);
}
} else if ($type == Doctrine_ClassMetadata::GENERATOR_TYPE_TABLE) {
if ( ! isset($this->_idGenerators[$type])) {
$this->_idGenerators[$type] = new Doctrine_Id_TableGenerator($this);
}
}
$generator = $this->_idGenerators[$type];
$generator->configureForClass($class);
return $generator;
}*/
} }
?> ?>
\ No newline at end of file
...@@ -59,7 +59,7 @@ class Doctrine_EntityManagerFactory ...@@ -59,7 +59,7 @@ class Doctrine_EntityManagerFactory
*/ */
public function __construct() public function __construct()
{ {
$this->_connFactory = new Doctrine_ConnectionFactory();
} }
/** /**
...@@ -93,16 +93,20 @@ class Doctrine_EntityManagerFactory ...@@ -93,16 +93,20 @@ class Doctrine_EntityManagerFactory
*/ */
public function createEntityManager($connParams, $name = null) public function createEntityManager($connParams, $name = null)
{ {
if ( ! $this->_connFactory) {
// Initialize connection factory
$this->_connFactory = new Doctrine_ConnectionFactory();
if ( ! $this->_config) { if ( ! $this->_config) {
$this->_config = new Doctrine_Configuration(); $this->_config = new Doctrine_Configuration();
} }
if ( ! $this->_eventManager) { if ( ! $this->_eventManager) {
$this->_eventManager = new Doctrine_EventManager(); $this->_eventManager = new Doctrine_EventManager();
} }
$this->_connFactory->setConfiguration($this->_config);
$this->_connFactory->setEventManager($this->_eventManager);
}
$conn = $this->_connFactory->createConnection($connParams); $conn = $this->_connFactory->createConnection($connParams);
$conn->setEventManager($this->_eventManager);
$conn->setConfiguration($this->_config);
$em = new Doctrine_EntityManager($conn); $em = new Doctrine_EntityManager($conn);
$em->setEventManager($this->_eventManager); $em->setEventManager($this->_eventManager);
......
...@@ -123,6 +123,7 @@ abstract class Doctrine_EntityPersister_Abstract ...@@ -123,6 +123,7 @@ abstract class Doctrine_EntityPersister_Abstract
if ($class->isIdGeneratorIdentity()) { if ($class->isIdGeneratorIdentity()) {
//TODO: Postgres IDENTITY columns (SERIAL) use a sequence, so we need to pass the //TODO: Postgres IDENTITY columns (SERIAL) use a sequence, so we need to pass the
// sequence name to lastInsertId(). // sequence name to lastInsertId().
//TODO: $this->_em->getIdGenerator($class)->generate();
$entity->_assignIdentifier($this->_conn->lastInsertId()); $entity->_assignIdentifier($this->_conn->lastInsertId());
} }
} }
...@@ -312,6 +313,8 @@ abstract class Doctrine_EntityPersister_Abstract ...@@ -312,6 +313,8 @@ abstract class Doctrine_EntityPersister_Abstract
default: default:
$result[$columnName] = $newVal; $result[$columnName] = $newVal;
} }
/*$result[$columnName] = $type->convertToDatabaseValue(
$newVal, $this->_em->getConnection()->getDatabasePlatform());*/
} }
// @todo Cleanup // @todo Cleanup
......
...@@ -97,6 +97,8 @@ class Doctrine_EntityRepository ...@@ -97,6 +97,8 @@ class Doctrine_EntityRepository
$keys = $this->_classMetadata->getIdentifier(); $keys = $this->_classMetadata->getIdentifier();
} }
//TODO: check identity map?
return $this->_createQuery() return $this->_createQuery()
->where(implode(' = ? AND ', $keys) . ' = ?') ->where(implode(' = ? AND ', $keys) . ' = ?')
->fetchOne($values, $hydrationMode); ->fetchOne($values, $hydrationMode);
......
...@@ -73,7 +73,8 @@ class Doctrine_Hydrator_RecordDriver ...@@ -73,7 +73,8 @@ class Doctrine_Hydrator_RecordDriver
$relation = $entity->getClass()->getAssociationMapping($name); $relation = $entity->getClass()->getAssociationMapping($name);
$relatedClass = $this->_em->getClassMetadata($relation->getTargetEntityName()); $relatedClass = $this->_em->getClassMetadata($relation->getTargetEntityName());
$coll = $this->getElementCollection($relatedClass->getClassName()); $coll = $this->getElementCollection($relatedClass->getClassName());
$coll->setReference($entity, $relation); $coll->_setOwner($entity, $relation);
$coll->_setHydrationFlag(true);
$entity->_internalSetReference($name, $coll, true); $entity->_internalSetReference($name, $coll, true);
$this->_initializedRelations[$entity->getOid()][$name] = true; $this->_initializedRelations[$entity->getOid()][$name] = true;
} }
...@@ -145,7 +146,8 @@ class Doctrine_Hydrator_RecordDriver ...@@ -145,7 +146,8 @@ class Doctrine_Hydrator_RecordDriver
{ {
// take snapshots from all initialized collections // take snapshots from all initialized collections
foreach ($this->_collections as $coll) { foreach ($this->_collections as $coll) {
$coll->takeSnapshot(); $coll->_takeSnapshot();
$coll->_setHydrationFlag(false);
} }
$this->_collections = array(); $this->_collections = array();
$this->_initializedRelations = array(); $this->_initializedRelations = array();
......
...@@ -400,6 +400,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract ...@@ -400,6 +400,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$rowData[$dqlAlias][$fieldName] = $this->prepareValue( $rowData[$dqlAlias][$fieldName] = $this->prepareValue(
$class, $fieldName, $value, $cache[$key]['type']); $class, $fieldName, $value, $cache[$key]['type']);
} }
//$rowData[$dqlAlias][$fieldName] = $cache[$key]['type']->convertToObjectValue($value);
if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) { if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) {
$nonemptyComponents[$dqlAlias] = true; $nonemptyComponents[$dqlAlias] = true;
...@@ -468,6 +469,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract ...@@ -468,6 +469,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$rowData[$dqlAlias . '_' . $fieldName] = $this->prepareValue( $rowData[$dqlAlias . '_' . $fieldName] = $this->prepareValue(
$class, $fieldName, $value, $cache[$key]['type']); $class, $fieldName, $value, $cache[$key]['type']);
} }
//$rowData[$dqlAlias . '_' . $fieldName] = $cache[$key]['type']->convertToObjectValue($value);
} }
return $rowData; return $rowData;
......
<?php
#namespace Doctrine::DBAL::Id;
/**
* Enter description here...
*
* @todo Rename to AbstractIdGenerator
*/
abstract class Doctrine_Id_AbstractIdGenerator
{
protected $_em;
public function __construct(Doctrine_EntityManager $em)
{
$this->_em = $em;
}
abstract public function configureForClass(Doctrine_ClassMetadata $class);
abstract public function generate();
}
?>
\ No newline at end of file
<?php
class Doctrine_Id_IdentityGenerator extends Doctrine_Id_AbstractIdGenerator
{
public function generate(Doctrine_EntityManager $em)
{
}
}
?>
\ No newline at end of file
<?php
?>
\ No newline at end of file
<?php
?>
\ No newline at end of file
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* <http://www.phpdoctrine.org>. * <http://www.phpdoctrine.org>.
*/ */
#namespace Doctrine::DBAL::Import; #namespace Doctrine::ORM::Import;
/** /**
* class Doctrine_Import * class Doctrine_Import
...@@ -64,11 +64,11 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -64,11 +64,11 @@ class Doctrine_Import extends Doctrine_Connection_Module
$builder->setOptions($options); $builder->setOptions($options);
$classes = array(); $classes = array();
foreach ($connection->import->listTables() as $table) { foreach ($connection->getSchemaManager()->listTables() as $table) {
$definition = array(); $definition = array();
$definition['tableName'] = $table; $definition['tableName'] = $table;
$definition['className'] = Doctrine_Inflector::classify($table); $definition['className'] = Doctrine_Inflector::classify($table);
$definition['columns'] = $connection->import->listTableColumns($table); $definition['columns'] = $connection->getSchemaManager()->listTableColumns($table);
$builder->buildRecord($definition); $builder->buildRecord($definition);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* @subpackage Query * @subpackage Query
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 2.0
* @version $Revision: 1393 $ * @version $Revision: 1393 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
......
...@@ -238,7 +238,7 @@ class Doctrine_Query_Parser ...@@ -238,7 +238,7 @@ class Doctrine_Query_Parser
throw new Doctrine_Query_Parser_Exception(implode("\r\n", $this->_errors)); throw new Doctrine_Query_Parser_Exception(implode("\r\n", $this->_errors));
} }
// Assign the SQL executor in parser result // Assign the executor in parser result
$this->_parserResult->setSqlExecutor(Doctrine_Query_SqlExecutor_Abstract::create($AST)); $this->_parserResult->setSqlExecutor(Doctrine_Query_SqlExecutor_Abstract::create($AST));
return $this->_parserResult; return $this->_parserResult;
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
* <http://www.phpdoctrine.org>. * <http://www.phpdoctrine.org>.
*/ */
Doctrine::autoload('Doctrine_Query_AbstractResult');
/** /**
* Doctrine_Query_ParserResult * Doctrine_Query_ParserResult
* *
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
* <http://www.phpdoctrine.org>. * <http://www.phpdoctrine.org>.
*/ */
Doctrine::autoload('Doctrine_Query_AbstractResult');
/** /**
* Doctrine_Query_QueryResult * Doctrine_Query_QueryResult
* *
...@@ -30,7 +28,7 @@ Doctrine::autoload('Doctrine_Query_AbstractResult'); ...@@ -30,7 +28,7 @@ Doctrine::autoload('Doctrine_Query_AbstractResult');
* @author Janne Vanhala <jpvanhal@cc.hut.fi> * @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org * @link http://www.phpdoctrine.org
* @since 1.0 * @since 2.0
* @version $Revision$ * @version $Revision$
*/ */
class Doctrine_Query_QueryResult extends Doctrine_Query_AbstractResult class Doctrine_Query_QueryResult extends Doctrine_Query_AbstractResult
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* @link www.phpdoctrine.org * @link www.phpdoctrine.org
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @todo Remove
*/ */
class Doctrine_Query_Registry class Doctrine_Query_Registry
{ {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.phpdoctrine.org>.
*/ */
Doctrine::autoload('Doctrine_Query_Exception');
/** /**
* Doctrine_Query_Exception * Doctrine_Query_Exception
* *
...@@ -29,6 +29,7 @@ Doctrine::autoload('Doctrine_Query_Exception'); ...@@ -29,6 +29,7 @@ Doctrine::autoload('Doctrine_Query_Exception');
* @link www.phpdoctrine.org * @link www.phpdoctrine.org
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @todo Remove
*/ */
class Doctrine_Query_Registry_Exception extends Doctrine_Query_Exception class Doctrine_Query_Registry_Exception extends Doctrine_Query_Exception
{ } { }
\ No newline at end of file
...@@ -102,9 +102,7 @@ class Doctrine_Query_Scanner ...@@ -102,9 +102,7 @@ class Doctrine_Query_Scanner
foreach ($matches as $match) { foreach ($matches as $match) {
$value = $match[0]; $value = $match[0];
$type = $this->_getType($value); $type = $this->_getType($value);
$this->_tokens[] = array( $this->_tokens[] = array(
'value' => $value, 'value' => $value,
'type' => $type, 'type' => $type,
...@@ -130,7 +128,6 @@ class Doctrine_Query_Scanner ...@@ -130,7 +128,6 @@ class Doctrine_Query_Scanner
} else { } else {
$type = Doctrine_Query_Token::T_INTEGER; $type = Doctrine_Query_Token::T_INTEGER;
} }
} }
if ($value[0] === "'" && $value[strlen($value) - 1] === "'") { if ($value[0] === "'" && $value[strlen($value) - 1] === "'") {
$type = Doctrine_Query_Token::T_STRING; $type = Doctrine_Query_Token::T_STRING;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
* @link http://www.phpdoctrine.org * @link http://www.phpdoctrine.org
* @since 2.0 * @since 2.0
* @version $Revision$ * @version $Revision$
* @todo Merge into DatabasePlatform.
*/ */
abstract class Doctrine_Query_SqlBuilder abstract class Doctrine_Query_SqlBuilder
{ {
......
...@@ -28,10 +28,7 @@ ...@@ -28,10 +28,7 @@
* @link www.phpdoctrine.org * @link www.phpdoctrine.org
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @todo Give the tokenizer state, make it better work together with Doctrine_Query and maybe * @todo Remove.
* take out commonly used string manipulation methods
* into a stateless StringUtil? class. This tokenizer should be concerned with tokenizing
* DQL strings.
*/ */
class Doctrine_Query_Tokenizer class Doctrine_Query_Tokenizer
{ {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.phpdoctrine.org>.
*/ */
Doctrine::autoload('Doctrine_Exception');
/** /**
* Doctrine_Query_Exception * Doctrine_Query_Exception
* *
...@@ -29,6 +29,7 @@ Doctrine::autoload('Doctrine_Exception'); ...@@ -29,6 +29,7 @@ Doctrine::autoload('Doctrine_Exception');
* @since 1.0 * @since 1.0
* @version $Revision: 2702 $ * @version $Revision: 2702 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Remove
*/ */
class Doctrine_Query_Tokenizer_Exception extends Doctrine_Exception class Doctrine_Query_Tokenizer_Exception extends Doctrine_Exception
{ } { }
\ No newline at end of file
...@@ -299,7 +299,7 @@ class Doctrine_Schema_MsSqlSchemaManager extends Doctrine_Schema_SchemaManager ...@@ -299,7 +299,7 @@ class Doctrine_Schema_MsSqlSchemaManager extends Doctrine_Schema_SchemaManager
$val['type'] = $type; $val['type'] = $type;
$val['identity'] = $identity; $val['identity'] = $identity;
$decl = $this->conn->dataDict->getPortableDeclaration($val); $decl = $this->conn->getDatabasePlatform()->getPortableDeclaration($val);
$description = array( $description = array(
'name' => $val['column_name'], 'name' => $val['column_name'],
......
This diff is collapsed.
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* - terminals begin with a lower case character * - terminals begin with a lower case character
* - parentheses (...) are used for grouping * - parentheses (...) are used for grouping
* - square brackets [...] are used for defining an optional part, eg. zero or * - square brackets [...] are used for defining an optional part, eg. zero or
* one time time * one time
* - curly brackets {...} are used for repetion, eg. zero or more times * - curly brackets {...} are used for repetion, eg. zero or more times
* - double quotation marks "..." define a terminal string * - double quotation marks "..." define a terminal string
* - a vertical bar | represents an alternative * - a vertical bar | represents an alternative
...@@ -14,69 +14,69 @@ ...@@ -14,69 +14,69 @@
* Initially Select and Sub-select DQL will not support LIMIT and OFFSET (due to limit-subquery algorithm) * Initially Select and Sub-select DQL will not support LIMIT and OFFSET (due to limit-subquery algorithm)
*/ */
QueryLanguage = SelectStatement | UpdateStatement | DeleteStatement QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement
SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
UpdateStatement = UpdateClause [WhereClause] UpdateStatement ::= UpdateClause [WhereClause]
DeleteStatement = DeleteClause [WhereClause] DeleteStatement ::= DeleteClause [WhereClause]
Subselect = SimpleSelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] Subselect ::= SimpleSelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
SelectClause = "SELECT" ["ALL" | "DISTINCT"] SelectExpression {"," SelectExpression} SelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression {"," SelectExpression}*
SimpleSelectClause = "SELECT" ["ALL" | "DISTINCT"] SelectExpression SimpleSelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression
DeleteClause = "DELETE" ["FROM"] VariableDeclaration DeleteClause ::= "DELETE" ["FROM"] VariableDeclaration
WhereClause = "WHERE" ConditionalExpression WhereClause ::= "WHERE" ConditionalExpression
FromClause = "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration} FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}*
HavingClause = "HAVING" ConditionalExpression HavingClause ::= "HAVING" ConditionalExpression
GroupByClause = "GROUP" "BY" GroupByItem {"," GroupByItem} GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}*
OrderByClause = "ORDER" "BY" OrderByItem {"," OrderByItem} OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
LimitClause = "LIMIT" integer LimitClause ::= "LIMIT" integer
OffsetClause = "OFFSET" integer OffsetClause ::= "OFFSET" integer
UpdateClause = "UPDATE" VariableDeclaration "SET" UpdateItem {"," UpdateItem} UpdateClause ::= "UPDATE" VariableDeclaration "SET" UpdateItem {"," UpdateItem}*
OrderByItem = Expression ["ASC" | "DESC"] OrderByItem ::= Expression ["ASC" | "DESC"]
GroupByItem = PathExpression GroupByItem ::= PathExpression
UpdateItem = PathExpression "=" (Expression | "NULL") UpdateItem ::= PathExpression "=" (Expression | "NULL")
IdentificationVariableDeclaration = RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration} IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
JoinVariableDeclaration = Join [IndexBy] JoinVariableDeclaration ::= Join [IndexBy]
RangeVariableDeclaration = identifier {"." identifier} [["AS"] IdentificationVariable] RangeVariableDeclaration ::= identifier {"." identifier}* [["AS"] IdentificationVariable]
VariableDeclaration = identifier [["AS"] IdentificationVariable] VariableDeclaration ::= identifier [["AS"] IdentificationVariable]
IdentificationVariable = identifier IdentificationVariable ::= identifier
Join = ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression] Join ::= ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression]
IndexBy = "INDEX" "BY" identifier IndexBy ::= "INDEX" "BY" identifier
ConditionalExpression = ConditionalTerm {"OR" ConditionalTerm} ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}*
ConditionalTerm = ConditionalFactor {"AND" ConditionalFactor} ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}*
ConditionalFactor = ["NOT"] ConditionalPrimary ConditionalFactor ::= ["NOT"] ConditionalPrimary
ConditionalPrimary = SimpleConditionalExpression | "(" ConditionalExpression ")" ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"
SimpleConditionalExpression SimpleConditionalExpression
= Expression (ComparisonExpression | BetweenExpression | LikeExpression ::= Expression (ComparisonExpression | BetweenExpression | LikeExpression
| InExpression | NullComparisonExpression) | ExistsExpression | InExpression | NullComparisonExpression) | ExistsExpression
Atom = string | integer | float | boolean | input_parameter Atom ::= string | integer | float | boolean | input_parameter
Expression = Term {("+" | "-") Term} Expression ::= Term {("+" | "-") Term}*
Term = Factor {("*" | "/") Factor} Term ::= Factor {("*" | "/") Factor}*
Factor = [("+" | "-")] Primary Factor ::= [("+" | "-")] Primary
Primary = PathExpression | Atom | "(" Expression ")" | Function | AggregateExpression Primary ::= PathExpression | Atom | "(" Expression ")" | Function | AggregateExpression
SelectExpression = (PathExpressionEndingWithAsterisk | Expression | "(" Subselect ")" ) [["AS"] FieldIdentificationVariable] SelectExpression ::= (PathExpressionEndingWithAsterisk | Expression | "(" Subselect ")" ) [["AS"] FieldIdentificationVariable]
PathExpression = identifier {"." identifier} PathExpression ::= identifier {"." identifier}*
PathExpressionEndingWithAsterisk = {identifier "."} "*" PathExpressionEndingWithAsterisk ::= {identifier "."}* "*"
FieldIdentificationVariable = identifier FieldIdentificationVariable ::= identifier
AggregateExpression = ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] Expression ")" AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] Expression ")"
| "COUNT" "(" ["DISTINCT"] (Expression | "*") ")" | "COUNT" "(" ["DISTINCT"] (Expression | "*") ")"
QuantifiedExpression = ("ALL" | "ANY" | "SOME") "(" Subselect ")" QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
BetweenExpression = ["NOT"] "BETWEEN" Expression "AND" Expression BetweenExpression ::= ["NOT"] "BETWEEN" Expression "AND" Expression
ComparisonExpression = ComparisonOperator ( QuantifiedExpression | Expression | "(" Subselect ")" ) ComparisonExpression ::= ComparisonOperator ( QuantifiedExpression | Expression | "(" Subselect ")" )
InExpression = ["NOT"] "IN" "(" (Atom {"," Atom} | Subselect) ")" InExpression ::= ["NOT"] "IN" "(" (Atom {"," Atom}* | Subselect) ")"
LikeExpression = ["NOT"] "LIKE" Expression ["ESCAPE" string] LikeExpression ::= ["NOT"] "LIKE" Expression ["ESCAPE" string]
NullComparisonExpression = "IS" ["NOT"] "NULL" NullComparisonExpression ::= "IS" ["NOT"] "NULL"
ExistsExpression = "EXISTS" "(" Subselect ")" ExistsExpression ::= "EXISTS" "(" Subselect ")"
ComparisonOperator = "=" | "<" | "<=" | "<>" | ">" | ">=" | "!=" ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
Function = identifier "(" [Expression {"," Expression}] ")" Function ::= identifier "(" [Expression {"," Expression}*] ")"
...@@ -11,6 +11,7 @@ require_once 'Orm/Query/AllTests.php'; ...@@ -11,6 +11,7 @@ require_once 'Orm/Query/AllTests.php';
require_once 'Orm/Hydration/AllTests.php'; require_once 'Orm/Hydration/AllTests.php';
require_once 'Orm/Ticket/AllTests.php'; require_once 'Orm/Ticket/AllTests.php';
require_once 'Orm/Entity/AllTests.php'; require_once 'Orm/Entity/AllTests.php';
require_once 'Orm/Associations/AllTests.php';
// Tests // Tests
require_once 'Orm/UnitOfWorkTest.php'; require_once 'Orm/UnitOfWorkTest.php';
...@@ -39,6 +40,7 @@ class Orm_AllTests ...@@ -39,6 +40,7 @@ class Orm_AllTests
$suite->addTest(Orm_Hydration_AllTests::suite()); $suite->addTest(Orm_Hydration_AllTests::suite());
$suite->addTest(Orm_Entity_AllTests::suite()); $suite->addTest(Orm_Entity_AllTests::suite());
$suite->addTest(Orm_Ticket_AllTests::suite()); $suite->addTest(Orm_Ticket_AllTests::suite());
$suite->addTest(Orm_Associations_AllTests::suite());
return $suite; return $suite;
} }
......
<?php
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Orm_Associations_AllTests::main');
}
require_once 'lib/DoctrineTestInit.php';
// Tests
require_once 'Orm/Associations/OneToOneMappingTest.php';
class Orm_Associations_AllTests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new Doctrine_TestSuite('Doctrine Orm Associations');
$suite->addTestSuite('Orm_Associations_OneToOneMappingTest');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'Orm_Associations_AllTests::main') {
Orm_Associations_AllTests::main();
}
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class Doctrine_DatabasePlatformMock extends Doctrine_DatabasePlatform class Doctrine_DatabasePlatformMock extends Doctrine_DatabasePlatform
{ {
public function getNativeDeclaration($field) {} public function getNativeDeclaration(array $field) {}
public function getPortableDeclaration(array $field) {} public function getPortableDeclaration(array $field) {}
} }
......
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