[2.0][DDC-24] Fixed (together with some small misc. refactorings).
This commit is contained in:
parent
8f2d59c289
commit
435acc9188
@ -1551,6 +1551,13 @@ abstract class AbstractPlatform
|
||||
* @param array $field
|
||||
*/
|
||||
abstract public function getVarcharTypeDeclarationSql(array $field);
|
||||
|
||||
/**
|
||||
* Gets the SQL snippet used to declare a CLOB column type.
|
||||
*
|
||||
* @param array $field
|
||||
*/
|
||||
abstract public function getClobTypeDeclarationSql(array $field);
|
||||
|
||||
/**
|
||||
* Gets the name of the platform.
|
||||
|
@ -365,6 +365,12 @@ class MsSqlPlatform extends AbstractPlatform
|
||||
return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)')
|
||||
: ($length ? 'VARCHAR(' . $length . ')' : 'TEXT');
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getClobTypeDeclarationSql(array $field)
|
||||
{
|
||||
return 'TEXT';
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
|
@ -231,7 +231,8 @@ class MySqlPlatform extends AbstractPlatform
|
||||
: ($length ? 'VARCHAR(' . $length . ')' : 'VARCHAR(255)');
|
||||
}
|
||||
|
||||
public function getClobDeclarationSql(array $field)
|
||||
/** @override */
|
||||
public function getClobTypeDeclarationSql(array $field)
|
||||
{
|
||||
if ( ! empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
|
@ -223,6 +223,12 @@ class OraclePlatform extends AbstractPlatform
|
||||
return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(2000)')
|
||||
: ($length ? 'VARCHAR2(' . $length . ')' : 'VARCHAR2(4000)');
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getClobTypeDeclarationSql(array $field)
|
||||
{
|
||||
return 'CLOB';
|
||||
}
|
||||
|
||||
public function getListDatabasesSql()
|
||||
{
|
||||
|
@ -742,6 +742,12 @@ class PostgreSqlPlatform extends AbstractPlatform
|
||||
return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)')
|
||||
: ($length ? 'VARCHAR(' . $length . ')' : 'TEXT');
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getClobTypeDeclarationSql(array $field)
|
||||
{
|
||||
return 'TEXT';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the platform name for this instance
|
||||
|
@ -370,6 +370,11 @@ class SqlitePlatform extends AbstractPlatform
|
||||
return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)')
|
||||
: ($length ? 'VARCHAR(' . $length . ')' : 'TEXT');
|
||||
}
|
||||
|
||||
public function getClobTypeDeclarationSql(array $field)
|
||||
{
|
||||
return 'CLOB';
|
||||
}
|
||||
|
||||
public function getListSequencesSql($database)
|
||||
{
|
||||
|
@ -172,6 +172,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
|
||||
$length = 1;
|
||||
break;
|
||||
case 'text':
|
||||
$fixed = false;
|
||||
$type = 'text';
|
||||
break;
|
||||
case 'varchar':
|
||||
case 'interval':
|
||||
case '_varchar':
|
||||
@ -186,7 +189,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
|
||||
$type = 'boolean';
|
||||
}
|
||||
} elseif (strstr($dbType, 'text')) {
|
||||
$type = 'clob';
|
||||
$type = 'text';
|
||||
}
|
||||
if ($fixed !== false) {
|
||||
$fixed = true;
|
||||
|
@ -138,6 +138,9 @@ class SqliteSchemaManager extends AbstractSchemaManager
|
||||
$length = 8;
|
||||
break;
|
||||
case 'clob':
|
||||
$fixed = false;
|
||||
$type = 'text';
|
||||
break;
|
||||
case 'tinytext':
|
||||
case 'mediumtext':
|
||||
case 'longtext':
|
||||
|
@ -11,7 +11,7 @@ class ObjectType extends Type
|
||||
{
|
||||
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
|
||||
{
|
||||
return $platform->getClobDeclarationSql($fieldDeclaration);
|
||||
return $platform->getClobTypeDeclarationSql($fieldDeclaration);
|
||||
}
|
||||
|
||||
public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
|
||||
|
@ -12,7 +12,7 @@ class TextType extends Type
|
||||
/** @override */
|
||||
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
|
||||
{
|
||||
return $platform->getClobDeclarationSql($fieldDeclaration);
|
||||
return $platform->getClobTypeDeclarationSql($fieldDeclaration);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
@ -134,7 +134,7 @@ class EntityRepository
|
||||
$by = substr($method, 9, strlen($method));
|
||||
$method = 'findOneBy';
|
||||
} else {
|
||||
throw new BadMethodCallException("Undefined method '$method'.");
|
||||
throw new \BadMethodCallException("Undefined method '$method'.");
|
||||
}
|
||||
|
||||
if ( ! isset($arguments[0])) {
|
||||
|
@ -340,7 +340,7 @@ class ObjectHydrator extends AbstractHydrator
|
||||
} else {
|
||||
// Single-valued association
|
||||
$reflFieldValue = $reflField->getValue($baseElement);
|
||||
if ( ! $reflFieldValue) {
|
||||
if ( ! $reflFieldValue /* || doctrine.refresh hint set */) {
|
||||
if (isset($nonemptyComponents[$dqlAlias])) {
|
||||
$element = $this->_getEntity($data, $dqlAlias);
|
||||
$reflField->setValue($baseElement, $element);
|
||||
@ -350,7 +350,7 @@ class ObjectHydrator extends AbstractHydrator
|
||||
// If there is an inverse mapping on the target class its bidirectional
|
||||
if (isset($targetClass->inverseMappings[$relation->sourceEntityName][$relationField])) {
|
||||
$sourceProp = $targetClass->inverseMappings[$relation->sourceEntityName][$relationField]->sourceFieldName;
|
||||
$targetClass->reflFields[$sourceProp]->setValue($element, $base);
|
||||
$targetClass->reflFields[$sourceProp]->setValue($element, $baseElement);
|
||||
} else if ($this->_ce[$parentClass] === $targetClass && $relation->mappedByFieldName) {
|
||||
// Special case: bi-directional self-referencing one-one on the same class
|
||||
$targetClass->reflFields[$relationField]->setValue($element, $baseElement);
|
||||
|
@ -109,19 +109,25 @@ class ProxyClassGenerator
|
||||
|
||||
$methods = $this->_generateMethods($class);
|
||||
$sleepImpl = $this->_generateSleep($class);
|
||||
$constructorInv = $class->reflClass->hasMethod('__construct') ? 'parent::__construct();' : '';
|
||||
|
||||
$placeholders = array(
|
||||
'<proxyClassName>', '<className>',
|
||||
'<methods>', '<sleepImpl>'
|
||||
'<methods>', '<sleepImpl>',
|
||||
'<constructorInvocation>'
|
||||
);
|
||||
$replacements = array(
|
||||
$proxyClassName, $originalClassName, $methods, $sleepImpl
|
||||
$proxyClassName, $originalClassName,
|
||||
$methods, $sleepImpl,
|
||||
$constructorInv
|
||||
);
|
||||
|
||||
$file = str_replace($placeholders, $replacements, $file);
|
||||
|
||||
file_put_contents($fileName, $file);
|
||||
|
||||
require $fileName;
|
||||
|
||||
return $proxyFullyQualifiedClassName;
|
||||
}
|
||||
|
||||
@ -130,7 +136,7 @@ class ProxyClassGenerator
|
||||
$methods = '';
|
||||
|
||||
foreach ($class->reflClass->getMethods() as $method) {
|
||||
if ($method->getName() == '__construct') {
|
||||
if ($method->isConstructor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -205,6 +211,7 @@ namespace Doctrine\Generated\Proxies {
|
||||
public function __construct($entityPersister, $identifier) {
|
||||
$this->_entityPersister = $entityPersister;
|
||||
$this->_identifier = $identifier;
|
||||
<constructorInvocation>
|
||||
}
|
||||
private function _load() {
|
||||
if ( ! $this->_loaded) {
|
||||
@ -241,6 +248,7 @@ namespace Doctrine\Generated\Proxies {
|
||||
$this->_assoc = $assoc;
|
||||
$this->_owner = $owner;
|
||||
$this->_joinColumnValues = $joinColumnValues;
|
||||
<constructorInvocation>
|
||||
}
|
||||
private function _load() {
|
||||
if ( ! $this->_loaded) {
|
||||
|
@ -1427,6 +1427,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
array_combine($class->identifier, $this->_entityIdentifiers[$oid]),
|
||||
$entity
|
||||
);
|
||||
//TODO: refresh (initialized) associations
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException("Entity is not MANAGED.");
|
||||
@ -1656,7 +1657,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
if (isset($this->_identityMap[$class->rootEntityName][$idHash])) {
|
||||
$entity = $this->_identityMap[$class->rootEntityName][$idHash];
|
||||
$oid = spl_object_hash($entity);
|
||||
$overrideLocalChanges = isset($hints[Query::HINT_REFRESH]);
|
||||
$overrideLocalValues = isset($hints[Query::HINT_REFRESH]);
|
||||
} else {
|
||||
$entity = new $className;
|
||||
$oid = spl_object_hash($entity);
|
||||
@ -1667,10 +1668,10 @@ class UnitOfWork implements PropertyChangedListener
|
||||
if ($entity instanceof \Doctrine\Common\NotifyPropertyChanged) {
|
||||
$entity->addPropertyChangedListener($this);
|
||||
}
|
||||
$overrideLocalChanges = true;
|
||||
$overrideLocalValues = true;
|
||||
}
|
||||
|
||||
if ($overrideLocalChanges) {
|
||||
if ($overrideLocalValues) {
|
||||
if ($this->_useCExtension) {
|
||||
doctrine_populate_data($entity, $data);
|
||||
} else {
|
||||
@ -1680,20 +1681,6 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($data as $field => $value) {
|
||||
if (isset($class->reflFields[$field])) {
|
||||
$currentValue = $class->reflFields[$field]->getValue($entity);
|
||||
// Only override the current value if:
|
||||
// a) There was no original value yet (nothing in _originalEntityData)
|
||||
// or
|
||||
// b) The original value is the same as the current value (it was not changed).
|
||||
if ( ! isset($this->_originalEntityData[$oid][$field]) ||
|
||||
$currentValue == $this->_originalEntityData[$oid][$field]) {
|
||||
$class->reflFields[$field]->setValue($entity, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($class->lifecycleCallbacks[Events::postLoad])) {
|
||||
|
@ -16,6 +16,12 @@ class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
{
|
||||
return "DUMMYVARCHAR()";
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getClobTypeDeclarationSql(array $field)
|
||||
{
|
||||
return 'DUMMYCLOB';
|
||||
}
|
||||
|
||||
public function getVarcharDefaultLength()
|
||||
{
|
||||
|
@ -57,6 +57,9 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
|
||||
/** @override */
|
||||
public function getVarcharTypeDeclarationSql(array $field) {}
|
||||
|
||||
/** @override */
|
||||
public function getClobTypeDeclarationSql(array $field) {}
|
||||
|
||||
/* MOCK API */
|
||||
|
||||
|
@ -54,4 +54,11 @@ class CmsAddress
|
||||
public function getCity() {
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
public function setUser(CmsUser $user) {
|
||||
if ($this->user !== $user) {
|
||||
$this->user = $user;
|
||||
$user->setAddress($this);
|
||||
}
|
||||
}
|
||||
}
|
@ -107,4 +107,11 @@ class CmsUser
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setAddress(CmsAddress $address) {
|
||||
if ($this->address !== $address) {
|
||||
$this->address = $address;
|
||||
$address->setUser($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user