diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index faac80574..535d57ccf 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -880,7 +880,9 @@ public function addCheckConstraint($definition, $name) public function addIndex($index, array $definition) { if (isset($definition['fields'])) { - foreach ((array) $definition['fields'] as $key => $field) { + $definition['fields'] = (array) $definition['fields']; + + foreach ($definition['fields'] as $key => $field) { if (is_numeric($key)) { $definition['fields'][$key] = $this->getColumnName($field); } else { diff --git a/tests/Table/IndexesUsingSingleFieldStringTestCase.php b/tests/Table/IndexesUsingSingleFieldStringTestCase.php new file mode 100644 index 000000000..21300f41a --- /dev/null +++ b/tests/Table/IndexesUsingSingleFieldStringTestCase.php @@ -0,0 +1,22 @@ +hasColumn('some_column_name', 'string', 255); + + $this->index('single_field_index_as_string', array( + 'fields' => 'some_column_name', + )); + } +} diff --git a/tests/run.php b/tests/run.php index d1dd2c7ee..16fe619fa 100644 --- a/tests/run.php +++ b/tests/run.php @@ -140,6 +140,7 @@ $core->addTestCase(new Doctrine_Table_TestCase()); $core->addTestCase(new Doctrine_Table_RemoveColumn_TestCase()); $core->addTestCase(new Doctrine_Table_NamedQuery_TestCase()); +$core->addTestCase(new Doctrine_Table_IndexesUsingSingleFieldString_TestCase()); $core->addTestCase(new Doctrine_UnitOfWork_TestCase()); $core->addTestCase(new Doctrine_Collection_TestCase()); $core->addTestCase(new Doctrine_Collection_Snapshot_TestCase());