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
c41cc5a6
Commit
c41cc5a6
authored
Apr 02, 2017
by
Immanuel Klinkenberg
Committed by
Steve Müller
Apr 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix primary key alteration when adding new columns to a table and it's
primary key on MySQL platform.
parent
3cc78d64
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+4
-0
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+24
-0
No files found.
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
c41cc5a6
...
...
@@ -699,6 +699,10 @@ class MySqlPlatform extends AbstractPlatform
// Dropping primary keys requires to unset autoincrement attribute on the particular column first.
foreach
(
$index
->
getColumns
()
as
$columnName
)
{
if
(
!
$diff
->
fromTable
->
hasColumn
(
$columnName
))
{
continue
;
}
$column
=
$diff
->
fromTable
->
getColumn
(
$columnName
);
if
(
$column
->
getAutoincrement
()
===
true
)
{
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
c41cc5a6
...
...
@@ -474,6 +474,30 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
),
$sql
);
}
public
function
testAlterPrimaryKeyWithNewColumn
()
{
$table
=
new
Table
(
"yolo"
);
$table
->
addColumn
(
'pkc1'
,
'integer'
);
$table
->
addColumn
(
'col_a'
,
'integer'
);
$table
->
setPrimaryKey
(
array
(
'pkc1'
));
$comparator
=
new
Comparator
();
$diffTable
=
clone
$table
;
$diffTable
->
addColumn
(
'pkc2'
,
'integer'
);
$diffTable
->
dropPrimaryKey
();
$diffTable
->
setPrimaryKey
(
array
(
'pkc1'
,
'pkc2'
));
$this
->
assertSame
(
array
(
'ALTER TABLE yolo DROP PRIMARY KEY'
,
'ALTER TABLE yolo ADD pkc2 INT NOT NULL'
,
'ALTER TABLE yolo ADD PRIMARY KEY (pkc1, pkc2)'
,
),
$this
->
_platform
->
getAlterTableSQL
(
$comparator
->
diffTable
(
$table
,
$diffTable
))
);
}
public
function
testInitializesDoctrineTypeMappings
()
{
$this
->
assertTrue
(
$this
->
_platform
->
hasDoctrineTypeMappingFor
(
'binary'
));
...
...
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