change quote strategy to interface
This commit is contained in:
parent
b6b35d9482
commit
85b6f8dc2f
@ -26,6 +26,7 @@ use Doctrine\Common\Cache\Cache,
|
||||
Doctrine\ORM\Mapping\Driver\Driver,
|
||||
Doctrine\ORM\Mapping\Driver\AnnotationDriver,
|
||||
Doctrine\ORM\Mapping\NamingStrategy,
|
||||
Doctrine\ORM\Mapping\QuoteStrategy,
|
||||
Doctrine\ORM\Mapping\DefaultNamingStrategy;
|
||||
|
||||
/**
|
||||
@ -631,32 +632,28 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
}
|
||||
|
||||
/**
|
||||
* Set quote strategy class.
|
||||
* Set quote strategy.
|
||||
*
|
||||
* @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';
|
||||
|
||||
if ($className !== $quoteStrategy && ! is_subclass_of($className, $quoteStrategy)) {
|
||||
throw new \InvalidArgumentException("Invalid quote strategy class");
|
||||
}
|
||||
|
||||
$this->_attributes['quoteStrategyClassName'] = $namingStrategy;
|
||||
$this->_attributes['quoteStrategy'] = $namingStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get quote strategy class.
|
||||
* Get quote strategy.
|
||||
*
|
||||
* @since 2.3
|
||||
* @return string
|
||||
* @return Doctrine\ORM\Mapping\QuoteStrategy
|
||||
*/
|
||||
public function getQuoteStrategyClassName()
|
||||
public function getQuoteStrategy()
|
||||
{
|
||||
return isset($this->_attributes['quoteStrategyClassName'])
|
||||
? $this->_attributes['quoteStrategyClassName']
|
||||
: 'Doctrine\ORM\Mapping\DefaultQuoteStrategy';
|
||||
if ( ! isset($this->_attributes['quoteStrategy'])) {
|
||||
$this->_attributes['quoteStrategy'] = new \Doctrine\ORM\Mapping\DefaultQuoteStrategy();
|
||||
}
|
||||
|
||||
return $this->_attributes['quoteStrategy'];
|
||||
}
|
||||
}
|
||||
|
@ -62,13 +62,6 @@ class EntityManager implements ObjectManager
|
||||
*/
|
||||
private $metadataFactory;
|
||||
|
||||
/**
|
||||
* The quote strategy.
|
||||
*
|
||||
* @var \Doctrine\ORM\Mapping\QuoteStrategy.
|
||||
*/
|
||||
private $quoteStrategy;
|
||||
|
||||
/**
|
||||
* The EntityRepository instances.
|
||||
*
|
||||
@ -140,7 +133,7 @@ class EntityManager implements ObjectManager
|
||||
$this->eventManager = $eventManager;
|
||||
|
||||
$metadataFactoryClassName = $config->getClassMetadataFactoryName();
|
||||
|
||||
|
||||
$this->metadataFactory = new $metadataFactoryClassName;
|
||||
$this->metadataFactory->setEntityManager($this);
|
||||
$this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl());
|
||||
@ -174,21 +167,6 @@ class EntityManager implements ObjectManager
|
||||
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.
|
||||
*
|
||||
|
@ -660,7 +660,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
if ($quoted) {
|
||||
$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));
|
||||
break;
|
||||
@ -681,7 +681,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
$class->setSequenceGeneratorDefinition($definition);
|
||||
}
|
||||
$sequenceGenerator = new \Doctrine\ORM\Id\SequenceGenerator(
|
||||
$this->em->getQuoteStrategy()->getSequenceName($definition, $class),
|
||||
$this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->targetPlatform),
|
||||
$definition['allocationSize']
|
||||
);
|
||||
$class->setIdGenerator($sequenceGenerator);
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
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
|
||||
@ -26,85 +28,84 @@ namespace Doctrine\ORM\Mapping;
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
class DefaultQuoteStrategy extends QuoteStrategy
|
||||
class DefaultQuoteStrategy implements QuoteStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getColumnName($fieldName, ClassMetadata $class)
|
||||
public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform)
|
||||
{
|
||||
return isset($class->fieldMappings[$fieldName]['quoted'])
|
||||
? $this->platform->quoteIdentifier($class->fieldMappings[$fieldName]['columnName'])
|
||||
? $platform->quoteIdentifier($class->fieldMappings[$fieldName]['columnName'])
|
||||
: $class->fieldMappings[$fieldName]['columnName'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTableName(ClassMetadata $class)
|
||||
public function getTableName(ClassMetadata $class, AbstractPlatform $platform)
|
||||
{
|
||||
return isset($class->table['quoted'])
|
||||
? $this->platform->quoteIdentifier($class->table['name'])
|
||||
? $platform->quoteIdentifier($class->table['name'])
|
||||
: $class->table['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSequenceName(array $definition, ClassMetadata $class)
|
||||
public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform)
|
||||
{
|
||||
return isset($definition['quoted'])
|
||||
? $this->platform->quoteSingleIdentifier($definition['sequenceName'])
|
||||
? $platform->quoteIdentifier($definition['sequenceName'])
|
||||
: $definition['sequenceName'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getJoinColumnName(array $joinColumn, ClassMetadata $class)
|
||||
public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform)
|
||||
{
|
||||
return isset($joinColumn['quoted'])
|
||||
? $this->platform->quoteIdentifier($joinColumn['name'])
|
||||
? $platform->quoteIdentifier($joinColumn['name'])
|
||||
: $joinColumn['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class)
|
||||
public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform)
|
||||
{
|
||||
return isset($joinColumn['quoted'])
|
||||
? $this->platform->quoteIdentifier($joinColumn['referencedColumnName'])
|
||||
? $platform->quoteIdentifier($joinColumn['referencedColumnName'])
|
||||
: $joinColumn['referencedColumnName'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getJoinTableName(array $association, ClassMetadata $class)
|
||||
public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform)
|
||||
{
|
||||
return isset($association['joinTable']['quoted'])
|
||||
? $this->platform->quoteIdentifier($association['joinTable']['name'])
|
||||
? $platform->quoteIdentifier($association['joinTable']['name'])
|
||||
: $association['joinTable']['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIdentifierColumnNames(ClassMetadata $class)
|
||||
public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform)
|
||||
{
|
||||
$quotedColumnNames = array();
|
||||
|
||||
foreach ($class->identifier as $fieldName) {
|
||||
if (isset($class->fieldMappings[$fieldName])) {
|
||||
$quotedColumnNames[] = $this->getColumnName($fieldName, $class);
|
||||
$quotedColumnNames[] = $this->getColumnName($fieldName, $class, $platform);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Association defined as Id field
|
||||
$platform = $this->platform;
|
||||
$joinColumns = $class->associationMappings[$fieldName]['joinColumns'];
|
||||
$assocQuotedColumnNames = array_map(
|
||||
function ($joinColumn) use ($platform) {
|
||||
@ -124,16 +125,16 @@ class DefaultQuoteStrategy extends QuoteStrategy
|
||||
/**
|
||||
* {@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.
|
||||
// If the alias is to long, characters are cut off from the beginning.
|
||||
// And strip non alphanumeric characters
|
||||
$columnName = $columnName . $counter;
|
||||
$columnName = substr($columnName, -$this->platform->getMaxIdentifierLength());
|
||||
$columnName = substr($columnName, -$platform->getMaxIdentifierLength());
|
||||
$columnName = preg_replace('/[^A-Za-z0-9_]/', '', $columnName);
|
||||
|
||||
return $this->platform->getSQLResultCasing($columnName);
|
||||
return $platform->getSQLResultCasing($columnName);
|
||||
}
|
||||
|
||||
}
|
@ -23,95 +23,91 @@ 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 column, alias and table quotes
|
||||
*
|
||||
* @since 2.3
|
||||
* @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.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @param ClassMetadata $class
|
||||
* @param AbstractPlatform $platform
|
||||
* @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.
|
||||
*
|
||||
* @param ClassMetadata $class
|
||||
* @param AbstractPlatform $platform
|
||||
* @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.
|
||||
*
|
||||
* @param array $definition
|
||||
* @param ClassMetadata $class
|
||||
* @param AbstractPlatform $platform
|
||||
* @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.
|
||||
*
|
||||
* @param array $association
|
||||
* @param ClassMetadata $class
|
||||
* @param AbstractPlatform $platform
|
||||
* @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.
|
||||
*
|
||||
* @param array $joinColumn
|
||||
* @param ClassMetadata $class
|
||||
* @param AbstractPlatform $platform
|
||||
* @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.
|
||||
*
|
||||
* @param array $joinColumn
|
||||
* @param ClassMetadata $class
|
||||
* @param AbstractPlatform $platform
|
||||
* @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.
|
||||
*
|
||||
* @param ClassMetadata $class
|
||||
* @param AbstractPlatform $platform
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getIdentifierColumnNames(ClassMetadata $class);
|
||||
function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform);
|
||||
|
||||
/**
|
||||
* Gets the column alias.
|
||||
*
|
||||
* @param string $columnName
|
||||
* @param integer $counter
|
||||
* @param AbstractPlatform $platform
|
||||
* @param ClassMetadata $class
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getColumnAlias($columnName, $counter, ClassMetadata $class = null);
|
||||
function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = null);
|
||||
|
||||
}
|
@ -45,6 +45,13 @@ abstract class AbstractCollectionPersister
|
||||
*/
|
||||
protected $_uow;
|
||||
|
||||
/**
|
||||
* The database platform.
|
||||
*
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
protected $platform;
|
||||
|
||||
/**
|
||||
* The quote strategy.
|
||||
*
|
||||
@ -62,7 +69,8 @@ abstract class AbstractCollectionPersister
|
||||
$this->_em = $em;
|
||||
$this->_uow = $em->getUnitOfWork();
|
||||
$this->_conn = $em->getConnection();
|
||||
$this->quoteStrategy = $em->getQuoteStrategy();
|
||||
$this->platform = $this->_conn->getDatabasePlatform();
|
||||
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
|
||||
protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
|
||||
{
|
||||
$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);
|
||||
$this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name);
|
||||
|
||||
|
@ -198,8 +198,8 @@ class BasicEntityPersister
|
||||
$this->_em = $em;
|
||||
$this->_class = $class;
|
||||
$this->_conn = $em->getConnection();
|
||||
$this->quoteStrategy = $em->getQuoteStrategy();
|
||||
$this->_platform = $this->_conn->getDatabasePlatform();
|
||||
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,13 +298,13 @@ class BasicEntityPersister
|
||||
protected function fetchVersionValue($versionedClass, $id)
|
||||
{
|
||||
$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
|
||||
$sql = 'SELECT ' . $versionFieldColumnName
|
||||
. ' FROM ' . $this->quoteStrategy->getTableName($versionedClass)
|
||||
. ' FROM ' . $this->quoteStrategy->getTableName($versionedClass, $this->_platform)
|
||||
. ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';
|
||||
$value = $this->_conn->fetchColumn($sql, array_values((array)$id));
|
||||
|
||||
@ -332,7 +332,7 @@ class BasicEntityPersister
|
||||
|
||||
if (isset($updateData[$tableName]) && $updateData[$tableName]) {
|
||||
$this->_updateTable(
|
||||
$entity, $this->quoteStrategy->getTableName($this->_class),
|
||||
$entity, $this->quoteStrategy->getTableName($this->_class, $this->_platform),
|
||||
$updateData[$tableName], $this->_class->isVersioned
|
||||
);
|
||||
|
||||
@ -361,7 +361,7 @@ class BasicEntityPersister
|
||||
$placeholder = '?';
|
||||
|
||||
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'])) {
|
||||
$type = Type::getType($this->_columnTypes[$columnName]);
|
||||
@ -386,7 +386,7 @@ class BasicEntityPersister
|
||||
$params[] = $id[$idField];
|
||||
$types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
|
||||
} else {
|
||||
$where[] = $this->quoteStrategy->getColumnName($idField, $this->_class);
|
||||
$where[] = $this->quoteStrategy->getColumnName($idField, $this->_class, $this->_platform);
|
||||
$params[] = $id[$idField];
|
||||
$types[] = $this->_class->fieldMappings[$idField]['type'];
|
||||
}
|
||||
@ -395,7 +395,7 @@ class BasicEntityPersister
|
||||
if ($versioned) {
|
||||
$versionField = $this->_class->versionField;
|
||||
$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) {
|
||||
$set[] = $versionColumn . ' = ' . $versionColumn . ' + 1';
|
||||
@ -439,30 +439,30 @@ class BasicEntityPersister
|
||||
$mapping = $relatedClass->associationMappings[$mapping['mappedBy']];
|
||||
|
||||
foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) {
|
||||
$keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass);
|
||||
$keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass, $this->_platform);
|
||||
}
|
||||
|
||||
if ($selfReferential) {
|
||||
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
|
||||
$otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass);
|
||||
$otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass, $this->_platform);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
|
||||
$keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class);
|
||||
$keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
|
||||
}
|
||||
|
||||
if ($selfReferential) {
|
||||
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'])) {
|
||||
|
||||
$joinTableName = $this->quoteStrategy->getJoinTableName($mapping, $this->_class);
|
||||
$joinTableName = $this->quoteStrategy->getJoinTableName($mapping, $this->_class, $this->_platform);
|
||||
$this->_conn->delete($joinTableName, array_combine($keys, $identifier));
|
||||
|
||||
if ($selfReferential) {
|
||||
@ -488,8 +488,8 @@ class BasicEntityPersister
|
||||
$identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
|
||||
$this->deleteJoinTableRecords($identifier);
|
||||
|
||||
$id = array_combine($this->quoteStrategy->getIdentifierColumnNames($this->_class), $identifier);
|
||||
$this->_conn->delete($this->quoteStrategy->getTableName($this->_class), $id);
|
||||
$id = array_combine($this->quoteStrategy->getIdentifierColumnNames($this->_class, $this->_platform), $identifier);
|
||||
$this->_conn->delete($this->quoteStrategy->getTableName($this->_class, $this->_platform), $id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -561,7 +561,7 @@ class BasicEntityPersister
|
||||
$sourceColumn = $joinColumn['name'];
|
||||
$targetColumn = $joinColumn['referencedColumnName'];
|
||||
|
||||
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class);
|
||||
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
|
||||
$this->quotedColumns[$sourceColumn] = $quotedColumn;
|
||||
|
||||
if ($newVal === null) {
|
||||
@ -841,7 +841,7 @@ class BasicEntityPersister
|
||||
$sourceClass = $this->_em->getClassMetadata($assoc['sourceEntity']);
|
||||
|
||||
if ($assoc['isOwningSide']) {
|
||||
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass);
|
||||
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->_platform);
|
||||
|
||||
foreach ($assoc['relationToSourceKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) {
|
||||
if ($sourceClass->containsForeignIdentifier) {
|
||||
@ -864,7 +864,7 @@ class BasicEntityPersister
|
||||
}
|
||||
} else {
|
||||
$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
|
||||
foreach ($owningAssoc['relationToTargetKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) {
|
||||
@ -934,7 +934,7 @@ class BasicEntityPersister
|
||||
}
|
||||
|
||||
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)
|
||||
. $this->_selectJoinSql . $joinSql
|
||||
. ($conditionSql ? ' WHERE ' . $conditionSql : '')
|
||||
@ -967,7 +967,7 @@ class BasicEntityPersister
|
||||
$this->_getSQLTableAlias($this->_class->fieldMappings[$fieldName]['inherited'])
|
||||
: $baseTableAlias;
|
||||
|
||||
$columnName = $this->quoteStrategy->getColumnName($fieldName, $this->_class);
|
||||
$columnName = $this->quoteStrategy->getColumnName($fieldName, $this->_class, $this->_platform);
|
||||
|
||||
$orderBySql .= $orderBySql ? ', ' : ' ORDER BY ';
|
||||
$orderBySql .= $tableAlias . '.' . $columnName . ' ' . $orientation;
|
||||
@ -1045,12 +1045,12 @@ class BasicEntityPersister
|
||||
|
||||
if ($assoc['isOwningSide']) {
|
||||
$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);
|
||||
foreach ($assoc['joinColumns'] as $joinColumn) {
|
||||
$sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class);
|
||||
$targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class);
|
||||
$sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
|
||||
$targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class, $this->_platform);
|
||||
|
||||
if ( ! $first) {
|
||||
$this->_selectJoinSql .= ' AND ';
|
||||
@ -1069,7 +1069,7 @@ class BasicEntityPersister
|
||||
$owningAssoc = $eagerEntity->getAssociationMapping($assoc['mappedBy']);
|
||||
|
||||
$this->_selectJoinSql .= ' LEFT JOIN';
|
||||
$this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity) . ' '
|
||||
$this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity, $this->_platform) . ' '
|
||||
. $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) . ' ON ';
|
||||
|
||||
foreach ($owningAssoc['sourceToTargetKeyColumns'] as $sourceCol => $targetCol) {
|
||||
@ -1109,7 +1109,7 @@ class BasicEntityPersister
|
||||
|
||||
if ($columnList) $columnList .= ', ';
|
||||
|
||||
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class);
|
||||
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
|
||||
$resultColumnName = $this->getSQLColumnAlias($joinColumn['name']);
|
||||
$columnList .= $this->_getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias) )
|
||||
. '.' . $quotedColumn . ' AS ' . $resultColumnName;
|
||||
@ -1137,7 +1137,7 @@ class BasicEntityPersister
|
||||
$joinClauses = $owningAssoc['relationToSourceKeyColumns'];
|
||||
}
|
||||
|
||||
$joinTableName = $this->quoteStrategy->getJoinTableName($owningAssoc, $this->_class);
|
||||
$joinTableName = $this->quoteStrategy->getJoinTableName($owningAssoc, $this->_class, $this->_platform);
|
||||
$joinSql = '';
|
||||
|
||||
foreach ($joinClauses as $joinTableColumn => $sourceColumn) {
|
||||
@ -1146,7 +1146,7 @@ class BasicEntityPersister
|
||||
if ($this->_class->containsForeignIdentifier && ! isset($this->_class->fieldNames[$sourceColumn])) {
|
||||
$quotedColumn = $sourceColumn; // join columns cannot be quoted
|
||||
} 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 . ' = '
|
||||
@ -1169,8 +1169,8 @@ class BasicEntityPersister
|
||||
|
||||
if (empty($columns)) {
|
||||
$insertSql = $this->_platform->getEmptyIdentityInsertSQL(
|
||||
$this->quoteStrategy->getTableName($this->_class),
|
||||
$this->quoteStrategy->getColumnName($this->_class->identifier[0], $this->_class)
|
||||
$this->quoteStrategy->getTableName($this->_class, $this->_platform),
|
||||
$this->quoteStrategy->getColumnName($this->_class->identifier[0], $this->_class, $this->_platform)
|
||||
);
|
||||
} else {
|
||||
$columns = array_unique($columns);
|
||||
@ -1189,7 +1189,7 @@ class BasicEntityPersister
|
||||
$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) . ')';
|
||||
}
|
||||
|
||||
@ -1220,11 +1220,11 @@ class BasicEntityPersister
|
||||
$assoc = $this->_class->associationMappings[$name];
|
||||
if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) {
|
||||
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) {
|
||||
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class);
|
||||
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform);
|
||||
$this->_columnTypes[$name] = $this->_class->fieldMappings[$name]['type'];
|
||||
}
|
||||
}
|
||||
@ -1243,7 +1243,7 @@ class BasicEntityPersister
|
||||
protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
|
||||
{
|
||||
$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]);
|
||||
|
||||
$this->_rsm->addFieldResult($alias, $columnAlias, $field);
|
||||
@ -1313,7 +1313,7 @@ class BasicEntityPersister
|
||||
*/
|
||||
protected function getLockTablesSql()
|
||||
{
|
||||
return 'FROM ' . $this->quoteStrategy->getTableName($this->_class) . ' '
|
||||
return 'FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' '
|
||||
. $this->_getSQLTableAlias($this->_class->name);
|
||||
}
|
||||
|
||||
@ -1342,7 +1342,7 @@ class BasicEntityPersister
|
||||
? $this->_class->fieldMappings[$field]['inherited']
|
||||
: $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'])) {
|
||||
$type = Type::getType($this->_class->getTypeOfField($field));
|
||||
@ -1610,7 +1610,7 @@ class BasicEntityPersister
|
||||
*/
|
||||
public function getSQLColumnAlias($columnName)
|
||||
{
|
||||
return $this->quoteStrategy->getColumnAlias($columnName, $this->_sqlAliasCounter++);
|
||||
return $this->quoteStrategy->getColumnAlias($columnName, $this->_sqlAliasCounter++, $this->_platform);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +105,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
||||
$tableName = $cm->getTableName();
|
||||
|
||||
$this->_owningTableMap[$fieldName] = $tableName;
|
||||
$this->_quotedTableMap[$tableName] = $this->quoteStrategy->getTableName($cm);
|
||||
$this->_quotedTableMap[$tableName] = $this->quoteStrategy->getTableName($cm, $this->_platform);
|
||||
|
||||
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
|
||||
// table were affected.
|
||||
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);
|
||||
$this->assignDefaultVersionValue($entity, $id);
|
||||
@ -247,15 +247,15 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
||||
// delete the row from the root table. Cascades do the rest.
|
||||
if ($this->_platform->supportsForeignKeyConstraints()) {
|
||||
$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 {
|
||||
// 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) {
|
||||
$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) {
|
||||
$parentClass = $this->_em->getClassMetadata($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;
|
||||
|
||||
foreach ($idColumns as $idColumn) {
|
||||
@ -361,7 +361,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
foreach ($idColumns as $idColumn) {
|
||||
@ -400,7 +400,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
||||
}
|
||||
|
||||
return $this->_platform->modifyLimitQuery('SELECT ' . $this->_selectColumnListSql
|
||||
. ' FROM ' . $this->quoteStrategy->getTableName($this->_class) . ' ' . $baseTableAlias
|
||||
. ' FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' . $baseTableAlias
|
||||
. $joinSql
|
||||
. ($conditionSql != '' ? ' WHERE ' . $conditionSql : '') . $orderBySql, $limit, $offset)
|
||||
. $lockSql;
|
||||
@ -422,7 +422,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
||||
foreach ($this->_class->parentClasses as $parentClassName) {
|
||||
$parentClass = $this->_em->getClassMetadata($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;
|
||||
|
||||
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. */
|
||||
@ -463,7 +463,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
||||
}
|
||||
} else if ($this->_class->name != $this->_class->rootEntityName ||
|
||||
! $this->_class->isIdGeneratorIdentity() || $this->_class->identifier[0] != $name) {
|
||||
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class);
|
||||
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$mapping = $coll->getMapping();
|
||||
$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']) . ' = ?';
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$mapping = $coll->getMapping();
|
||||
$columns = $mapping['joinTableColumns'];
|
||||
$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) . ')'
|
||||
. ' VALUES (' . implode(', ', array_fill(0, count($columns), '?')) . ')';
|
||||
@ -151,7 +151,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
{
|
||||
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
||||
$mapping = $coll->getMapping();
|
||||
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class);
|
||||
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform);
|
||||
|
||||
return 'DELETE FROM ' . $joinTable
|
||||
. ' WHERE ' . implode(' = ? AND ', array_keys($mapping['relationToSourceKeyColumns'])) . ' = ?';
|
||||
@ -224,7 +224,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
}
|
||||
|
||||
$sql = 'SELECT COUNT(*)'
|
||||
. ' FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class) . ' t'
|
||||
. ' FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform) . ' t'
|
||||
. $joinTargetEntitySQL
|
||||
. ' WHERE ' . implode(' AND ', $whereClauses);
|
||||
|
||||
@ -326,7 +326,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$targetId = $uow->getEntityIdentifier($element);
|
||||
}
|
||||
|
||||
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $sourceClass);
|
||||
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $sourceClass, $this->platform);
|
||||
$whereClauses = array();
|
||||
$params = array();
|
||||
|
||||
@ -387,7 +387,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$joinTargetEntitySQL = '';
|
||||
if ($filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) {
|
||||
$joinTargetEntitySQL = ' JOIN '
|
||||
. $this->quoteStrategy->getTableName($targetClass) . ' te'
|
||||
. $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' te'
|
||||
. ' ON';
|
||||
|
||||
$joinTargetEntitySQLClauses = array();
|
||||
|
@ -45,7 +45,7 @@ class OneToManyPersister extends AbstractCollectionPersister
|
||||
$mapping = $coll->getMapping();
|
||||
$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()) . ' = ?';
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ class OneToManyPersister extends AbstractCollectionPersister
|
||||
}
|
||||
|
||||
$sql = 'SELECT count(*)'
|
||||
. ' FROM ' . $this->quoteStrategy->getTableName($targetClass) . ' t'
|
||||
. ' FROM ' . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' t'
|
||||
. ' WHERE ' . implode(' AND ', $whereClauses);
|
||||
|
||||
return $this->_conn->fetchColumn($sql, $params);
|
||||
@ -204,7 +204,7 @@ class OneToManyPersister extends AbstractCollectionPersister
|
||||
|
||||
$mapping = $coll->getMapping();
|
||||
$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()) . ' = ?';
|
||||
|
||||
return (bool) $this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element));
|
||||
|
@ -42,7 +42,8 @@ class SizeFunction extends FunctionNode
|
||||
*/
|
||||
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;
|
||||
$assocField = $this->collectionPathExpression->field;
|
||||
|
||||
@ -56,7 +57,7 @@ class SizeFunction extends FunctionNode
|
||||
$targetTableAlias = $sqlWalker->getSQLTableAlias($targetClass->getTableName());
|
||||
$sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias);
|
||||
|
||||
$sql .= $quoteStrategy->getTableName($targetClass) . ' ' . $targetTableAlias . ' WHERE ';
|
||||
$sql .= $quoteStrategy->getTableName($targetClass, $platform) . ' ' . $targetTableAlias . ' WHERE ';
|
||||
|
||||
$owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']];
|
||||
|
||||
@ -67,7 +68,7 @@ class SizeFunction extends FunctionNode
|
||||
|
||||
$sql .= $targetTableAlias . '.' . $sourceColumn
|
||||
. ' = '
|
||||
. $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class);
|
||||
. $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $platform);
|
||||
}
|
||||
} else { // many-to-many
|
||||
$targetClass = $sqlWalker->getEntityManager()->getClassMetadata($assoc['targetEntity']);
|
||||
@ -80,7 +81,7 @@ class SizeFunction extends FunctionNode
|
||||
$sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias);
|
||||
|
||||
// join to target table
|
||||
$sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass) . ' ' . $joinTableAlias . ' WHERE ';
|
||||
$sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $platform) . ' ' . $joinTableAlias . ' WHERE ';
|
||||
|
||||
$joinColumns = $assoc['isOwningSide']
|
||||
? $joinTable['joinColumns']
|
||||
@ -92,7 +93,7 @@ class SizeFunction extends FunctionNode
|
||||
if ($first) $first = false; else $sql .= ' AND ';
|
||||
|
||||
$sourceColumnName = $quoteStrategy->getColumnName(
|
||||
$class->fieldNames[$joinColumn['referencedColumnName']], $class
|
||||
$class->fieldNames[$joinColumn['referencedColumnName']], $class, $platform
|
||||
);
|
||||
|
||||
$sql .= $joinTableAlias . '.' . $joinColumn['name']
|
||||
|
@ -50,7 +50,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
|
||||
$em = $sqlWalker->getEntityManager();
|
||||
$conn = $em->getConnection();
|
||||
$platform = $conn->getDatabasePlatform();
|
||||
$quoteStrategy = $em->getQuoteStrategy();
|
||||
$quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
|
||||
|
||||
$primaryClass = $em->getClassMetadata($AST->deleteClause->abstractSchemaName);
|
||||
$primaryDqlAlias = $AST->deleteClause->aliasIdentificationVariable;
|
||||
@ -81,7 +81,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
|
||||
// 3. Create and store DELETE statements
|
||||
$classNames = array_merge($primaryClass->parentClasses, array($primaryClass->name), $primaryClass->subClasses);
|
||||
foreach (array_reverse($classNames) as $className) {
|
||||
$tableName = $quoteStrategy->getTableName($em->getClassMetadata($className));
|
||||
$tableName = $quoteStrategy->getTableName($em->getClassMetadata($className), $platform);
|
||||
$this->_sqlStatements[] = 'DELETE FROM ' . $tableName
|
||||
. ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')';
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
$em = $sqlWalker->getEntityManager();
|
||||
$conn = $em->getConnection();
|
||||
$platform = $conn->getDatabasePlatform();
|
||||
$quoteStrategy = $em->getQuoteStrategy();
|
||||
$quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
|
||||
|
||||
$updateClause = $AST->updateClause;
|
||||
$primaryClass = $sqlWalker->getEntityManager()->getClassMetadata($updateClause->abstractSchemaName);
|
||||
@ -86,7 +86,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
foreach (array_reverse($classNames) as $className) {
|
||||
$affected = false;
|
||||
$class = $em->getClassMetadata($className);
|
||||
$updateSql = 'UPDATE ' . $quoteStrategy->getTableName($class) . ' SET ';
|
||||
$updateSql = 'UPDATE ' . $quoteStrategy->getTableName($class, $platform) . ' SET ';
|
||||
|
||||
foreach ($updateItems as $updateItem) {
|
||||
$field = $updateItem->pathExpression->field;
|
||||
|
@ -170,8 +170,8 @@ class SqlWalker implements TreeWalker
|
||||
$this->rsm = $parserResult->getResultSetMapping();
|
||||
$this->em = $query->getEntityManager();
|
||||
$this->conn = $this->em->getConnection();
|
||||
$this->quoteStrategy = $this->em->getQuoteStrategy();
|
||||
$this->platform = $this->conn->getDatabasePlatform();
|
||||
$this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -286,7 +286,7 @@ class SqlWalker implements TreeWalker
|
||||
*/
|
||||
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.
|
||||
$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();
|
||||
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($class) as $columnName) {
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) {
|
||||
$sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName;
|
||||
}
|
||||
|
||||
@ -336,11 +336,11 @@ class SqlWalker implements TreeWalker
|
||||
$subClass = $this->em->getClassMetadata($subClassName);
|
||||
$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();
|
||||
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($subClass) as $columnName) {
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($subClass, $this->platform) as $columnName) {
|
||||
$sqlParts[] = $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName;
|
||||
}
|
||||
|
||||
@ -361,7 +361,7 @@ class SqlWalker implements TreeWalker
|
||||
if ( ! isset($qComp['relation']['orderBy'])) continue;
|
||||
|
||||
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())
|
||||
? $this->em->getUnitOfWork()->getEntityPersister($qComp['metadata']->name)->getOwningTable($fieldName)
|
||||
: $qComp['metadata']->getTableName();
|
||||
@ -544,7 +544,7 @@ class SqlWalker implements TreeWalker
|
||||
$tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable);
|
||||
$sqlParts = array();
|
||||
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($class) as $columnName) {
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($class, $this->platform) as $columnName) {
|
||||
$sqlParts[] = $tableAlias . '.' . $columnName;
|
||||
}
|
||||
|
||||
@ -592,7 +592,7 @@ class SqlWalker implements TreeWalker
|
||||
$sql .= $this->walkIdentificationVariable($dqlAlias, $fieldName) . '.';
|
||||
}
|
||||
|
||||
$sql .= $this->quoteStrategy->getColumnName($fieldName, $class);
|
||||
$sql .= $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
|
||||
break;
|
||||
|
||||
case AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION:
|
||||
@ -1161,7 +1161,7 @@ class SqlWalker implements TreeWalker
|
||||
: $class->getTableName();
|
||||
|
||||
$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']);
|
||||
|
||||
$col = $sqlTableAlias . '.' . $columnName;
|
||||
@ -1257,7 +1257,7 @@ class SqlWalker implements TreeWalker
|
||||
|
||||
$sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias);
|
||||
$columnAlias = $this->getSQLColumnAlias($mapping['columnName']);
|
||||
$quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class);
|
||||
$quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
|
||||
|
||||
$col = $sqlTableAlias . '.' . $quotedColumnName;
|
||||
|
||||
@ -1288,7 +1288,7 @@ class SqlWalker implements TreeWalker
|
||||
}
|
||||
|
||||
$columnAlias = $this->getSQLColumnAlias($mapping['columnName']);
|
||||
$quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass);
|
||||
$quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform);
|
||||
|
||||
$col = $sqlTableAlias . '.' . $quotedColumnName;
|
||||
|
||||
@ -1523,7 +1523,7 @@ class SqlWalker implements TreeWalker
|
||||
{
|
||||
$class = $this->em->getClassMetadata($deleteClause->abstractSchemaName);
|
||||
$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->rootAliases[] = $deleteClause->aliasIdentificationVariable;
|
||||
@ -1541,7 +1541,7 @@ class SqlWalker implements TreeWalker
|
||||
{
|
||||
$class = $this->em->getClassMetadata($updateClause->abstractSchemaName);
|
||||
$tableName = $class->getTableName();
|
||||
$sql = 'UPDATE ' . $this->quoteStrategy->getTableName($class);
|
||||
$sql = 'UPDATE ' . $this->quoteStrategy->getTableName($class, $this->platform);
|
||||
|
||||
$this->setSQLTableAlias($tableName, $tableName, $updateClause->aliasIdentificationVariable);
|
||||
$this->rootAliases[] = $updateClause->aliasIdentificationVariable;
|
||||
@ -1752,18 +1752,18 @@ class SqlWalker implements TreeWalker
|
||||
$targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName());
|
||||
$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']];
|
||||
$sqlParts = array();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass) as $targetColumnName) {
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass, $this->platform) as $targetColumnName) {
|
||||
if (isset($dqlParamKey)) {
|
||||
$this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++);
|
||||
}
|
||||
@ -1784,15 +1784,15 @@ class SqlWalker implements TreeWalker
|
||||
$sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
|
||||
|
||||
// join to target table
|
||||
$sql .= $this->quoteStrategy->getJoinTableName($owningAssoc, $targetClass) . ' ' . $joinTableAlias
|
||||
. ' INNER JOIN ' . $this->quoteStrategy->getTableName($targetClass) . ' ' . $targetTableAlias . ' ON ';
|
||||
$sql .= $this->quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $this->platform) . ' ' . $joinTableAlias
|
||||
. ' INNER JOIN ' . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' ON ';
|
||||
|
||||
// join conditions
|
||||
$joinColumns = $assoc['isOwningSide'] ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns'];
|
||||
$joinSqlParts = array();
|
||||
|
||||
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;
|
||||
}
|
||||
@ -1804,12 +1804,12 @@ class SqlWalker implements TreeWalker
|
||||
$sqlParts = array();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass) as $targetColumnName) {
|
||||
foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass, $this->platform) as $targetColumnName) {
|
||||
if (isset($dqlParamKey)) {
|
||||
$this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class SchemaTool
|
||||
*
|
||||
* @var \Doctrine\ORM\Mapping\QuoteStrategy
|
||||
*/
|
||||
protected $quoteStrategy;
|
||||
private $quoteStrategy;
|
||||
|
||||
/**
|
||||
* Initializes a new SchemaTool instance that uses the connection of the
|
||||
@ -69,8 +69,8 @@ class SchemaTool
|
||||
public function __construct(EntityManager $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->quoteStrategy = $em->getQuoteStrategy();
|
||||
$this->platform = $em->getConnection()->getDatabasePlatform();
|
||||
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,7 +145,7 @@ class SchemaTool
|
||||
continue;
|
||||
}
|
||||
|
||||
$table = $schema->createTable($this->quoteStrategy->getTableName($class));
|
||||
$table = $schema->createTable($this->quoteStrategy->getTableName($class, $this->platform));
|
||||
$columns = array(); // table columns
|
||||
|
||||
if ($class->isInheritanceTypeSingleTable()) {
|
||||
@ -172,7 +172,7 @@ class SchemaTool
|
||||
$pkColumns = array();
|
||||
foreach ($class->fieldMappings as $fieldName => $mapping) {
|
||||
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);
|
||||
|
||||
if ($class->isIdentifier($fieldName)) {
|
||||
@ -191,7 +191,7 @@ class SchemaTool
|
||||
/* @var \Doctrine\ORM\Mapping\ClassMetadata $class */
|
||||
$idMapping = $class->fieldMappings[$class->identifier[0]];
|
||||
$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?
|
||||
$table->getColumn($columnName)->setAutoincrement(false);
|
||||
|
||||
@ -199,7 +199,7 @@ class SchemaTool
|
||||
|
||||
// Add a FK constraint on the ID column
|
||||
$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')
|
||||
);
|
||||
}
|
||||
@ -216,12 +216,12 @@ class SchemaTool
|
||||
$pkColumns = array();
|
||||
foreach ($class->identifier as $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])) {
|
||||
/* @var $assoc \Doctrine\ORM\Mapping\OneToOne */
|
||||
$assoc = $class->associationMappings[$identifierField];
|
||||
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) {
|
||||
$seqDef = $class->sequenceGeneratorDefinition;
|
||||
$quotedName = $this->quoteStrategy->getSequenceName($seqDef, $class);
|
||||
$quotedName = $this->quoteStrategy->getSequenceName($seqDef, $class, $this->platform);
|
||||
if ( ! $schema->hasSequence($quotedName)) {
|
||||
$schema->createSequence(
|
||||
$quotedName,
|
||||
@ -328,7 +328,7 @@ class SchemaTool
|
||||
$column = $this->_gatherColumn($class, $mapping, $table);
|
||||
|
||||
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)
|
||||
{
|
||||
$columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class);
|
||||
$columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
|
||||
$columnType = $mapping['type'];
|
||||
|
||||
$options = array();
|
||||
@ -441,7 +441,7 @@ class SchemaTool
|
||||
// create join table
|
||||
$joinTable = $mapping['joinTable'];
|
||||
|
||||
$theJoinTable = $schema->createTable($this->quoteStrategy->getJoinTableName($mapping, $foreignClass));
|
||||
$theJoinTable = $schema->createTable($this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform));
|
||||
|
||||
$primaryKeyColumns = $uniqueConstraints = array();
|
||||
|
||||
@ -509,7 +509,7 @@ class SchemaTool
|
||||
$localColumns = array();
|
||||
$foreignColumns = array();
|
||||
$fkOptions = array();
|
||||
$foreignTableName = $this->quoteStrategy->getTableName($class);
|
||||
$foreignTableName = $this->quoteStrategy->getTableName($class, $this->platform);
|
||||
|
||||
foreach ($joinColumns as $joinColumn) {
|
||||
|
||||
@ -522,8 +522,8 @@ class SchemaTool
|
||||
);
|
||||
}
|
||||
|
||||
$quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class);
|
||||
$quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $class);
|
||||
$quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
|
||||
$quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $class, $this->platform);
|
||||
|
||||
$primaryKeyColumns[] = $quotedColumnName;
|
||||
$localColumns[] = $quotedColumnName;
|
||||
|
@ -19,11 +19,17 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
|
||||
*/
|
||||
private $strategy;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $platform;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$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' => 'id', 'columnName' => 'id'));
|
||||
|
||||
$this->assertEquals('id' ,$this->strategy->getColumnName('id', $cm));
|
||||
$this->assertEquals('"name"' ,$this->strategy->getColumnName('name', $cm));
|
||||
$this->assertEquals('id' ,$this->strategy->getColumnName('id', $cm, $this->platform));
|
||||
$this->assertEquals('"name"' ,$this->strategy->getColumnName('name', $cm, $this->platform));
|
||||
}
|
||||
|
||||
public function testGetTableName()
|
||||
{
|
||||
$cm = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$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->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
||||
$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()
|
||||
@ -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($cm2->associationMappings['user'], $cm2));
|
||||
$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->platform));
|
||||
|
||||
}
|
||||
|
||||
@ -106,18 +112,18 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
|
||||
'columnName' => 'id',
|
||||
));
|
||||
|
||||
$this->assertEquals(array('"id"'), $this->strategy->getIdentifierColumnNames($cm1));
|
||||
$this->assertEquals(array('id'), $this->strategy->getIdentifierColumnNames($cm2));
|
||||
$this->assertEquals(array('"id"'), $this->strategy->getIdentifierColumnNames($cm1, $this->platform));
|
||||
$this->assertEquals(array('id'), $this->strategy->getIdentifierColumnNames($cm2, $this->platform));
|
||||
}
|
||||
|
||||
|
||||
public function testColumnAlias()
|
||||
{
|
||||
$i = 0;
|
||||
$this->assertEquals('columnName0', $this->strategy->getColumnAlias('columnName', $i++));
|
||||
$this->assertEquals('column_name1', $this->strategy->getColumnAlias('column_name', $i++));
|
||||
$this->assertEquals('COLUMN_NAME2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++));
|
||||
$this->assertEquals('COLUMNNAME3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++));
|
||||
$this->assertEquals('columnName0', $this->strategy->getColumnAlias('columnName', $i++, $this->platform));
|
||||
$this->assertEquals('column_name1', $this->strategy->getColumnAlias('column_name', $i++, $this->platform));
|
||||
$this->assertEquals('COLUMN_NAME2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++, $this->platform));
|
||||
$this->assertEquals('COLUMNNAME3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++, $this->platform));
|
||||
}
|
||||
|
||||
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()
|
||||
@ -150,7 +156,7 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
|
||||
));
|
||||
|
||||
$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()
|
||||
@ -167,6 +173,6 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase
|
||||
));
|
||||
|
||||
$joinColumn = $cm->associationMappings['article']['joinColumns'][0];
|
||||
$this->assertEquals('"id"',$this->strategy->getReferencedJoinColumnName($joinColumn, $cm));
|
||||
$this->assertEquals('"id"',$this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user