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
df00bd4b
Commit
df00bd4b
authored
Dec 18, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DDC-464' into 2.4
parents
ad8608ba
76019c44
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
1 deletion
+65
-1
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+13
-0
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+26
-0
MySqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
+26
-1
No files found.
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
df00bd4b
...
...
@@ -582,6 +582,19 @@ class MySqlPlatform extends AbstractPlatform
$table
=
$diff
->
name
;
foreach
(
$diff
->
removedIndexes
as
$remKey
=>
$remIndex
)
{
// Dropping primary keys requires to unset autoincrement attribute on the particular column first.
if
(
$remIndex
->
isPrimary
()
&&
$diff
->
fromTable
instanceof
Table
)
{
foreach
(
$remIndex
->
getColumns
()
as
$columnName
)
{
$column
=
$diff
->
fromTable
->
getColumn
(
$columnName
);
if
(
$column
->
getAutoincrement
()
===
true
)
{
$column
->
setAutoincrement
(
false
);
$sql
[]
=
'ALTER TABLE '
.
$table
.
' MODIFY '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
}
}
}
foreach
(
$diff
->
addedIndexes
as
$addKey
=>
$addIndex
)
{
if
(
$remIndex
->
getColumns
()
==
$addIndex
->
getColumns
())
{
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
df00bd4b
...
...
@@ -64,4 +64,30 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this
->
assertArrayHasKey
(
'f_index'
,
$indexes
);
$this
->
assertTrue
(
$indexes
[
'f_index'
]
->
hasFlag
(
'fulltext'
));
}
/**
* @group DBAL-464
*/
public
function
testDropPrimaryKeyWithAutoincrementColumn
()
{
$table
=
new
Table
(
"drop_primary_key"
);
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'primary'
=>
true
,
'autoincrement'
=>
true
));
$table
->
addColumn
(
'foo'
,
'integer'
,
array
(
'primary'
=>
true
));
$table
->
setPrimaryKey
(
array
(
'id'
,
'foo'
));
$this
->
_sm
->
dropAndCreateTable
(
$table
);
$diffTable
=
clone
$table
;
$diffTable
->
dropPrimaryKey
();
$comparator
=
new
Comparator
();
$this
->
_sm
->
alterTable
(
$comparator
->
diffTable
(
$table
,
$diffTable
));
$table
=
$this
->
_sm
->
listTableDetails
(
"drop_primary_key"
);
$this
->
assertFalse
(
$table
->
hasPrimaryKey
());
$this
->
assertFalse
(
$table
->
getColumn
(
'id'
)
->
getAutoincrement
());
}
}
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
View file @
df00bd4b
...
...
@@ -8,7 +8,7 @@ use Doctrine\DBAL\Schema\Table;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\Comparator
;
class
MySqlPlatformTest
extends
AbstractPlatformTestCase
{
...
...
@@ -295,4 +295,29 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
$this
->
assertEquals
(
'LONGBLOB'
,
$this
->
_platform
->
getBlobTypeDeclarationSQL
(
array
(
'length'
=>
16777216
)));
$this
->
assertEquals
(
'LONGBLOB'
,
$this
->
_platform
->
getBlobTypeDeclarationSQL
(
array
()));
}
/**
* @group DBAL-464
*/
public
function
testDropPrimaryKeyWithAutoincrementColumn
()
{
$table
=
new
Table
(
"drop_primary_key"
);
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'primary'
=>
true
,
'autoincrement'
=>
true
));
$table
->
addColumn
(
'foo'
,
'integer'
,
array
(
'primary'
=>
true
));
$table
->
addColumn
(
'bar'
,
'integer'
);
$table
->
setPrimaryKey
(
array
(
'id'
,
'foo'
));
$comparator
=
new
Comparator
();
$diffTable
=
clone
$table
;
$diffTable
->
dropPrimaryKey
();
$this
->
assertEquals
(
array
(
'ALTER TABLE drop_primary_key MODIFY id INT NOT NULL'
,
'ALTER TABLE drop_primary_key DROP PRIMARY KEY'
),
$this
->
_platform
->
getAlterTableSQL
(
$comparator
->
diffTable
(
$table
,
$diffTable
))
);
}
}
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