Permalink
Browse files

Merge pull request #487 from FabioBatSilva/DDC-2069

Fix DDC-2069
  • Loading branch information...
2 parents 2c0feb2 + 86fddfe commit 814f2f9e039caf712b75af7f61d28c361189bcab @guilhermeblanco guilhermeblanco committed Oct 21, 2012
@@ -198,6 +198,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
if (is_string($index['columns'])) {
$columns = explode(',', $index['columns']);
+ $columns = array_map('trim', $columns);
} else {
$columns = $index['columns'];
}
@@ -217,6 +218,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
if (is_string($unique['columns'])) {
$columns = explode(',', $unique['columns']);
+ $columns = array_map('trim', $columns);
} else {
$columns = $unique['columns'];
}
@@ -628,7 +630,7 @@ private function columnToArray($fieldName, $column)
$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 @@ public function testInvalidMappingFileException()
$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

0 comments on commit 814f2f9

Please sign in to comment.