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
fd288786
Commit
fd288786
authored
Jul 18, 2013
by
Bart Visscher
Committed by
Benjamin Eberlei
Dec 20, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When changing from a non-primary index to a primary index, the dropped index isn't named PRIMARY
parent
bfa1e77b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+9
-0
MySqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
+13
-0
No files found.
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
fd288786
...
...
@@ -623,6 +623,15 @@ class MySqlPlatform extends AbstractPlatform
}
}
}
foreach
(
$diff
->
changedIndexes
as
$changedKey
=>
$changedIndex
)
{
if
(
$changedIndex
->
isPrimary
()
&&
$changedKey
!=
'PRIMARY'
)
{
$index
=
$diff
->
changedIndexes
[
$changedKey
];
$index
=
new
Index
(
$changedKey
,
$index
->
getColumns
(),
$index
->
isUnique
(),
false
);
$diff
->
removedIndexes
[
$changedKey
]
=
$index
;
$diff
->
addedIndexes
[
'PRIMARY'
]
=
$diff
->
changedIndexes
[
$changedKey
];
unset
(
$diff
->
changedIndexes
[
$changedKey
]);
}
}
$sql
=
array_merge
(
$sql
,
parent
::
getPreAlterTableIndexForeignKeySQL
(
$diff
));
...
...
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
View file @
fd288786
...
...
@@ -343,4 +343,17 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
"ALTER TABLE foo ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)"
,
),
$sql
);
}
public
function
testNamedPrimaryKey
()
{
$diff
=
new
TableDiff
(
'mytable'
);
$diff
->
changedIndexes
[
'foo_index'
]
=
new
Index
(
'foo_index'
,
array
(
'foo'
),
true
,
true
);
$sql
=
$this
->
_platform
->
getAlterTableSQL
(
$diff
);
$this
->
assertEquals
(
array
(
"DROP INDEX foo_index ON mytable"
,
"ALTER TABLE mytable ADD PRIMARY KEY (foo)"
,
),
$sql
);
}
}
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