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
565facd9
Commit
565facd9
authored
May 01, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-361' into 2.3
parents
c9cdbb0a
19a91720
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+5
-3
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+20
-0
No files found.
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
565facd9
...
@@ -295,9 +295,11 @@ class Comparator
...
@@ -295,9 +295,11 @@ class Comparator
$removedColumnName
=
strtolower
(
$removedColumn
->
getName
());
$removedColumnName
=
strtolower
(
$removedColumn
->
getName
());
$addedColumnName
=
strtolower
(
$addedColumn
->
getName
());
$addedColumnName
=
strtolower
(
$addedColumn
->
getName
());
$tableDifferences
->
renamedColumns
[
$removedColumnName
]
=
$addedColumn
;
if
(
!
isset
(
$tableDifferences
->
renamedColumns
[
$removedColumnName
]))
{
unset
(
$tableDifferences
->
addedColumns
[
$addedColumnName
]);
$tableDifferences
->
renamedColumns
[
$removedColumnName
]
=
$addedColumn
;
unset
(
$tableDifferences
->
removedColumns
[
$removedColumnName
]);
unset
(
$tableDifferences
->
addedColumns
[
$addedColumnName
]);
unset
(
$tableDifferences
->
removedColumns
[
$removedColumnName
]);
}
}
}
}
}
}
}
...
...
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
565facd9
...
@@ -210,6 +210,26 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
...
@@ -210,6 +210,26 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
array
(),
$c
->
diffColumn
(
$column1
,
$column1
));
$this
->
assertEquals
(
array
(),
$c
->
diffColumn
(
$column1
,
$column1
));
}
}
public
function
testCompareChangeColumns_MultipleNewColumnsRename
()
{
$tableA
=
new
Table
(
"foo"
);
$tableA
->
addColumn
(
'datefield1'
,
'datetime'
);
$tableB
=
new
Table
(
"foo"
);
$tableB
->
addColumn
(
'new_datefield1'
,
'datetime'
);
$tableB
->
addColumn
(
'new_datefield2'
,
'datetime'
);
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
$this
->
assertCount
(
1
,
$tableDiff
->
renamedColumns
,
"we should have one rename datefield1 => new_datefield1."
);
$this
->
assertArrayHasKey
(
'datefield1'
,
$tableDiff
->
renamedColumns
,
"'datefield1' should be set to be renamed to new_datefield1"
);
$this
->
assertCount
(
1
,
$tableDiff
->
addedColumns
,
"'new_datefield2' should be added"
);
$this
->
assertArrayHasKey
(
'new_datefield2'
,
$tableDiff
->
addedColumns
,
"'new_datefield2' should be added, not created through renaming!"
);
$this
->
assertCount
(
0
,
$tableDiff
->
removedColumns
,
"Nothing should be removed."
);
$this
->
assertCount
(
0
,
$tableDiff
->
changedColumns
,
"Nothing should be changed as all fields old & new have diff names."
);
}
public
function
testCompareRemovedIndex
()
public
function
testCompareRemovedIndex
()
{
{
$schema1
=
new
Schema
(
array
(
$schema1
=
new
Schema
(
array
(
...
...
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