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
bcbc3a21
Commit
bcbc3a21
authored
Jan 22, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-207' into 2.2
parents
083d68d9
53a671e4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
RemoveNamespacedAssets.php
lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
+8
-0
RemoveNamespacedAssetsTest.php
.../Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php
+23
-0
No files found.
lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
View file @
bcbc3a21
...
...
@@ -89,6 +89,14 @@ class RemoveNamespacedAssets implements Visitor
*/
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
{
// The table may already be deleted in a previous
// RemoveNamespacedAssets#acceptTable call. Removing Foreign keys that
// point to nowhere.
if
(
!
$this
->
schema
->
hasTable
(
$fkConstraint
->
getForeignTableName
()))
{
$localTable
->
removeForeignKey
(
$fkConstraint
->
getName
());
return
;
}
$foreignTable
=
$this
->
schema
->
getTable
(
$fkConstraint
->
getForeignTableName
());
if
(
!
$foreignTable
->
isInDefaultNamespace
(
$this
->
schema
->
getName
())
)
{
$localTable
->
removeForeignKey
(
$fkConstraint
->
getName
());
...
...
tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php
View file @
bcbc3a21
...
...
@@ -37,6 +37,29 @@ class RemoveNamespacedAssetsTest extends \PHPUnit_Framework_TestCase
$config
->
setName
(
"test"
);
$schema
=
new
Schema
(
array
(),
array
(),
$config
);
$fooTable
=
$schema
->
createTable
(
"foo.bar"
);
$fooTable
->
addColumn
(
'id'
,
'integer'
);
$testTable
=
$schema
->
createTable
(
"test.test"
);
$testTable
->
addColumn
(
'id'
,
'integer'
);
$testTable
->
addForeignKeyConstraint
(
"foo.bar"
,
array
(
"id"
),
array
(
"id"
));
$schema
->
visit
(
new
RemoveNamespacedAssets
());
$sql
=
$schema
->
toSql
(
new
MySqlPlatform
());
$this
->
assertEquals
(
1
,
count
(
$sql
),
"Just one CREATE TABLE statement, no foreign key and table to foo.bar"
);
}
/**
* @group DBAL-204
*/
public
function
testCleanupForeignKeysDifferentOrder
()
{
$config
=
new
SchemaConfig
;
$config
->
setName
(
"test"
);
$schema
=
new
Schema
(
array
(),
array
(),
$config
);
$testTable
=
$schema
->
createTable
(
"test.test"
);
$testTable
->
addColumn
(
'id'
,
'integer'
);
...
...
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