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
f20ba141
Unverified
Commit
f20ba141
authored
May 07, 2020
by
Grégoire Paris
Committed by
GitHub
May 07, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3994 from greg0ire/check-for-alter-support-fk
Use proper check in acceptForeignKey()
parents
61a6b9b9
f0c1af4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
CreateSchemaSqlCollector.php
...Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
+1
-1
ForeignKeyTest.php
.../Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php
+37
-0
CreateSchemaSqlCollectorTest.php
...ests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
+4
-4
No files found.
lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
View file @
f20ba141
...
...
@@ -55,7 +55,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor
*/
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
{
if
(
!
$this
->
platform
->
supportsForeignKeyConstraints
())
{
if
(
!
$this
->
platform
->
supports
CreateDrop
ForeignKeyConstraints
())
{
return
;
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php
0 → 100644
View file @
f20ba141
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\Tests\DBAL\Functional\Schema
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\Tests\DbalFunctionalTestCase
;
class
ForeignKeyTest
extends
DbalFunctionalTestCase
{
public
function
testCreatingATableWithAForeignKey
()
:
void
{
$schema
=
new
Schema
();
$referencedTable
=
$schema
->
createTable
(
'referenced_table'
);
$referencedTable
->
addColumn
(
'id'
,
'integer'
);
$referencedTable
->
setPrimaryKey
([
'id'
]);
$referencingTable
=
$schema
->
createTable
(
'referencing_table'
);
$referencingTable
->
addColumn
(
'referenced_id'
,
'integer'
);
$referencingTable
->
addForeignKeyConstraint
(
$referencedTable
,
[
'referenced_id'
],
[
'id'
]
);
foreach
(
$schema
->
toSql
(
$this
->
connection
->
getDatabasePlatform
())
as
$sql
)
{
$this
->
connection
->
exec
(
$sql
);
}
self
::
assertCount
(
1
,
$this
->
connection
->
getSchemaManager
()
->
listTableForeignKeys
(
'referencing_table'
)
);
}
}
tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
View file @
f20ba141
...
...
@@ -29,7 +29,7 @@ class CreateSchemaSqlCollectorTest extends TestCase
'getCreateSchemaSQL'
,
'getCreateSequenceSQL'
,
'getCreateTableSQL'
,
'supportsForeignKeyConstraints'
,
'supports
CreateDrop
ForeignKeyConstraints'
,
'supportsSchemas'
,
]
)
...
...
@@ -76,11 +76,11 @@ class CreateSchemaSqlCollectorTest extends TestCase
public
function
testAcceptsForeignKey
()
:
void
{
$this
->
platformMock
->
expects
(
$this
->
at
(
0
))
->
method
(
'supportsForeignKeyConstraints'
)
->
method
(
'supports
CreateDrop
ForeignKeyConstraints'
)
->
will
(
$this
->
returnValue
(
false
));
$this
->
platformMock
->
expects
(
$this
->
at
(
1
))
->
method
(
'supportsForeignKeyConstraints'
)
->
method
(
'supports
CreateDrop
ForeignKeyConstraints'
)
->
will
(
$this
->
returnValue
(
true
));
$table
=
$this
->
createTableMock
();
...
...
@@ -106,7 +106,7 @@ class CreateSchemaSqlCollectorTest extends TestCase
public
function
testResetsQueries
()
:
void
{
foreach
([
'supportsSchemas'
,
'supportsForeignKeyConstraints'
]
as
$method
)
{
foreach
([
'supportsSchemas'
,
'supports
CreateDrop
ForeignKeyConstraints'
]
as
$method
)
{
$this
->
platformMock
->
expects
(
$this
->
any
())
->
method
(
$method
)
->
will
(
$this
->
returnValue
(
true
));
...
...
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