1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Fix DDC-2069

This commit is contained in:
Fabio B. Silva 2012-10-20 00:28:38 -03:00
parent 56e96793c0
commit 86fddfed9a
3 changed files with 49 additions and 1 deletions

View File

@ -198,6 +198,7 @@ class YamlDriver extends FileDriver
if (is_string($index['columns'])) { if (is_string($index['columns'])) {
$columns = explode(',', $index['columns']); $columns = explode(',', $index['columns']);
$columns = array_map('trim', $columns);
} else { } else {
$columns = $index['columns']; $columns = $index['columns'];
} }
@ -217,6 +218,7 @@ class YamlDriver extends FileDriver
if (is_string($unique['columns'])) { if (is_string($unique['columns'])) {
$columns = explode(',', $unique['columns']); $columns = explode(',', $unique['columns']);
$columns = array_map('trim', $columns);
} else { } else {
$columns = $unique['columns']; $columns = $unique['columns'];
} }
@ -628,7 +630,7 @@ class YamlDriver extends FileDriver
$mapping['type'] = $column['type']; $mapping['type'] = $column['type'];
if (isset($params[1])) { if (isset($params[1])) {
$column['length'] = substr($params[1], 0, strlen($params[1]) - 1); $column['length'] = (integer) substr($params[1], 0, strlen($params[1]) - 1);
} }
} }

View File

@ -54,4 +54,35 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest
$this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel'); $this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel');
} }
/**
* @group DDC-2069
*/
public function testSpacesShouldBeIgnoredWhenUseExplode()
{
$metadata = $this->createClassMetadata(__NAMESPACE__.'\DDC2069Entity');
$unique = $metadata->table['uniqueConstraints'][0]['columns'];
$indexes = $metadata->table['indexes'][0]['columns'];
$nameField = $metadata->fieldMappings['name'];
$valueField = $metadata->fieldMappings['value'];
$this->assertEquals('name', $unique[0]);
$this->assertEquals('value', $unique[1]);
$this->assertEquals('value', $indexes[0]);
$this->assertEquals('name', $indexes[1]);
$this->assertEquals(255, $nameField['length']);
$this->assertEquals(255, $valueField['length']);
}
}
class DDC2069Entity
{
public $id;
public $name;
public $value;
} }

View File

@ -0,0 +1,15 @@
Doctrine\Tests\ORM\Mapping\DDC2069Entity:
type: entity
id:
id:
fields:
name:
type: string ( 255 )
value:
type: string ( 255 )
uniqueConstraints:
0:
columns: name, value
indexes:
0:
columns: value, name