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
81591fd4
Commit
81591fd4
authored
Jan 01, 2015
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/#760-DBAL-1097-backport-to-2.4' into 2.4
parents
028a29b5
f4c1d3c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
0 deletions
+83
-0
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+38
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+45
-0
No files found.
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
81591fd4
...
@@ -567,6 +567,44 @@ LEFT JOIN user_cons_columns r_cols
...
@@ -567,6 +567,44 @@ LEFT JOIN user_cons_columns r_cols
return
'ALTER TABLE '
.
$table
.
' DROP CONSTRAINT '
.
$foreignKey
;
return
'ALTER TABLE '
.
$table
.
' DROP CONSTRAINT '
.
$foreignKey
;
}
}
/**
* {@inheritdoc}
*/
public
function
getAdvancedForeignKeyOptionsSQL
(
ForeignKeyConstraint
$foreignKey
)
{
$referentialAction
=
null
;
if
(
$foreignKey
->
hasOption
(
'onDelete'
))
{
$referentialAction
=
$this
->
getForeignKeyReferentialActionSQL
(
$foreignKey
->
getOption
(
'onDelete'
));
}
return
$referentialAction
?
' ON DELETE '
.
$referentialAction
:
''
;
}
/**
* {@inheritdoc}
*/
public
function
getForeignKeyReferentialActionSQL
(
$action
)
{
$action
=
strtoupper
(
$action
);
switch
(
$action
)
{
case
'RESTRICT'
:
// RESTRICT is not supported, therefore falling back to NO ACTION.
case
'NO ACTION'
:
// NO ACTION cannot be declared explicitly,
// therefore returning empty string to indicate to OMIT the referential clause.
return
''
;
case
'CASCADE'
:
case
'SET NULL'
:
return
$action
;
default
:
// SET DEFAULT is not supported, throw exception instead.
throw
new
\InvalidArgumentException
(
'Invalid foreign key action: '
.
$action
);
}
}
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
81591fd4
...
@@ -3,6 +3,10 @@
...
@@ -3,6 +3,10 @@
namespace
Doctrine\Tests\DBAL\Platforms
;
namespace
Doctrine\Tests\DBAL\Platforms
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
Doctrine\DBAL\Schema\Column
;
use
Doctrine\DBAL\Schema\Comparator
;
use
Doctrine\DBAL\Schema\ForeignKeyConstraint
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Types\Type
;
require_once
__DIR__
.
'/../../TestInit.php'
;
require_once
__DIR__
.
'/../../TestInit.php'
;
...
@@ -200,6 +204,47 @@ class OraclePlatformTest extends AbstractPlatformTestCase
...
@@ -200,6 +204,47 @@ class OraclePlatformTest extends AbstractPlatformTestCase
return
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'
;
return
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'
;
}
}
/**
* @group DBAL-1097
*
* @dataProvider getGeneratesAdvancedForeignKeyOptionsSQLData
*/
public
function
testGeneratesAdvancedForeignKeyOptionsSQL
(
array
$options
,
$expectedSql
)
{
$foreignKey
=
new
ForeignKeyConstraint
(
array
(
'foo'
),
'foreign_table'
,
array
(
'bar'
),
null
,
$options
);
$this
->
assertSame
(
$expectedSql
,
$this
->
_platform
->
getAdvancedForeignKeyOptionsSQL
(
$foreignKey
));
}
/**
* @return array
*/
public
function
getGeneratesAdvancedForeignKeyOptionsSQLData
()
{
return
array
(
array
(
array
(),
''
),
array
(
array
(
'onUpdate'
=>
'CASCADE'
),
''
),
array
(
array
(
'onDelete'
=>
'CASCADE'
),
' ON DELETE CASCADE'
),
array
(
array
(
'onDelete'
=>
'NO ACTION'
),
''
),
array
(
array
(
'onDelete'
=>
'RESTRICT'
),
''
),
array
(
array
(
'onUpdate'
=>
'SET NULL'
,
'onDelete'
=>
'SET NULL'
),
' ON DELETE SET NULL'
),
);
}
/**
* {@inheritdoc}
*/
public
function
getReturnsForeignKeyReferentialActionSQL
()
{
return
array
(
array
(
'CASCADE'
,
'CASCADE'
),
array
(
'SET NULL'
,
'SET NULL'
),
array
(
'NO ACTION'
,
''
),
array
(
'RESTRICT'
,
''
),
array
(
'CaScAdE'
,
'CASCADE'
),
);
}
public
function
testModifyLimitQuery
()
public
function
testModifyLimitQuery
()
{
{
$sql
=
$this
->
_platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
,
0
);
$sql
=
$this
->
_platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
,
0
);
...
...
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