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
4e024dcb
Commit
4e024dcb
authored
Dec 20, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-617' into 2.4
parents
121332f1
03827efe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+2
-2
ForeignKeyConstraint.php
lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
+20
-0
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+14
-0
No files found.
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
4e024dcb
...
@@ -322,11 +322,11 @@ class Comparator
...
@@ -322,11 +322,11 @@ class Comparator
*/
*/
public
function
diffForeignKey
(
ForeignKeyConstraint
$key1
,
ForeignKeyConstraint
$key2
)
public
function
diffForeignKey
(
ForeignKeyConstraint
$key1
,
ForeignKeyConstraint
$key2
)
{
{
if
(
array_map
(
'strtolower'
,
$key1
->
get
LocalColumns
())
!=
array_map
(
'strtolower'
,
$key2
->
get
LocalColumns
()))
{
if
(
array_map
(
'strtolower'
,
$key1
->
get
UnquotedLocalColumns
())
!=
array_map
(
'strtolower'
,
$key2
->
getUnquoted
LocalColumns
()))
{
return
true
;
return
true
;
}
}
if
(
array_map
(
'strtolower'
,
$key1
->
get
ForeignColumns
())
!=
array_map
(
'strtolower'
,
$key2
->
get
ForeignColumns
()))
{
if
(
array_map
(
'strtolower'
,
$key1
->
get
UnquotedForeignColumns
())
!=
array_map
(
'strtolower'
,
$key2
->
getUnquoted
ForeignColumns
()))
{
return
true
;
return
true
;
}
}
...
...
lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
View file @
4e024dcb
...
@@ -163,6 +163,26 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
...
@@ -163,6 +163,26 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
return
$columns
;
return
$columns
;
}
}
/**
* Returns unquoted representation of local table column names for comparison with other FK
*
* @return array
*/
public
function
getUnquotedLocalColumns
()
{
return
array_map
(
array
(
$this
,
'trimQuotes'
),
$this
->
getLocalColumns
());
}
/**
* Returns unquoted representation of foreign table column names for comparison with other FK
*
* @return array
*/
public
function
getUnquotedForeignColumns
()
{
return
array_map
(
array
(
$this
,
'trimQuotes'
),
$this
->
getForeignColumns
());
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
*
...
...
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
4e024dcb
...
@@ -913,6 +913,20 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
...
@@ -913,6 +913,20 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$expected
,
Comparator
::
compareSchemas
(
$oldSchema
,
$newSchema
));
$this
->
assertEquals
(
$expected
,
Comparator
::
compareSchemas
(
$oldSchema
,
$newSchema
));
}
}
/**
* @group DBAL-617
*/
public
function
testCompareQuotedAndUnquotedForeignKeyColumns
()
{
$fk1
=
new
ForeignKeyConstraint
(
array
(
"foo"
),
"bar"
,
array
(
"baz"
),
"fk1"
,
array
(
'onDelete'
=>
'NO ACTION'
));
$fk2
=
new
ForeignKeyConstraint
(
array
(
"`foo`"
),
"bar"
,
array
(
"`baz`"
),
"fk1"
,
array
(
'onDelete'
=>
'NO ACTION'
));
$comparator
=
new
Comparator
();
$diff
=
$comparator
->
diffForeignKey
(
$fk1
,
$fk2
);
$this
->
assertFalse
(
$diff
);
}
/**
/**
* @param SchemaDiff $diff
* @param SchemaDiff $diff
* @param int $newTableCount
* @param int $newTableCount
...
...
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