Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Table): support for index declared with single field as string #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Doctrine/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions tests/Table/IndexesUsingSingleFieldStringTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

class Doctrine_Table_IndexesUsingSingleFieldString_TestCase extends Doctrine_UnitTestCase
{
protected $tables = array('IndexDeclaredWithSingleFieldStringRecord');

public function testSupportIndexesUsingSingleFieldString()
{
}
}

class IndexDeclaredWithSingleFieldStringRecord extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('some_column_name', 'string', 255);

$this->index('single_field_index_as_string', array(
'fields' => 'some_column_name',
));
}
}
1 change: 1 addition & 0 deletions tests/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading