Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
ccc3d3be
Commit
ccc3d3be
authored
Jan 20, 2017
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes #2508: pass through index options when renaming index on table
parent
292a6516
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+2
-2
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+28
-0
No files found.
lib/Doctrine/DBAL/Schema/Table.php
View file @
ccc3d3be
...
...
@@ -253,10 +253,10 @@ class Table extends AbstractAsset
unset
(
$this
->
_indexes
[
$oldIndexName
]);
if
(
$oldIndex
->
isUnique
())
{
return
$this
->
addUniqueIndex
(
$oldIndex
->
getColumns
(),
$newIndexName
);
return
$this
->
addUniqueIndex
(
$oldIndex
->
getColumns
(),
$newIndexName
,
$oldIndex
->
getOptions
()
);
}
return
$this
->
addIndex
(
$oldIndex
->
getColumns
(),
$newIndexName
,
$oldIndex
->
getFlags
());
return
$this
->
addIndex
(
$oldIndex
->
getColumns
(),
$newIndexName
,
$oldIndex
->
getFlags
()
,
$oldIndex
->
getOptions
()
);
}
/**
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
ccc3d3be
...
...
@@ -741,6 +741,34 @@ class TableTest extends \Doctrine\Tests\DbalTestCase
$this
->
assertTrue
(
$table
->
hasIndex
(
'UNIQ_D87F7E0C76FF8CAA78240498'
));
}
/**
* @group DBAL-2508
*/
public
function
testKeepsIndexOptionsOnRenamingRegularIndex
()
{
$table
=
new
Table
(
'foo'
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addIndex
(
array
(
'id'
),
'idx_bar'
,
array
(),
array
(
'where'
=>
'1 = 1'
));
$table
->
renameIndex
(
'idx_bar'
,
'idx_baz'
);
$this
->
assertSame
(
array
(
'where'
=>
'1 = 1'
),
$table
->
getIndex
(
'idx_baz'
)
->
getOptions
());
}
/**
* @group DBAL-2508
*/
public
function
testKeepsIndexOptionsOnRenamingUniqueIndex
()
{
$table
=
new
Table
(
'foo'
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addUniqueIndex
(
array
(
'id'
),
'idx_bar'
,
array
(
'where'
=>
'1 = 1'
));
$table
->
renameIndex
(
'idx_bar'
,
'idx_baz'
);
$this
->
assertSame
(
array
(
'where'
=>
'1 = 1'
),
$table
->
getIndex
(
'idx_baz'
)
->
getOptions
());
}
/**
* @group DBAL-234
* @expectedException \Doctrine\DBAL\Schema\SchemaException
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment