1
0
mirror of synced 2025-01-19 06:51:40 +03:00

fix DDC-1642

This commit is contained in:
Fabio B. Silva 2012-02-12 22:24:03 -02:00
parent 600d0ba2a2
commit 86054eb659
3 changed files with 45 additions and 2 deletions

View File

@ -1152,9 +1152,10 @@ class BasicEntityPersister
foreach ($columns AS $column) {
$placeholder = '?';
if (isset($this->_columnTypes[$column]) &&
if (isset($this->_class->fieldNames[$column]) &&
isset($this->_columnTypes[$this->_class->fieldNames[$column]]) &&
isset($this->_class->fieldMappings[$this->_class->fieldNames[$column]]['requireSQLConversion'])) {
$type = Type::getType($this->_columnTypes[$column]);
$type = Type::getType($this->_columnTypes[$this->_class->fieldNames[$column]]);
$placeholder = $type->convertToDatabaseValueSQL('?', $this->_platform);
}

View File

@ -18,4 +18,9 @@ class CustomTypeUpperCase
* @Column(type="upper_case_string")
*/
public $lowerCaseString;
/**
* @Column(type="upper_case_string", name="named_lower_case_string", nullable = true)
*/
public $namedLowerCaseString;
}

View File

@ -47,6 +47,43 @@ class TypeValueSqlTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn("select lowerCaseString from customtype_uppercases where id=".$entity->id.""), 'Database holds uppercase string');
}
/**
* @group DDC-1642
*/
public function testUpperCaseStringTypeWhenColumnNameIsDefined()
{
$entity = new CustomTypeUpperCase();
$entity->lowerCaseString = 'Some Value';
$entity->namedLowerCaseString = 'foo';
$this->_em->persist($entity);
$this->_em->flush();
$id = $entity->id;
$this->_em->clear();
$entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id);
$this->assertEquals('foo', $entity->namedLowerCaseString, 'Entity holds lowercase string');
$this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn("select named_lower_case_string from customtype_uppercases where id=".$entity->id.""), 'Database holds uppercase string');
$entity->namedLowerCaseString = 'bar';
$this->_em->persist($entity);
$this->_em->flush();
$id = $entity->id;
$this->_em->clear();
$entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id);
$this->assertEquals('bar', $entity->namedLowerCaseString, 'Entity holds lowercase string');
$this->assertEquals('BAR', $this->_em->getConnection()->fetchColumn("select named_lower_case_string from customtype_uppercases where id=".$entity->id.""), 'Database holds uppercase string');
}
public function testTypeValueSqlWithAssociations()
{
$parent = new CustomTypeParent();