1
0
mirror of synced 2025-01-31 12:32:59 +03:00

change quote strategy to interface

This commit is contained in:
Fabio B. Silva 2012-06-11 20:14:17 -03:00
parent b6b35d9482
commit 85b6f8dc2f
17 changed files with 189 additions and 202 deletions

View File

@ -26,6 +26,7 @@ use Doctrine\Common\Cache\Cache,
Doctrine\ORM\Mapping\Driver\Driver, Doctrine\ORM\Mapping\Driver\Driver,
Doctrine\ORM\Mapping\Driver\AnnotationDriver, Doctrine\ORM\Mapping\Driver\AnnotationDriver,
Doctrine\ORM\Mapping\NamingStrategy, Doctrine\ORM\Mapping\NamingStrategy,
Doctrine\ORM\Mapping\QuoteStrategy,
Doctrine\ORM\Mapping\DefaultNamingStrategy; Doctrine\ORM\Mapping\DefaultNamingStrategy;
/** /**
@ -631,32 +632,28 @@ class Configuration extends \Doctrine\DBAL\Configuration
} }
/** /**
* Set quote strategy class. * Set quote strategy.
* *
* @since 2.3 * @since 2.3
* @param string $className * @param Doctrine\ORM\Mapping\QuoteStrategy $quoteStrategy
*/ */
public function setQuoteStrategyClassName($className) public function setQuoteStrategy(QuoteStrategy $quoteStrategy)
{ {
$quoteStrategy = 'Doctrine\ORM\Mapping\QuoteStrategy'; $this->_attributes['quoteStrategy'] = $namingStrategy;
if ($className !== $quoteStrategy && ! is_subclass_of($className, $quoteStrategy)) {
throw new \InvalidArgumentException("Invalid quote strategy class");
}
$this->_attributes['quoteStrategyClassName'] = $namingStrategy;
} }
/** /**
* Get quote strategy class. * Get quote strategy.
* *
* @since 2.3 * @since 2.3
* @return string * @return Doctrine\ORM\Mapping\QuoteStrategy
*/ */
public function getQuoteStrategyClassName() public function getQuoteStrategy()
{ {
return isset($this->_attributes['quoteStrategyClassName']) if ( ! isset($this->_attributes['quoteStrategy'])) {
? $this->_attributes['quoteStrategyClassName'] $this->_attributes['quoteStrategy'] = new \Doctrine\ORM\Mapping\DefaultQuoteStrategy();
: 'Doctrine\ORM\Mapping\DefaultQuoteStrategy'; }
return $this->_attributes['quoteStrategy'];
} }
} }

View File

@ -62,13 +62,6 @@ class EntityManager implements ObjectManager
*/ */
private $metadataFactory; private $metadataFactory;
/**
* The quote strategy.
*
* @var \Doctrine\ORM\Mapping\QuoteStrategy.
*/
private $quoteStrategy;
/** /**
* The EntityRepository instances. * The EntityRepository instances.
* *
@ -140,7 +133,7 @@ class EntityManager implements ObjectManager
$this->eventManager = $eventManager; $this->eventManager = $eventManager;
$metadataFactoryClassName = $config->getClassMetadataFactoryName(); $metadataFactoryClassName = $config->getClassMetadataFactoryName();
$this->metadataFactory = new $metadataFactoryClassName; $this->metadataFactory = new $metadataFactoryClassName;
$this->metadataFactory->setEntityManager($this); $this->metadataFactory->setEntityManager($this);
$this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl()); $this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl());
@ -174,21 +167,6 @@ class EntityManager implements ObjectManager
return $this->metadataFactory; return $this->metadataFactory;
} }
/**
* Gets the quote strategy.
*
* @return \Doctrine\ORM\Mapping\QuoteStrategy
*/
public function getQuoteStrategy()
{
if ($this->quoteStrategy === null) {
$className = $this->getConfiguration()->getQuoteStrategyClassName();
$this->quoteStrategy = new $className($this->getConnection()->getDatabasePlatform());
}
return $this->quoteStrategy;
}
/** /**
* Gets an ExpressionBuilder used for object-oriented construction of query expressions. * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
* *

View File

@ -660,7 +660,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
if ($quoted) { if ($quoted) {
$definition['quoted'] = true; $definition['quoted'] = true;
} }
$sequenceName = $this->em->getQuoteStrategy()->getSequenceName($definition, $class); $sequenceName = $this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->targetPlatform);
} }
$class->setIdGenerator(new \Doctrine\ORM\Id\IdentityGenerator($sequenceName)); $class->setIdGenerator(new \Doctrine\ORM\Id\IdentityGenerator($sequenceName));
break; break;
@ -681,7 +681,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
$class->setSequenceGeneratorDefinition($definition); $class->setSequenceGeneratorDefinition($definition);
} }
$sequenceGenerator = new \Doctrine\ORM\Id\SequenceGenerator( $sequenceGenerator = new \Doctrine\ORM\Id\SequenceGenerator(
$this->em->getQuoteStrategy()->getSequenceName($definition, $class), $this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->targetPlatform),
$definition['allocationSize'] $definition['allocationSize']
); );
$class->setIdGenerator($sequenceGenerator); $class->setIdGenerator($sequenceGenerator);

View File

@ -19,6 +19,8 @@
namespace Doctrine\ORM\Mapping; namespace Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\DBAL\Platforms\AbstractPlatform;
/** /**
* A set of rules for determining the physical column, alias and table quotes * A set of rules for determining the physical column, alias and table quotes
@ -26,85 +28,84 @@ namespace Doctrine\ORM\Mapping;
* @since 2.3 * @since 2.3
* @author Fabio B. Silva <fabio.bat.silva@gmail.com> * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/ */
class DefaultQuoteStrategy extends QuoteStrategy class DefaultQuoteStrategy implements QuoteStrategy
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getColumnName($fieldName, ClassMetadata $class) public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform)
{ {
return isset($class->fieldMappings[$fieldName]['quoted']) return isset($class->fieldMappings[$fieldName]['quoted'])
? $this->platform->quoteIdentifier($class->fieldMappings[$fieldName]['columnName']) ? $platform->quoteIdentifier($class->fieldMappings[$fieldName]['columnName'])
: $class->fieldMappings[$fieldName]['columnName']; : $class->fieldMappings[$fieldName]['columnName'];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getTableName(ClassMetadata $class) public function getTableName(ClassMetadata $class, AbstractPlatform $platform)
{ {
return isset($class->table['quoted']) return isset($class->table['quoted'])
? $this->platform->quoteIdentifier($class->table['name']) ? $platform->quoteIdentifier($class->table['name'])
: $class->table['name']; : $class->table['name'];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSequenceName(array $definition, ClassMetadata $class) public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform)
{ {
return isset($definition['quoted']) return isset($definition['quoted'])
? $this->platform->quoteSingleIdentifier($definition['sequenceName']) ? $platform->quoteIdentifier($definition['sequenceName'])
: $definition['sequenceName']; : $definition['sequenceName'];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getJoinColumnName(array $joinColumn, ClassMetadata $class) public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform)
{ {
return isset($joinColumn['quoted']) return isset($joinColumn['quoted'])
? $this->platform->quoteIdentifier($joinColumn['name']) ? $platform->quoteIdentifier($joinColumn['name'])
: $joinColumn['name']; : $joinColumn['name'];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class) public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform)
{ {
return isset($joinColumn['quoted']) return isset($joinColumn['quoted'])
? $this->platform->quoteIdentifier($joinColumn['referencedColumnName']) ? $platform->quoteIdentifier($joinColumn['referencedColumnName'])
: $joinColumn['referencedColumnName']; : $joinColumn['referencedColumnName'];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getJoinTableName(array $association, ClassMetadata $class) public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform)
{ {
return isset($association['joinTable']['quoted']) return isset($association['joinTable']['quoted'])
? $this->platform->quoteIdentifier($association['joinTable']['name']) ? $platform->quoteIdentifier($association['joinTable']['name'])
: $association['joinTable']['name']; : $association['joinTable']['name'];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getIdentifierColumnNames(ClassMetadata $class) public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform)
{ {
$quotedColumnNames = array(); $quotedColumnNames = array();
foreach ($class->identifier as $fieldName) { foreach ($class->identifier as $fieldName) {
if (isset($class->fieldMappings[$fieldName])) { if (isset($class->fieldMappings[$fieldName])) {
$quotedColumnNames[] = $this->getColumnName($fieldName, $class); $quotedColumnNames[] = $this->getColumnName($fieldName, $class, $platform);
continue; continue;
} }
// Association defined as Id field // Association defined as Id field
$platform = $this->platform;
$joinColumns = $class->associationMappings[$fieldName]['joinColumns']; $joinColumns = $class->associationMappings[$fieldName]['joinColumns'];
$assocQuotedColumnNames = array_map( $assocQuotedColumnNames = array_map(
function ($joinColumn) use ($platform) { function ($joinColumn) use ($platform) {
@ -124,16 +125,16 @@ class DefaultQuoteStrategy extends QuoteStrategy
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getColumnAlias($columnName, $counter, ClassMetadata $class = null) public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = null)
{ {
// Trim the column alias to the maximum identifier length of the platform. // Trim the column alias to the maximum identifier length of the platform.
// If the alias is to long, characters are cut off from the beginning. // If the alias is to long, characters are cut off from the beginning.
// And strip non alphanumeric characters // And strip non alphanumeric characters
$columnName = $columnName . $counter; $columnName = $columnName . $counter;
$columnName = substr($columnName, -$this->platform->getMaxIdentifierLength()); $columnName = substr($columnName, -$platform->getMaxIdentifierLength());
$columnName = preg_replace('/[^A-Za-z0-9_]/', '', $columnName); $columnName = preg_replace('/[^A-Za-z0-9_]/', '', $columnName);
return $this->platform->getSQLResultCasing($columnName); return $platform->getSQLResultCasing($columnName);
} }
} }

View File

@ -23,95 +23,91 @@ use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
/** /**
* A set of rules for determining the physical column, alias and table quotes * A set of rules for determining the column, alias and table quotes
* *
* @since 2.3 * @since 2.3
* @author Fabio B. Silva <fabio.bat.silva@gmail.com> * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/ */
abstract class QuoteStrategy interface QuoteStrategy
{ {
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
protected $platform;
/**
* @param AbstractPlatform $platform
*/
public function __construct(AbstractPlatform $platform)
{
$this->platform = $platform;
}
/** /**
* Gets the (possibly quoted) column name for safe use in an SQL statement. * Gets the (possibly quoted) column name for safe use in an SQL statement.
* *
* @param string $fieldName * @param string $fieldName
* @param ClassMetadata $class * @param ClassMetadata $class
* @param AbstractPlatform $platform
* @return string * @return string
*/ */
abstract public function getColumnName($fieldName, ClassMetadata $class); function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform);
/** /**
* Gets the (possibly quoted) primary table name for safe use in an SQL statement. * Gets the (possibly quoted) primary table name for safe use in an SQL statement.
* *
* @param ClassMetadata $class * @param ClassMetadata $class
* @param AbstractPlatform $platform
* @return string * @return string
*/ */
abstract public function getTableName(ClassMetadata $class); function getTableName(ClassMetadata $class, AbstractPlatform $platform);
/** /**
* Gets the (possibly quoted) sequence name for safe use in an SQL statement. * Gets the (possibly quoted) sequence name for safe use in an SQL statement.
* *
* @param array $definition * @param array $definition
* @param ClassMetadata $class * @param ClassMetadata $class
* @param AbstractPlatform $platform
* @return string * @return string
*/ */
abstract public function getSequenceName(array $definition, ClassMetadata $class); function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform);
/** /**
* Gets the (possibly quoted) name of the join table. * Gets the (possibly quoted) name of the join table.
* *
* @param array $association * @param array $association
* @param ClassMetadata $class * @param ClassMetadata $class
* @param AbstractPlatform $platform
* @return string * @return string
*/ */
abstract public function getJoinTableName(array $association, ClassMetadata $class); function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform);
/** /**
* Gets the (possibly quoted) join column name. * Gets the (possibly quoted) join column name.
* *
* @param array $joinColumn * @param array $joinColumn
* @param ClassMetadata $class * @param ClassMetadata $class
* @param AbstractPlatform $platform
* @return string * @return string
*/ */
abstract public function getJoinColumnName(array $joinColumn, ClassMetadata $class); function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform);
/** /**
* Gets the (possibly quoted) join column name. * Gets the (possibly quoted) join column name.
* *
* @param array $joinColumn * @param array $joinColumn
* @param ClassMetadata $class * @param ClassMetadata $class
* @param AbstractPlatform $platform
* @return string * @return string
*/ */
abstract public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class); function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform);
/** /**
* Gets the (possibly quoted) identifier column names for safe use in an SQL statement. * Gets the (possibly quoted) identifier column names for safe use in an SQL statement.
* *
* @param ClassMetadata $class * @param ClassMetadata $class
* @param AbstractPlatform $platform
* @return array * @return array
*/ */
abstract public function getIdentifierColumnNames(ClassMetadata $class); function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform);
/** /**
* Gets the column alias. * Gets the column alias.
* *
* @param string $columnName * @param string $columnName
* @param integer $counter * @param integer $counter
* @param AbstractPlatform $platform
* @param ClassMetadata $class * @param ClassMetadata $class
* @return string * @return string
*/ */
abstract public function getColumnAlias($columnName, $counter, ClassMetadata $class = null); function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = null);
} }

View File

@ -45,6 +45,13 @@ abstract class AbstractCollectionPersister
*/ */
protected $_uow; protected $_uow;
/**
* The database platform.
*
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
protected $platform;
/** /**
* The quote strategy. * The quote strategy.
* *
@ -62,7 +69,8 @@ abstract class AbstractCollectionPersister
$this->_em = $em; $this->_em = $em;
$this->_uow = $em->getUnitOfWork(); $this->_uow = $em->getUnitOfWork();
$this->_conn = $em->getConnection(); $this->_conn = $em->getConnection();
$this->quoteStrategy = $em->getQuoteStrategy(); $this->platform = $this->_conn->getDatabasePlatform();
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
} }
/** /**

View File

@ -61,7 +61,7 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
{ {
$columnName = $class->columnNames[$field]; $columnName = $class->columnNames[$field];
$sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $this->quoteStrategy->getColumnName($field, $class); $sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $this->quoteStrategy->getColumnName($field, $class, $this->_platform);
$columnAlias = $this->getSQLColumnAlias($columnName); $columnAlias = $this->getSQLColumnAlias($columnName);
$this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name); $this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name);

View File

@ -198,8 +198,8 @@ class BasicEntityPersister
$this->_em = $em; $this->_em = $em;
$this->_class = $class; $this->_class = $class;
$this->_conn = $em->getConnection(); $this->_conn = $em->getConnection();
$this->quoteStrategy = $em->getQuoteStrategy();
$this->_platform = $this->_conn->getDatabasePlatform(); $this->_platform = $this->_conn->getDatabasePlatform();
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
} }
/** /**
@ -298,13 +298,13 @@ class BasicEntityPersister
protected function fetchVersionValue($versionedClass, $id) protected function fetchVersionValue($versionedClass, $id)
{ {
$versionField = $versionedClass->versionField; $versionField = $versionedClass->versionField;
$identifier = $this->quoteStrategy->getIdentifierColumnNames($versionedClass); $identifier = $this->quoteStrategy->getIdentifierColumnNames($versionedClass, $this->_platform);
$versionFieldColumnName = $this->quoteStrategy->getColumnName($versionField, $versionedClass); $versionFieldColumnName = $this->quoteStrategy->getColumnName($versionField, $versionedClass, $this->_platform);
//FIXME: Order with composite keys might not be correct //FIXME: Order with composite keys might not be correct
$sql = 'SELECT ' . $versionFieldColumnName $sql = 'SELECT ' . $versionFieldColumnName
. ' FROM ' . $this->quoteStrategy->getTableName($versionedClass) . ' FROM ' . $this->quoteStrategy->getTableName($versionedClass, $this->_platform)
. ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?'; . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';
$value = $this->_conn->fetchColumn($sql, array_values((array)$id)); $value = $this->_conn->fetchColumn($sql, array_values((array)$id));
@ -332,7 +332,7 @@ class BasicEntityPersister
if (isset($updateData[$tableName]) && $updateData[$tableName]) { if (isset($updateData[$tableName]) && $updateData[$tableName]) {
$this->_updateTable( $this->_updateTable(
$entity, $this->quoteStrategy->getTableName($this->_class), $entity, $this->quoteStrategy->getTableName($this->_class, $this->_platform),
$updateData[$tableName], $this->_class->isVersioned $updateData[$tableName], $this->_class->isVersioned
); );
@ -361,7 +361,7 @@ class BasicEntityPersister
$placeholder = '?'; $placeholder = '?';
if (isset($this->_class->fieldNames[$columnName])) { if (isset($this->_class->fieldNames[$columnName])) {
$column = $this->quoteStrategy->getColumnName($this->_class->fieldNames[$columnName], $this->_class); $column = $this->quoteStrategy->getColumnName($this->_class->fieldNames[$columnName], $this->_class, $this->_platform);
if (isset($this->_class->fieldMappings[$this->_class->fieldNames[$columnName]]['requireSQLConversion'])) { if (isset($this->_class->fieldMappings[$this->_class->fieldNames[$columnName]]['requireSQLConversion'])) {
$type = Type::getType($this->_columnTypes[$columnName]); $type = Type::getType($this->_columnTypes[$columnName]);
@ -386,7 +386,7 @@ class BasicEntityPersister
$params[] = $id[$idField]; $params[] = $id[$idField];
$types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type']; $types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
} else { } else {
$where[] = $this->quoteStrategy->getColumnName($idField, $this->_class); $where[] = $this->quoteStrategy->getColumnName($idField, $this->_class, $this->_platform);
$params[] = $id[$idField]; $params[] = $id[$idField];
$types[] = $this->_class->fieldMappings[$idField]['type']; $types[] = $this->_class->fieldMappings[$idField]['type'];
} }
@ -395,7 +395,7 @@ class BasicEntityPersister
if ($versioned) { if ($versioned) {
$versionField = $this->_class->versionField; $versionField = $this->_class->versionField;
$versionFieldType = $this->_class->fieldMappings[$versionField]['type']; $versionFieldType = $this->_class->fieldMappings[$versionField]['type'];
$versionColumn = $this->quoteStrategy->getColumnName($versionField, $this->_class); $versionColumn = $this->quoteStrategy->getColumnName($versionField, $this->_class, $this->_platform);
if ($versionFieldType == Type::INTEGER) { if ($versionFieldType == Type::INTEGER) {
$set[] = $versionColumn . ' = ' . $versionColumn . ' + 1'; $set[] = $versionColumn . ' = ' . $versionColumn . ' + 1';
@ -439,30 +439,30 @@ class BasicEntityPersister
$mapping = $relatedClass->associationMappings[$mapping['mappedBy']]; $mapping = $relatedClass->associationMappings[$mapping['mappedBy']];
foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) { foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) {
$keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass); $keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass, $this->_platform);
} }
if ($selfReferential) { if ($selfReferential) {
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
$otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass); $otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass, $this->_platform);
} }
} }
} else { } else {
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
$keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class); $keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
} }
if ($selfReferential) { if ($selfReferential) {
foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) { foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) {
$otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class); $otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
} }
} }
} }
if ( ! isset($mapping['isOnDeleteCascade'])) { if ( ! isset($mapping['isOnDeleteCascade'])) {
$joinTableName = $this->quoteStrategy->getJoinTableName($mapping, $this->_class); $joinTableName = $this->quoteStrategy->getJoinTableName($mapping, $this->_class, $this->_platform);
$this->_conn->delete($joinTableName, array_combine($keys, $identifier)); $this->_conn->delete($joinTableName, array_combine($keys, $identifier));
if ($selfReferential) { if ($selfReferential) {
@ -488,8 +488,8 @@ class BasicEntityPersister
$identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity); $identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
$this->deleteJoinTableRecords($identifier); $this->deleteJoinTableRecords($identifier);
$id = array_combine($this->quoteStrategy->getIdentifierColumnNames($this->_class), $identifier); $id = array_combine($this->quoteStrategy->getIdentifierColumnNames($this->_class, $this->_platform), $identifier);
$this->_conn->delete($this->quoteStrategy->getTableName($this->_class), $id); $this->_conn->delete($this->quoteStrategy->getTableName($this->_class, $this->_platform), $id);
} }
/** /**
@ -561,7 +561,7 @@ class BasicEntityPersister
$sourceColumn = $joinColumn['name']; $sourceColumn = $joinColumn['name'];
$targetColumn = $joinColumn['referencedColumnName']; $targetColumn = $joinColumn['referencedColumnName'];
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class); $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
$this->quotedColumns[$sourceColumn] = $quotedColumn; $this->quotedColumns[$sourceColumn] = $quotedColumn;
if ($newVal === null) { if ($newVal === null) {
@ -841,7 +841,7 @@ class BasicEntityPersister
$sourceClass = $this->_em->getClassMetadata($assoc['sourceEntity']); $sourceClass = $this->_em->getClassMetadata($assoc['sourceEntity']);
if ($assoc['isOwningSide']) { if ($assoc['isOwningSide']) {
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass); $quotedJoinTable = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->_platform);
foreach ($assoc['relationToSourceKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) { foreach ($assoc['relationToSourceKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) {
if ($sourceClass->containsForeignIdentifier) { if ($sourceClass->containsForeignIdentifier) {
@ -864,7 +864,7 @@ class BasicEntityPersister
} }
} else { } else {
$owningAssoc = $this->_em->getClassMetadata($assoc['targetEntity'])->associationMappings[$assoc['mappedBy']]; $owningAssoc = $this->_em->getClassMetadata($assoc['targetEntity'])->associationMappings[$assoc['mappedBy']];
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($owningAssoc, $sourceClass); $quotedJoinTable = $this->quoteStrategy->getJoinTableName($owningAssoc, $sourceClass, $this->_platform);
// TRICKY: since the association is inverted source and target are flipped // TRICKY: since the association is inverted source and target are flipped
foreach ($owningAssoc['relationToTargetKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) { foreach ($owningAssoc['relationToTargetKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) {
@ -934,7 +934,7 @@ class BasicEntityPersister
} }
return $this->_platform->modifyLimitQuery('SELECT ' . $this->_getSelectColumnListSQL() return $this->_platform->modifyLimitQuery('SELECT ' . $this->_getSelectColumnListSQL()
. $this->_platform->appendLockHint(' FROM ' . $this->quoteStrategy->getTableName($this->_class) . ' ' . $this->_platform->appendLockHint(' FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' '
. $alias, $lockMode) . $alias, $lockMode)
. $this->_selectJoinSql . $joinSql . $this->_selectJoinSql . $joinSql
. ($conditionSql ? ' WHERE ' . $conditionSql : '') . ($conditionSql ? ' WHERE ' . $conditionSql : '')
@ -967,7 +967,7 @@ class BasicEntityPersister
$this->_getSQLTableAlias($this->_class->fieldMappings[$fieldName]['inherited']) $this->_getSQLTableAlias($this->_class->fieldMappings[$fieldName]['inherited'])
: $baseTableAlias; : $baseTableAlias;
$columnName = $this->quoteStrategy->getColumnName($fieldName, $this->_class); $columnName = $this->quoteStrategy->getColumnName($fieldName, $this->_class, $this->_platform);
$orderBySql .= $orderBySql ? ', ' : ' ORDER BY '; $orderBySql .= $orderBySql ? ', ' : ' ORDER BY ';
$orderBySql .= $tableAlias . '.' . $columnName . ' ' . $orientation; $orderBySql .= $tableAlias . '.' . $columnName . ' ' . $orientation;
@ -1045,12 +1045,12 @@ class BasicEntityPersister
if ($assoc['isOwningSide']) { if ($assoc['isOwningSide']) {
$this->_selectJoinSql .= ' ' . $this->getJoinSQLForJoinColumns($assoc['joinColumns']); $this->_selectJoinSql .= ' ' . $this->getJoinSQLForJoinColumns($assoc['joinColumns']);
$this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity) . ' ' . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) .' ON '; $this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity, $this->_platform) . ' ' . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) .' ON ';
$tableAlias = $this->_getSQLTableAlias($assoc['targetEntity'], $assocAlias); $tableAlias = $this->_getSQLTableAlias($assoc['targetEntity'], $assocAlias);
foreach ($assoc['joinColumns'] as $joinColumn) { foreach ($assoc['joinColumns'] as $joinColumn) {
$sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class); $sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
$targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class); $targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class, $this->_platform);
if ( ! $first) { if ( ! $first) {
$this->_selectJoinSql .= ' AND '; $this->_selectJoinSql .= ' AND ';
@ -1069,7 +1069,7 @@ class BasicEntityPersister
$owningAssoc = $eagerEntity->getAssociationMapping($assoc['mappedBy']); $owningAssoc = $eagerEntity->getAssociationMapping($assoc['mappedBy']);
$this->_selectJoinSql .= ' LEFT JOIN'; $this->_selectJoinSql .= ' LEFT JOIN';
$this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity) . ' ' $this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity, $this->_platform) . ' '
. $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) . ' ON '; . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) . ' ON ';
foreach ($owningAssoc['sourceToTargetKeyColumns'] as $sourceCol => $targetCol) { foreach ($owningAssoc['sourceToTargetKeyColumns'] as $sourceCol => $targetCol) {
@ -1109,7 +1109,7 @@ class BasicEntityPersister
if ($columnList) $columnList .= ', '; if ($columnList) $columnList .= ', ';
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class); $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
$resultColumnName = $this->getSQLColumnAlias($joinColumn['name']); $resultColumnName = $this->getSQLColumnAlias($joinColumn['name']);
$columnList .= $this->_getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias) ) $columnList .= $this->_getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias) )
. '.' . $quotedColumn . ' AS ' . $resultColumnName; . '.' . $quotedColumn . ' AS ' . $resultColumnName;
@ -1137,7 +1137,7 @@ class BasicEntityPersister
$joinClauses = $owningAssoc['relationToSourceKeyColumns']; $joinClauses = $owningAssoc['relationToSourceKeyColumns'];
} }
$joinTableName = $this->quoteStrategy->getJoinTableName($owningAssoc, $this->_class); $joinTableName = $this->quoteStrategy->getJoinTableName($owningAssoc, $this->_class, $this->_platform);
$joinSql = ''; $joinSql = '';
foreach ($joinClauses as $joinTableColumn => $sourceColumn) { foreach ($joinClauses as $joinTableColumn => $sourceColumn) {
@ -1146,7 +1146,7 @@ class BasicEntityPersister
if ($this->_class->containsForeignIdentifier && ! isset($this->_class->fieldNames[$sourceColumn])) { if ($this->_class->containsForeignIdentifier && ! isset($this->_class->fieldNames[$sourceColumn])) {
$quotedColumn = $sourceColumn; // join columns cannot be quoted $quotedColumn = $sourceColumn; // join columns cannot be quoted
} else { } else {
$quotedColumn = $this->quoteStrategy->getColumnName($this->_class->fieldNames[$sourceColumn], $this->_class); $quotedColumn = $this->quoteStrategy->getColumnName($this->_class->fieldNames[$sourceColumn], $this->_class, $this->_platform);
} }
$joinSql .= $this->_getSQLTableAlias($this->_class->name) . '.' . $quotedColumn . ' = ' $joinSql .= $this->_getSQLTableAlias($this->_class->name) . '.' . $quotedColumn . ' = '
@ -1169,8 +1169,8 @@ class BasicEntityPersister
if (empty($columns)) { if (empty($columns)) {
$insertSql = $this->_platform->getEmptyIdentityInsertSQL( $insertSql = $this->_platform->getEmptyIdentityInsertSQL(
$this->quoteStrategy->getTableName($this->_class), $this->quoteStrategy->getTableName($this->_class, $this->_platform),
$this->quoteStrategy->getColumnName($this->_class->identifier[0], $this->_class) $this->quoteStrategy->getColumnName($this->_class->identifier[0], $this->_class, $this->_platform)
); );
} else { } else {
$columns = array_unique($columns); $columns = array_unique($columns);
@ -1189,7 +1189,7 @@ class BasicEntityPersister
$values[] = $placeholder; $values[] = $placeholder;
} }
$insertSql = 'INSERT INTO ' . $this->quoteStrategy->getTableName($this->_class) $insertSql = 'INSERT INTO ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform)
. ' (' . implode(', ', $columns) . ') VALUES (' . implode(', ', $values) . ')'; . ' (' . implode(', ', $columns) . ') VALUES (' . implode(', ', $values) . ')';
} }
@ -1220,11 +1220,11 @@ class BasicEntityPersister
$assoc = $this->_class->associationMappings[$name]; $assoc = $this->_class->associationMappings[$name];
if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) {
foreach ($assoc['joinColumns'] as $joinColumn) { foreach ($assoc['joinColumns'] as $joinColumn) {
$columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class); $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
} }
} }
} else if ($this->_class->generatorType != ClassMetadata::GENERATOR_TYPE_IDENTITY || $this->_class->identifier[0] != $name) { } else if ($this->_class->generatorType != ClassMetadata::GENERATOR_TYPE_IDENTITY || $this->_class->identifier[0] != $name) {
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class); $columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform);
$this->_columnTypes[$name] = $this->_class->fieldMappings[$name]['type']; $this->_columnTypes[$name] = $this->_class->fieldMappings[$name]['type'];
} }
} }
@ -1243,7 +1243,7 @@ class BasicEntityPersister
protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
{ {
$sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) $sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias)
. '.' . $this->quoteStrategy->getColumnName($field, $class); . '.' . $this->quoteStrategy->getColumnName($field, $class, $this->_platform);
$columnAlias = $this->getSQLColumnAlias($class->columnNames[$field]); $columnAlias = $this->getSQLColumnAlias($class->columnNames[$field]);
$this->_rsm->addFieldResult($alias, $columnAlias, $field); $this->_rsm->addFieldResult($alias, $columnAlias, $field);
@ -1313,7 +1313,7 @@ class BasicEntityPersister
*/ */
protected function getLockTablesSql() protected function getLockTablesSql()
{ {
return 'FROM ' . $this->quoteStrategy->getTableName($this->_class) . ' ' return 'FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' '
. $this->_getSQLTableAlias($this->_class->name); . $this->_getSQLTableAlias($this->_class->name);
} }
@ -1342,7 +1342,7 @@ class BasicEntityPersister
? $this->_class->fieldMappings[$field]['inherited'] ? $this->_class->fieldMappings[$field]['inherited']
: $this->_class->name; : $this->_class->name;
$conditionSql .= $this->_getSQLTableAlias($className) . '.' . $this->quoteStrategy->getColumnName($field, $this->_class); $conditionSql .= $this->_getSQLTableAlias($className) . '.' . $this->quoteStrategy->getColumnName($field, $this->_class, $this->_platform);
if (isset($this->_class->fieldMappings[$field]['requireSQLConversion'])) { if (isset($this->_class->fieldMappings[$field]['requireSQLConversion'])) {
$type = Type::getType($this->_class->getTypeOfField($field)); $type = Type::getType($this->_class->getTypeOfField($field));
@ -1610,7 +1610,7 @@ class BasicEntityPersister
*/ */
public function getSQLColumnAlias($columnName) public function getSQLColumnAlias($columnName)
{ {
return $this->quoteStrategy->getColumnAlias($columnName, $this->_sqlAliasCounter++); return $this->quoteStrategy->getColumnAlias($columnName, $this->_sqlAliasCounter++, $this->_platform);
} }
/** /**

View File

@ -105,7 +105,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
$tableName = $cm->getTableName(); $tableName = $cm->getTableName();
$this->_owningTableMap[$fieldName] = $tableName; $this->_owningTableMap[$fieldName] = $tableName;
$this->_quotedTableMap[$tableName] = $this->quoteStrategy->getTableName($cm); $this->_quotedTableMap[$tableName] = $this->quoteStrategy->getTableName($cm, $this->_platform);
return $tableName; return $tableName;
} }
@ -225,7 +225,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
// Make sure the table with the version column is updated even if no columns on that // Make sure the table with the version column is updated even if no columns on that
// table were affected. // table were affected.
if ($isVersioned && ! isset($updateData[$versionedTable])) { if ($isVersioned && ! isset($updateData[$versionedTable])) {
$this->_updateTable($entity, $this->quoteStrategy->getTableName($versionedClass), array(), true); $this->_updateTable($entity, $this->quoteStrategy->getTableName($versionedClass, $this->_platform), array(), true);
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity); $id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
$this->assignDefaultVersionValue($entity, $id); $this->assignDefaultVersionValue($entity, $id);
@ -247,15 +247,15 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
// delete the row from the root table. Cascades do the rest. // delete the row from the root table. Cascades do the rest.
if ($this->_platform->supportsForeignKeyConstraints()) { if ($this->_platform->supportsForeignKeyConstraints()) {
$this->_conn->delete( $this->_conn->delete(
$this->quoteStrategy->getTableName($this->_em->getClassMetadata($this->_class->rootEntityName)), $id $this->quoteStrategy->getTableName($this->_em->getClassMetadata($this->_class->rootEntityName), $this->_platform), $id
); );
} else { } else {
// Delete from all tables individually, starting from this class' table up to the root table. // Delete from all tables individually, starting from this class' table up to the root table.
$this->_conn->delete($this->quoteStrategy->getTableName($this->_class), $id); $this->_conn->delete($this->quoteStrategy->getTableName($this->_class, $this->_platform), $id);
foreach ($this->_class->parentClasses as $parentClass) { foreach ($this->_class->parentClasses as $parentClass) {
$this->_conn->delete( $this->_conn->delete(
$this->quoteStrategy->getTableName($this->_em->getClassMetadata($parentClass)), $id $this->quoteStrategy->getTableName($this->_em->getClassMetadata($parentClass), $this->_platform), $id
); );
} }
} }
@ -321,7 +321,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
foreach ($this->_class->parentClasses as $parentClassName) { foreach ($this->_class->parentClasses as $parentClassName) {
$parentClass = $this->_em->getClassMetadata($parentClassName); $parentClass = $this->_em->getClassMetadata($parentClassName);
$tableAlias = $this->_getSQLTableAlias($parentClassName); $tableAlias = $this->_getSQLTableAlias($parentClassName);
$joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass) . ' ' . $tableAlias . ' ON '; $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->_platform) . ' ' . $tableAlias . ' ON ';
$first = true; $first = true;
foreach ($idColumns as $idColumn) { foreach ($idColumns as $idColumn) {
@ -361,7 +361,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
} }
// Add LEFT JOIN // Add LEFT JOIN
$joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass) . ' ' . $tableAlias . ' ON '; $joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->_platform) . ' ' . $tableAlias . ' ON ';
$first = true; $first = true;
foreach ($idColumns as $idColumn) { foreach ($idColumns as $idColumn) {
@ -400,7 +400,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
} }
return $this->_platform->modifyLimitQuery('SELECT ' . $this->_selectColumnListSql return $this->_platform->modifyLimitQuery('SELECT ' . $this->_selectColumnListSql
. ' FROM ' . $this->quoteStrategy->getTableName($this->_class) . ' ' . $baseTableAlias . ' FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' . $baseTableAlias
. $joinSql . $joinSql
. ($conditionSql != '' ? ' WHERE ' . $conditionSql : '') . $orderBySql, $limit, $offset) . ($conditionSql != '' ? ' WHERE ' . $conditionSql : '') . $orderBySql, $limit, $offset)
. $lockSql; . $lockSql;
@ -422,7 +422,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
foreach ($this->_class->parentClasses as $parentClassName) { foreach ($this->_class->parentClasses as $parentClassName) {
$parentClass = $this->_em->getClassMetadata($parentClassName); $parentClass = $this->_em->getClassMetadata($parentClassName);
$tableAlias = $this->_getSQLTableAlias($parentClassName); $tableAlias = $this->_getSQLTableAlias($parentClassName);
$joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass) . ' ' . $tableAlias . ' ON '; $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->_platform) . ' ' . $tableAlias . ' ON ';
$first = true; $first = true;
foreach ($idColumns as $idColumn) { foreach ($idColumns as $idColumn) {
@ -432,7 +432,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
} }
} }
return 'FROM ' .$this->quoteStrategy->getTableName($this->_class) . ' ' . $baseTableAlias . $joinSql; return 'FROM ' .$this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' . $baseTableAlias . $joinSql;
} }
/* Ensure this method is never called. This persister overrides _getSelectEntitiesSQL directly. */ /* Ensure this method is never called. This persister overrides _getSelectEntitiesSQL directly. */
@ -463,7 +463,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
} }
} else if ($this->_class->name != $this->_class->rootEntityName || } else if ($this->_class->name != $this->_class->rootEntityName ||
! $this->_class->isIdGeneratorIdentity() || $this->_class->identifier[0] != $name) { ! $this->_class->isIdGeneratorIdentity() || $this->_class->identifier[0] != $name) {
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class); $columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform);
} }
} }

View File

@ -45,7 +45,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$mapping = $coll->getMapping(); $mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata(get_class($coll->getOwner())); $class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
return 'DELETE FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class) return 'DELETE FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform)
. ' WHERE ' . implode(' = ? AND ', $mapping['joinTableColumns']) . ' = ?'; . ' WHERE ' . implode(' = ? AND ', $mapping['joinTableColumns']) . ' = ?';
} }
@ -81,7 +81,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$mapping = $coll->getMapping(); $mapping = $coll->getMapping();
$columns = $mapping['joinTableColumns']; $columns = $mapping['joinTableColumns'];
$class = $this->_em->getClassMetadata(get_class($coll->getOwner())); $class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform);
return 'INSERT INTO ' . $joinTable . ' (' . implode(', ', $columns) . ')' return 'INSERT INTO ' . $joinTable . ' (' . implode(', ', $columns) . ')'
. ' VALUES (' . implode(', ', array_fill(0, count($columns), '?')) . ')'; . ' VALUES (' . implode(', ', array_fill(0, count($columns), '?')) . ')';
@ -151,7 +151,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
{ {
$class = $this->_em->getClassMetadata(get_class($coll->getOwner())); $class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
$mapping = $coll->getMapping(); $mapping = $coll->getMapping();
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform);
return 'DELETE FROM ' . $joinTable return 'DELETE FROM ' . $joinTable
. ' WHERE ' . implode(' = ? AND ', array_keys($mapping['relationToSourceKeyColumns'])) . ' = ?'; . ' WHERE ' . implode(' = ? AND ', array_keys($mapping['relationToSourceKeyColumns'])) . ' = ?';
@ -224,7 +224,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
} }
$sql = 'SELECT COUNT(*)' $sql = 'SELECT COUNT(*)'
. ' FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class) . ' t' . ' FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform) . ' t'
. $joinTargetEntitySQL . $joinTargetEntitySQL
. ' WHERE ' . implode(' AND ', $whereClauses); . ' WHERE ' . implode(' AND ', $whereClauses);
@ -326,7 +326,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$targetId = $uow->getEntityIdentifier($element); $targetId = $uow->getEntityIdentifier($element);
} }
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $sourceClass); $quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $sourceClass, $this->platform);
$whereClauses = array(); $whereClauses = array();
$params = array(); $params = array();
@ -387,7 +387,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$joinTargetEntitySQL = ''; $joinTargetEntitySQL = '';
if ($filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) { if ($filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) {
$joinTargetEntitySQL = ' JOIN ' $joinTargetEntitySQL = ' JOIN '
. $this->quoteStrategy->getTableName($targetClass) . ' te' . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' te'
. ' ON'; . ' ON';
$joinTargetEntitySQLClauses = array(); $joinTargetEntitySQLClauses = array();

View File

@ -45,7 +45,7 @@ class OneToManyPersister extends AbstractCollectionPersister
$mapping = $coll->getMapping(); $mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata($mapping['targetEntity']); $class = $this->_em->getClassMetadata($mapping['targetEntity']);
return 'DELETE FROM ' . $this->quoteStrategy->getTableName($class) return 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform)
. ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?'; . ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?';
} }
@ -127,7 +127,7 @@ class OneToManyPersister extends AbstractCollectionPersister
} }
$sql = 'SELECT count(*)' $sql = 'SELECT count(*)'
. ' FROM ' . $this->quoteStrategy->getTableName($targetClass) . ' t' . ' FROM ' . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' t'
. ' WHERE ' . implode(' AND ', $whereClauses); . ' WHERE ' . implode(' AND ', $whereClauses);
return $this->_conn->fetchColumn($sql, $params); return $this->_conn->fetchColumn($sql, $params);
@ -204,7 +204,7 @@ class OneToManyPersister extends AbstractCollectionPersister
$mapping = $coll->getMapping(); $mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata($mapping['targetEntity']); $class = $this->_em->getClassMetadata($mapping['targetEntity']);
$sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class) $sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform)
. ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?'; . ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?';
return (bool) $this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element)); return (bool) $this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element));

View File

@ -42,7 +42,8 @@ class SizeFunction extends FunctionNode
*/ */
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{ {
$quoteStrategy = $sqlWalker->getEntityManager()->getQuoteStrategy(); $platform = $sqlWalker->getEntityManager()->getConnection()->getDatabasePlatform();
$quoteStrategy = $sqlWalker->getEntityManager()->getConfiguration()->getQuoteStrategy();
$dqlAlias = $this->collectionPathExpression->identificationVariable; $dqlAlias = $this->collectionPathExpression->identificationVariable;
$assocField = $this->collectionPathExpression->field; $assocField = $this->collectionPathExpression->field;
@ -56,7 +57,7 @@ class SizeFunction extends FunctionNode
$targetTableAlias = $sqlWalker->getSQLTableAlias($targetClass->getTableName()); $targetTableAlias = $sqlWalker->getSQLTableAlias($targetClass->getTableName());
$sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); $sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias);
$sql .= $quoteStrategy->getTableName($targetClass) . ' ' . $targetTableAlias . ' WHERE '; $sql .= $quoteStrategy->getTableName($targetClass, $platform) . ' ' . $targetTableAlias . ' WHERE ';
$owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']]; $owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']];
@ -67,7 +68,7 @@ class SizeFunction extends FunctionNode
$sql .= $targetTableAlias . '.' . $sourceColumn $sql .= $targetTableAlias . '.' . $sourceColumn
. ' = ' . ' = '
. $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class); . $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $platform);
} }
} else { // many-to-many } else { // many-to-many
$targetClass = $sqlWalker->getEntityManager()->getClassMetadata($assoc['targetEntity']); $targetClass = $sqlWalker->getEntityManager()->getClassMetadata($assoc['targetEntity']);
@ -80,7 +81,7 @@ class SizeFunction extends FunctionNode
$sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); $sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias);
// join to target table // join to target table
$sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass) . ' ' . $joinTableAlias . ' WHERE '; $sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $platform) . ' ' . $joinTableAlias . ' WHERE ';
$joinColumns = $assoc['isOwningSide'] $joinColumns = $assoc['isOwningSide']
? $joinTable['joinColumns'] ? $joinTable['joinColumns']
@ -92,7 +93,7 @@ class SizeFunction extends FunctionNode
if ($first) $first = false; else $sql .= ' AND '; if ($first) $first = false; else $sql .= ' AND ';
$sourceColumnName = $quoteStrategy->getColumnName( $sourceColumnName = $quoteStrategy->getColumnName(
$class->fieldNames[$joinColumn['referencedColumnName']], $class $class->fieldNames[$joinColumn['referencedColumnName']], $class, $platform
); );
$sql .= $joinTableAlias . '.' . $joinColumn['name'] $sql .= $joinTableAlias . '.' . $joinColumn['name']

View File

@ -50,7 +50,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
$em = $sqlWalker->getEntityManager(); $em = $sqlWalker->getEntityManager();
$conn = $em->getConnection(); $conn = $em->getConnection();
$platform = $conn->getDatabasePlatform(); $platform = $conn->getDatabasePlatform();
$quoteStrategy = $em->getQuoteStrategy(); $quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
$primaryClass = $em->getClassMetadata($AST->deleteClause->abstractSchemaName); $primaryClass = $em->getClassMetadata($AST->deleteClause->abstractSchemaName);
$primaryDqlAlias = $AST->deleteClause->aliasIdentificationVariable; $primaryDqlAlias = $AST->deleteClause->aliasIdentificationVariable;
@ -81,7 +81,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
// 3. Create and store DELETE statements // 3. Create and store DELETE statements
$classNames = array_merge($primaryClass->parentClasses, array($primaryClass->name), $primaryClass->subClasses); $classNames = array_merge($primaryClass->parentClasses, array($primaryClass->name), $primaryClass->subClasses);
foreach (array_reverse($classNames) as $className) { foreach (array_reverse($classNames) as $className) {
$tableName = $quoteStrategy->getTableName($em->getClassMetadata($className)); $tableName = $quoteStrategy->getTableName($em->getClassMetadata($className), $platform);
$this->_sqlStatements[] = 'DELETE FROM ' . $tableName $this->_sqlStatements[] = 'DELETE FROM ' . $tableName
. ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')'; . ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')';
} }

View File

@ -53,7 +53,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
$em = $sqlWalker->getEntityManager(); $em = $sqlWalker->getEntityManager();
$conn = $em->getConnection(); $conn = $em->getConnection();
$platform = $conn->getDatabasePlatform(); $platform = $conn->getDatabasePlatform();
$quoteStrategy = $em->getQuoteStrategy(); $quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
$updateClause = $AST->updateClause; $updateClause = $AST->updateClause;
$primaryClass = $sqlWalker->getEntityManager()->getClassMetadata($updateClause->abstractSchemaName); $primaryClass = $sqlWalker->getEntityManager()->getClassMetadata($updateClause->abstractSchemaName);
@ -86,7 +86,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
foreach (array_reverse($classNames) as $className) { foreach (array_reverse($classNames) as $className) {
$affected = false; $affected = false;
$class = $em->getClassMetadata($className); $class = $em->getClassMetadata($className);
$updateSql = 'UPDATE ' . $quoteStrategy->getTableName($class) . ' SET '; $updateSql = 'UPDATE ' . $quoteStrategy->getTableName($class, $platform) . ' SET ';
foreach ($updateItems as $updateItem) { foreach ($updateItems as $updateItem) {
$field = $updateItem->pathExpression->field; $field = $updateItem->pathExpression->field;

View File

@ -170,8 +170,8 @@ class SqlWalker implements TreeWalker
$this->rsm = $parserResult->getResultSetMapping(); $this->rsm = $parserResult->getResultSetMapping();
$this->em = $query->getEntityManager(); $this->em = $query->getEntityManager();
$this->conn = $this->em->getConnection(); $this->conn = $this->em->getConnection();
$this->quoteStrategy = $this->em->getQuoteStrategy();
$this->platform = $this->conn->getDatabasePlatform(); $this->platform = $this->conn->getDatabasePlatform();
$this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy();
} }
/** /**
@ -286,7 +286,7 @@ class SqlWalker implements TreeWalker
*/ */
public function getSQLColumnAlias($columnName) public function getSQLColumnAlias($columnName)
{ {
return $this->quoteStrategy->getColumnAlias($columnName, $this->aliasCounter++); return $this->quoteStrategy->getColumnAlias($columnName, $this->aliasCounter++, $this->platform);
} }
/** /**
@ -310,11 +310,11 @@ class SqlWalker implements TreeWalker
// If this is a joined association we must use left joins to preserve the correct result. // If this is a joined association we must use left joins to preserve the correct result.
$sql .= isset($this->queryComponents[$dqlAlias]['relation']) ? ' LEFT ' : ' INNER '; $sql .= isset($this->queryComponents[$dqlAlias]['relation']) ? ' LEFT ' : ' INNER ';
$sql .= 'JOIN ' . $this->quoteStrategy->getTableName($parentClass) . ' ' . $tableAlias . ' ON '; $sql .= 'JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON ';
$sqlParts = array(); $sqlParts = array();
foreach ($this->quoteStrategy->getIdentifierColumnNames($class) as $columnName) { foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) {
$sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName; $sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName;
} }
@ -336,11 +336,11 @@ class SqlWalker implements TreeWalker
$subClass = $this->em->getClassMetadata($subClassName); $subClass = $this->em->getClassMetadata($subClassName);
$tableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); $tableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias);
$sql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass) . ' ' . $tableAlias . ' ON '; $sql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON ';
$sqlParts = array(); $sqlParts = array();
foreach ($this->quoteStrategy->getIdentifierColumnNames($subClass) as $columnName) { foreach ($this->quoteStrategy->getIdentifierColumnNames($subClass, $this->platform) as $columnName) {
$sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName; $sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName;
} }
@ -361,7 +361,7 @@ class SqlWalker implements TreeWalker
if ( ! isset($qComp['relation']['orderBy'])) continue; if ( ! isset($qComp['relation']['orderBy'])) continue;
foreach ($qComp['relation']['orderBy'] as $fieldName => $orientation) { foreach ($qComp['relation']['orderBy'] as $fieldName => $orientation) {
$columnName = $this->quoteStrategy->getColumnName($fieldName, $qComp['metadata']); $columnName = $this->quoteStrategy->getColumnName($fieldName, $qComp['metadata'], $this->platform);
$tableName = ($qComp['metadata']->isInheritanceTypeJoined()) $tableName = ($qComp['metadata']->isInheritanceTypeJoined())
? $this->em->getUnitOfWork()->getEntityPersister($qComp['metadata']->name)->getOwningTable($fieldName) ? $this->em->getUnitOfWork()->getEntityPersister($qComp['metadata']->name)->getOwningTable($fieldName)
: $qComp['metadata']->getTableName(); : $qComp['metadata']->getTableName();
@ -544,7 +544,7 @@ class SqlWalker implements TreeWalker
$tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable); $tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable);
$sqlParts = array(); $sqlParts = array();
foreach ($this->quoteStrategy->getIdentifierColumnNames($class) as $columnName) { foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) {
$sqlParts[] = $tableAlias . '.' . $columnName; $sqlParts[] = $tableAlias . '.' . $columnName;
} }
@ -592,7 +592,7 @@ class SqlWalker implements TreeWalker
$sql .= $this->walkIdentificationVariable($dqlAlias, $fieldName) . '.'; $sql .= $this->walkIdentificationVariable($dqlAlias, $fieldName) . '.';
} }
$sql .= $this->quoteStrategy->getColumnName($fieldName, $class); $sql .= $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
break; break;
case AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION: case AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION:
@ -1161,7 +1161,7 @@ class SqlWalker implements TreeWalker
: $class->getTableName(); : $class->getTableName();
$sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias); $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias);
$columnName = $this->quoteStrategy->getColumnName($fieldName, $class); $columnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
$columnAlias = $this->getSQLColumnAlias($class->fieldMappings[$fieldName]['columnName']); $columnAlias = $this->getSQLColumnAlias($class->fieldMappings[$fieldName]['columnName']);
$col = $sqlTableAlias . '.' . $columnName; $col = $sqlTableAlias . '.' . $columnName;
@ -1257,7 +1257,7 @@ class SqlWalker implements TreeWalker
$sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias); $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias);
$columnAlias = $this->getSQLColumnAlias($mapping['columnName']); $columnAlias = $this->getSQLColumnAlias($mapping['columnName']);
$quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class); $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
$col = $sqlTableAlias . '.' . $quotedColumnName; $col = $sqlTableAlias . '.' . $quotedColumnName;
@ -1288,7 +1288,7 @@ class SqlWalker implements TreeWalker
} }
$columnAlias = $this->getSQLColumnAlias($mapping['columnName']); $columnAlias = $this->getSQLColumnAlias($mapping['columnName']);
$quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass); $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform);
$col = $sqlTableAlias . '.' . $quotedColumnName; $col = $sqlTableAlias . '.' . $quotedColumnName;
@ -1523,7 +1523,7 @@ class SqlWalker implements TreeWalker
{ {
$class = $this->em->getClassMetadata($deleteClause->abstractSchemaName); $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName);
$tableName = $class->getTableName(); $tableName = $class->getTableName();
$sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class); $sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform);
$this->setSQLTableAlias($tableName, $tableName, $deleteClause->aliasIdentificationVariable); $this->setSQLTableAlias($tableName, $tableName, $deleteClause->aliasIdentificationVariable);
$this->rootAliases[] = $deleteClause->aliasIdentificationVariable; $this->rootAliases[] = $deleteClause->aliasIdentificationVariable;
@ -1541,7 +1541,7 @@ class SqlWalker implements TreeWalker
{ {
$class = $this->em->getClassMetadata($updateClause->abstractSchemaName); $class = $this->em->getClassMetadata($updateClause->abstractSchemaName);
$tableName = $class->getTableName(); $tableName = $class->getTableName();
$sql = 'UPDATE ' . $this->quoteStrategy->getTableName($class); $sql = 'UPDATE ' . $this->quoteStrategy->getTableName($class, $this->platform);
$this->setSQLTableAlias($tableName, $tableName, $updateClause->aliasIdentificationVariable); $this->setSQLTableAlias($tableName, $tableName, $updateClause->aliasIdentificationVariable);
$this->rootAliases[] = $updateClause->aliasIdentificationVariable; $this->rootAliases[] = $updateClause->aliasIdentificationVariable;
@ -1752,18 +1752,18 @@ class SqlWalker implements TreeWalker
$targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName()); $targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName());
$sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias); $sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
$sql .= $this->quoteStrategy->getTableName($targetClass) . ' ' . $targetTableAlias . ' WHERE '; $sql .= $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' WHERE ';
$owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']]; $owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']];
$sqlParts = array(); $sqlParts = array();
foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) { foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class); $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $this->platform);
$sqlParts[] = $sourceTableAlias . '.' . $targetColumn . ' = ' . $targetTableAlias . '.' . $sourceColumn; $sqlParts[] = $sourceTableAlias . '.' . $targetColumn . ' = ' . $targetTableAlias . '.' . $sourceColumn;
} }
foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass) as $targetColumnName) { foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass, $this->platform) as $targetColumnName) {
if (isset($dqlParamKey)) { if (isset($dqlParamKey)) {
$this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++); $this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++);
} }
@ -1784,15 +1784,15 @@ class SqlWalker implements TreeWalker
$sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias); $sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
// join to target table // join to target table
$sql .= $this->quoteStrategy->getJoinTableName($owningAssoc, $targetClass) . ' ' . $joinTableAlias $sql .= $this->quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $this->platform) . ' ' . $joinTableAlias
. ' INNER JOIN ' . $this->quoteStrategy->getTableName($targetClass) . ' ' . $targetTableAlias . ' ON '; . ' INNER JOIN ' . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' ON ';
// join conditions // join conditions
$joinColumns = $assoc['isOwningSide'] ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns']; $joinColumns = $assoc['isOwningSide'] ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns'];
$joinSqlParts = array(); $joinSqlParts = array();
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($targetClass->fieldNames[$joinColumn['referencedColumnName']], $targetClass); $targetColumn = $this->quoteStrategy->getColumnName($targetClass->fieldNames[$joinColumn['referencedColumnName']], $targetClass, $this->platform);
$joinSqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' = ' . $targetTableAlias . '.' . $targetColumn; $joinSqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' = ' . $targetTableAlias . '.' . $targetColumn;
} }
@ -1804,12 +1804,12 @@ class SqlWalker implements TreeWalker
$sqlParts = array(); $sqlParts = array();
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$joinColumn['referencedColumnName']], $class); $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$joinColumn['referencedColumnName']], $class, $this->platform);
$sqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' = ' . $sourceTableAlias . '.' . $targetColumn; $sqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' = ' . $sourceTableAlias . '.' . $targetColumn;
} }
foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass) as $targetColumnName) { foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass, $this->platform) as $targetColumnName) {
if (isset($dqlParamKey)) { if (isset($dqlParamKey)) {
$this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++); $this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++);
} }

View File

@ -58,7 +58,7 @@ class SchemaTool
* *
* @var \Doctrine\ORM\Mapping\QuoteStrategy * @var \Doctrine\ORM\Mapping\QuoteStrategy
*/ */
protected $quoteStrategy; private $quoteStrategy;
/** /**
* Initializes a new SchemaTool instance that uses the connection of the * Initializes a new SchemaTool instance that uses the connection of the
@ -69,8 +69,8 @@ class SchemaTool
public function __construct(EntityManager $em) public function __construct(EntityManager $em)
{ {
$this->em = $em; $this->em = $em;
$this->quoteStrategy = $em->getQuoteStrategy();
$this->platform = $em->getConnection()->getDatabasePlatform(); $this->platform = $em->getConnection()->getDatabasePlatform();
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
} }
/** /**
@ -145,7 +145,7 @@ class SchemaTool
continue; continue;
} }
$table = $schema->createTable($this->quoteStrategy->getTableName($class)); $table = $schema->createTable($this->quoteStrategy->getTableName($class, $this->platform));
$columns = array(); // table columns $columns = array(); // table columns
if ($class->isInheritanceTypeSingleTable()) { if ($class->isInheritanceTypeSingleTable()) {
@ -172,7 +172,7 @@ class SchemaTool
$pkColumns = array(); $pkColumns = array();
foreach ($class->fieldMappings as $fieldName => $mapping) { foreach ($class->fieldMappings as $fieldName => $mapping) {
if ( ! isset($mapping['inherited'])) { if ( ! isset($mapping['inherited'])) {
$columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class); $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
$this->_gatherColumn($class, $mapping, $table); $this->_gatherColumn($class, $mapping, $table);
if ($class->isIdentifier($fieldName)) { if ($class->isIdentifier($fieldName)) {
@ -191,7 +191,7 @@ class SchemaTool
/* @var \Doctrine\ORM\Mapping\ClassMetadata $class */ /* @var \Doctrine\ORM\Mapping\ClassMetadata $class */
$idMapping = $class->fieldMappings[$class->identifier[0]]; $idMapping = $class->fieldMappings[$class->identifier[0]];
$this->_gatherColumn($class, $idMapping, $table); $this->_gatherColumn($class, $idMapping, $table);
$columnName = $this->quoteStrategy->getColumnName($class->identifier[0], $class); $columnName = $this->quoteStrategy->getColumnName($class->identifier[0], $class, $this->platform);
// TODO: This seems rather hackish, can we optimize it? // TODO: This seems rather hackish, can we optimize it?
$table->getColumn($columnName)->setAutoincrement(false); $table->getColumn($columnName)->setAutoincrement(false);
@ -199,7 +199,7 @@ class SchemaTool
// Add a FK constraint on the ID column // Add a FK constraint on the ID column
$table->addUnnamedForeignKeyConstraint( $table->addUnnamedForeignKeyConstraint(
$this->quoteStrategy->getTableName($this->em->getClassMetadata($class->rootEntityName)), $this->quoteStrategy->getTableName($this->em->getClassMetadata($class->rootEntityName), $this->platform),
array($columnName), array($columnName), array('onDelete' => 'CASCADE') array($columnName), array($columnName), array('onDelete' => 'CASCADE')
); );
} }
@ -216,12 +216,12 @@ class SchemaTool
$pkColumns = array(); $pkColumns = array();
foreach ($class->identifier as $identifierField) { foreach ($class->identifier as $identifierField) {
if (isset($class->fieldMappings[$identifierField])) { if (isset($class->fieldMappings[$identifierField])) {
$pkColumns[] = $this->quoteStrategy->getColumnName($identifierField, $class); $pkColumns[] = $this->quoteStrategy->getColumnName($identifierField, $class, $this->platform);
} else if (isset($class->associationMappings[$identifierField])) { } else if (isset($class->associationMappings[$identifierField])) {
/* @var $assoc \Doctrine\ORM\Mapping\OneToOne */ /* @var $assoc \Doctrine\ORM\Mapping\OneToOne */
$assoc = $class->associationMappings[$identifierField]; $assoc = $class->associationMappings[$identifierField];
foreach ($assoc['joinColumns'] as $joinColumn) { foreach ($assoc['joinColumns'] as $joinColumn) {
$pkColumns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class); $pkColumns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
} }
} }
} }
@ -252,7 +252,7 @@ class SchemaTool
if ($class->isIdGeneratorSequence() && $class->name == $class->rootEntityName) { if ($class->isIdGeneratorSequence() && $class->name == $class->rootEntityName) {
$seqDef = $class->sequenceGeneratorDefinition; $seqDef = $class->sequenceGeneratorDefinition;
$quotedName = $this->quoteStrategy->getSequenceName($seqDef, $class); $quotedName = $this->quoteStrategy->getSequenceName($seqDef, $class, $this->platform);
if ( ! $schema->hasSequence($quotedName)) { if ( ! $schema->hasSequence($quotedName)) {
$schema->createSequence( $schema->createSequence(
$quotedName, $quotedName,
@ -328,7 +328,7 @@ class SchemaTool
$column = $this->_gatherColumn($class, $mapping, $table); $column = $this->_gatherColumn($class, $mapping, $table);
if ($class->isIdentifier($mapping['fieldName'])) { if ($class->isIdentifier($mapping['fieldName'])) {
$pkColumns[] = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class); $pkColumns[] = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
} }
} }
@ -351,7 +351,7 @@ class SchemaTool
*/ */
private function _gatherColumn($class, array $mapping, $table) private function _gatherColumn($class, array $mapping, $table)
{ {
$columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class); $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
$columnType = $mapping['type']; $columnType = $mapping['type'];
$options = array(); $options = array();
@ -441,7 +441,7 @@ class SchemaTool
// create join table // create join table
$joinTable = $mapping['joinTable']; $joinTable = $mapping['joinTable'];
$theJoinTable = $schema->createTable($this->quoteStrategy->getJoinTableName($mapping, $foreignClass)); $theJoinTable = $schema->createTable($this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform));
$primaryKeyColumns = $uniqueConstraints = array(); $primaryKeyColumns = $uniqueConstraints = array();
@ -509,7 +509,7 @@ class SchemaTool
$localColumns = array(); $localColumns = array();
$foreignColumns = array(); $foreignColumns = array();
$fkOptions = array(); $fkOptions = array();
$foreignTableName = $this->quoteStrategy->getTableName($class); $foreignTableName = $this->quoteStrategy->getTableName($class, $this->platform);
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
@ -522,8 +522,8 @@ class SchemaTool
); );
} }
$quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class); $quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
$quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $class); $quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $class, $this->platform);
$primaryKeyColumns[] = $quotedColumnName; $primaryKeyColumns[] = $quotedColumnName;
$localColumns[] = $quotedColumnName; $localColumns[] = $quotedColumnName;

View File

@ -19,11 +19,17 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
*/ */
private $strategy; private $strategy;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $platform;
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
$em = $this->_getTestEntityManager(); $em = $this->_getTestEntityManager();
$this->strategy = new DefaultQuoteStrategy($em->getConnection()->getDatabasePlatform()); $this->platform = $em->getConnection()->getDatabasePlatform();
$this->strategy = new DefaultQuoteStrategy();
} }
/** /**
@ -44,20 +50,20 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
$cm->mapField(array('fieldName' => 'name', 'columnName' => '`name`')); $cm->mapField(array('fieldName' => 'name', 'columnName' => '`name`'));
$cm->mapField(array('fieldName' => 'id', 'columnName' => 'id')); $cm->mapField(array('fieldName' => 'id', 'columnName' => 'id'));
$this->assertEquals('id' ,$this->strategy->getColumnName('id', $cm)); $this->assertEquals('id' ,$this->strategy->getColumnName('id', $cm, $this->platform));
$this->assertEquals('"name"' ,$this->strategy->getColumnName('name', $cm)); $this->assertEquals('"name"' ,$this->strategy->getColumnName('name', $cm, $this->platform));
} }
public function testGetTableName() public function testGetTableName()
{ {
$cm = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
$cm->setPrimaryTable(array('name'=>'`cms_user`')); $cm->setPrimaryTable(array('name'=>'`cms_user`'));
$this->assertEquals('"cms_user"' ,$this->strategy->getTableName($cm)); $this->assertEquals('"cms_user"' ,$this->strategy->getTableName($cm, $this->platform));
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
$cm->setPrimaryTable(array('name'=>'cms_user')); $cm->setPrimaryTable(array('name'=>'cms_user'));
$this->assertEquals('cms_user' ,$this->strategy->getTableName($cm)); $this->assertEquals('cms_user' ,$this->strategy->getTableName($cm, $this->platform));
} }
public function testJoinTableName() public function testJoinTableName()
@ -84,8 +90,8 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
) )
); );
$this->assertEquals('"cmsaddress_cmsuser"', $this->strategy->getJoinTableName($cm1->associationMappings['user'], $cm1)); $this->assertEquals('"cmsaddress_cmsuser"', $this->strategy->getJoinTableName($cm1->associationMappings['user'], $cm1, $this->platform));
$this->assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($cm2->associationMappings['user'], $cm2)); $this->assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($cm2->associationMappings['user'], $cm2, $this->platform));
} }
@ -106,18 +112,18 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
'columnName' => 'id', 'columnName' => 'id',
)); ));
$this->assertEquals(array('"id"'), $this->strategy->getIdentifierColumnNames($cm1)); $this->assertEquals(array('"id"'), $this->strategy->getIdentifierColumnNames($cm1, $this->platform));
$this->assertEquals(array('id'), $this->strategy->getIdentifierColumnNames($cm2)); $this->assertEquals(array('id'), $this->strategy->getIdentifierColumnNames($cm2, $this->platform));
} }
public function testColumnAlias() public function testColumnAlias()
{ {
$i = 0; $i = 0;
$this->assertEquals('columnName0', $this->strategy->getColumnAlias('columnName', $i++)); $this->assertEquals('columnName0', $this->strategy->getColumnAlias('columnName', $i++, $this->platform));
$this->assertEquals('column_name1', $this->strategy->getColumnAlias('column_name', $i++)); $this->assertEquals('column_name1', $this->strategy->getColumnAlias('column_name', $i++, $this->platform));
$this->assertEquals('COLUMN_NAME2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++)); $this->assertEquals('COLUMN_NAME2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++, $this->platform));
$this->assertEquals('COLUMNNAME3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++)); $this->assertEquals('COLUMNNAME3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++, $this->platform));
} }
public function testQuoteIdentifierJoinColumns() public function testQuoteIdentifierJoinColumns()
@ -133,7 +139,7 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
)), )),
)); ));
$this->assertEquals(array('"article"'), $this->strategy->getIdentifierColumnNames($cm)); $this->assertEquals(array('"article"'), $this->strategy->getIdentifierColumnNames($cm, $this->platform));
} }
public function testJoinColumnName() public function testJoinColumnName()
@ -150,7 +156,7 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
)); ));
$joinColumn = $cm->associationMappings['article']['joinColumns'][0]; $joinColumn = $cm->associationMappings['article']['joinColumns'][0];
$this->assertEquals('"article"',$this->strategy->getJoinColumnName($joinColumn, $cm)); $this->assertEquals('"article"',$this->strategy->getJoinColumnName($joinColumn, $cm, $this->platform));
} }
public function testReferencedJoinColumnName() public function testReferencedJoinColumnName()
@ -167,6 +173,6 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
)); ));
$joinColumn = $cm->associationMappings['article']['joinColumns'][0]; $joinColumn = $cm->associationMappings['article']['joinColumns'][0];
$this->assertEquals('"id"',$this->strategy->getReferencedJoinColumnName($joinColumn, $cm)); $this->assertEquals('"id"',$this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform));
} }
} }