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
6460e4aa
Commit
6460e4aa
authored
Jan 09, 2016
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quote table and constraint names in drop foreign key / drop constraint SQL
parent
a9e08c8c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
104 additions
and
16 deletions
+104
-16
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+14
-8
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+7
-4
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+7
-4
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+10
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+46
-0
AbstractPostgreSqlPlatformTestCase.php
...sts/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+5
-0
AbstractSQLServerPlatformTestCase.php
...ests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+10
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+5
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
6460e4aa
...
...
@@ -1450,14 +1450,17 @@ abstract class AbstractPlatform
*/
public
function
getDropConstraintSQL
(
$constraint
,
$table
)
{
if
(
$constraint
instanceof
Constraint
)
{
$constraint
=
$constraint
->
getQuotedName
(
$this
);
if
(
!
$constraint
instanceof
Constraint
)
{
$constraint
=
new
Identifier
(
$constraint
);
}
if
(
$table
instanceof
Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
if
(
!
$table
instanceof
Table
)
{
$table
=
new
Identifier
(
$table
);
}
$constraint
=
$constraint
->
getQuotedName
(
$this
);
$table
=
$table
->
getQuotedName
(
$this
);
return
'ALTER TABLE '
.
$table
.
' DROP CONSTRAINT '
.
$constraint
;
}
...
...
@@ -1471,14 +1474,17 @@ abstract class AbstractPlatform
*/
public
function
getDropForeignKeySQL
(
$foreignKey
,
$table
)
{
if
(
$foreignKey
instanceof
ForeignKeyConstraint
)
{
$foreignKey
=
$foreignKey
->
getQuotedName
(
$this
);
if
(
!
$foreignKey
instanceof
ForeignKeyConstraint
)
{
$foreignKey
=
new
Identifier
(
$foreignKey
);
}
if
(
$table
instanceof
Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
if
(
!
$table
instanceof
Table
)
{
$table
=
new
Identifier
(
$table
);
}
$foreignKey
=
$foreignKey
->
getQuotedName
(
$this
);
$table
=
$table
->
getQuotedName
(
$this
);
return
'ALTER TABLE '
.
$table
.
' DROP FOREIGN KEY '
.
$foreignKey
;
}
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
6460e4aa
...
...
@@ -663,14 +663,17 @@ LEFT JOIN user_cons_columns r_cols
*/
public
function
getDropForeignKeySQL
(
$foreignKey
,
$table
)
{
if
(
$foreignKey
instanceof
ForeignKeyConstraint
)
{
$foreignKey
=
$foreignKey
->
getQuotedName
(
$this
);
if
(
!
$foreignKey
instanceof
ForeignKeyConstraint
)
{
$foreignKey
=
new
Identifier
(
$foreignKey
);
}
if
(
$table
instanceof
Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
if
(
!
$table
instanceof
Table
)
{
$table
=
new
Identifier
(
$table
);
}
$foreignKey
=
$foreignKey
->
getQuotedName
(
$this
);
$table
=
$table
->
getQuotedName
(
$this
);
return
'ALTER TABLE '
.
$table
.
' DROP CONSTRAINT '
.
$foreignKey
;
}
...
...
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
6460e4aa
...
...
@@ -160,14 +160,17 @@ class SQLServerPlatform extends AbstractPlatform
*/
public
function
getDropForeignKeySQL
(
$foreignKey
,
$table
)
{
if
(
$foreignKey
instanceof
ForeignKeyConstraint
)
{
$foreignKey
=
$foreignKey
->
getQuotedName
(
$this
);
if
(
!
$foreignKey
instanceof
ForeignKeyConstraint
)
{
$foreignKey
=
new
Identifier
(
$foreignKey
);
}
if
(
$table
instanceof
Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
if
(
!
$table
instanceof
Table
)
{
$table
=
new
Identifier
(
$table
);
}
$foreignKey
=
$foreignKey
->
getQuotedName
(
$this
);
$table
=
$table
->
getQuotedName
(
$this
);
return
'ALTER TABLE '
.
$table
.
' DROP CONSTRAINT '
.
$foreignKey
;
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
6460e4aa
...
...
@@ -571,6 +571,16 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
);
}
protected
function
getQuotesDropForeignKeySQL
()
{
return
'ALTER TABLE `table` DROP FOREIGN KEY `select`'
;
}
protected
function
getQuotesDropConstraintSQL
()
{
return
'ALTER TABLE `table` DROP CONSTRAINT `select`'
;
}
public
function
testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes
()
{
$table
=
new
Table
(
"text_blob_default_value"
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
6460e4aa
...
...
@@ -967,6 +967,52 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
);
}
/**
* @group DBAL-1237
*/
public
function
testQuotesDropForeignKeySQL
()
{
if
(
!
$this
->
_platform
->
supportsForeignKeyConstraints
())
{
$this
->
markTestSkipped
(
sprintf
(
'%s does not support foreign key constraints.'
,
get_class
(
$this
->
_platform
))
);
}
$tableName
=
'table'
;
$table
=
new
Table
(
$tableName
);
$foreignKeyName
=
'select'
;
$foreignKey
=
new
ForeignKeyConstraint
(
array
(),
'foo'
,
array
(),
'select'
);
$expectedSql
=
$this
->
getQuotesDropForeignKeySQL
();
$this
->
assertSame
(
$expectedSql
,
$this
->
_platform
->
getDropForeignKeySQL
(
$foreignKeyName
,
$tableName
));
$this
->
assertSame
(
$expectedSql
,
$this
->
_platform
->
getDropForeignKeySQL
(
$foreignKey
,
$table
));
}
protected
function
getQuotesDropForeignKeySQL
()
{
return
'ALTER TABLE "table" DROP FOREIGN KEY "select"'
;
}
/**
* @group DBAL-1237
*/
public
function
testQuotesDropConstraintSQL
()
{
$tableName
=
'table'
;
$table
=
new
Table
(
$tableName
);
$constraintName
=
'select'
;
$constraint
=
new
ForeignKeyConstraint
(
array
(),
'foo'
,
array
(),
'select'
);
$expectedSql
=
$this
->
getQuotesDropConstraintSQL
();
$this
->
assertSame
(
$expectedSql
,
$this
->
_platform
->
getDropConstraintSQL
(
$constraintName
,
$tableName
));
$this
->
assertSame
(
$expectedSql
,
$this
->
_platform
->
getDropConstraintSQL
(
$constraint
,
$table
));
}
protected
function
getQuotesDropConstraintSQL
()
{
return
'ALTER TABLE "table" DROP CONSTRAINT "select"'
;
}
protected
function
getStringLiteralQuoteCharacter
()
{
return
"'"
;
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
View file @
6460e4aa
...
...
@@ -669,6 +669,11 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
);
}
protected
function
getQuotesDropForeignKeySQL
()
{
return
'ALTER TABLE "table" DROP CONSTRAINT "select"'
;
}
public
function
testGetNullCommentOnColumnSQL
()
{
$this
->
assertEquals
(
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
View file @
6460e4aa
...
...
@@ -1035,6 +1035,16 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
);
}
protected
function
getQuotesDropForeignKeySQL
()
{
return
'ALTER TABLE [table] DROP CONSTRAINT [select]'
;
}
protected
function
getQuotesDropConstraintSQL
()
{
return
'ALTER TABLE [table] DROP CONSTRAINT [select]'
;
}
/**
* @dataProvider getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL
* @group DBAL-830
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
6460e4aa
...
...
@@ -545,6 +545,11 @@ class OraclePlatformTest extends AbstractPlatformTestCase
);
}
protected
function
getQuotesDropForeignKeySQL
()
{
return
'ALTER TABLE "table" DROP CONSTRAINT "select"'
;
}
/**
* @group DBAL-423
*/
...
...
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