Fix DDC-2069
This commit is contained in:
parent
56e96793c0
commit
86fddfed9a
@ -198,6 +198,7 @@ class YamlDriver extends FileDriver
|
||||
|
||||
if (is_string($index['columns'])) {
|
||||
$columns = explode(',', $index['columns']);
|
||||
$columns = array_map('trim', $columns);
|
||||
} else {
|
||||
$columns = $index['columns'];
|
||||
}
|
||||
@ -217,6 +218,7 @@ class YamlDriver extends FileDriver
|
||||
|
||||
if (is_string($unique['columns'])) {
|
||||
$columns = explode(',', $unique['columns']);
|
||||
$columns = array_map('trim', $columns);
|
||||
} else {
|
||||
$columns = $unique['columns'];
|
||||
}
|
||||
@ -628,7 +630,7 @@ class YamlDriver extends FileDriver
|
||||
$mapping['type'] = $column['type'];
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,4 +54,35 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest
|
||||
$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;
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue
Block a user