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
eeda97b6
Commit
eeda97b6
authored
Jun 30, 2014
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #533 from deeky666/DBAL-807
[DBAL-807] Respect schema when renaming indexes
parents
e7a917e9
9aeefcb9
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
250 additions
and
0 deletions
+250
-0
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+5
-0
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+5
-0
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+5
-0
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+24
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+63
-0
AbstractPostgreSqlPlatformTestCase.php
...sts/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+21
-0
AbstractSQLServerPlatformTestCase.php
...ests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+21
-0
DB2PlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
+21
-0
MySQL57PlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php
+21
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+21
-0
SQLAnywherePlatformTest.php
...Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+21
-0
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+22
-0
No files found.
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
eeda97b6
...
...
@@ -555,6 +555,11 @@ class DB2Platform extends AbstractPlatform
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
if
(
strpos
(
$tableName
,
'.'
)
!==
false
)
{
list
(
$schema
)
=
explode
(
'.'
,
$tableName
);
$oldIndexName
=
$schema
.
'.'
.
$oldIndexName
;
}
return
array
(
'RENAME INDEX '
.
$oldIndexName
.
' TO '
.
$index
->
getQuotedName
(
$this
));
}
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
eeda97b6
...
...
@@ -771,6 +771,11 @@ LEFT JOIN user_cons_columns r_cols
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
if
(
strpos
(
$tableName
,
'.'
)
!==
false
)
{
list
(
$schema
)
=
explode
(
'.'
,
$tableName
);
$oldIndexName
=
$schema
.
'.'
.
$oldIndexName
;
}
return
array
(
'ALTER INDEX '
.
$oldIndexName
.
' RENAME TO '
.
$index
->
getQuotedName
(
$this
));
}
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
eeda97b6
...
...
@@ -563,6 +563,11 @@ class PostgreSqlPlatform extends AbstractPlatform
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
if
(
strpos
(
$tableName
,
'.'
)
!==
false
)
{
list
(
$schema
)
=
explode
(
'.'
,
$tableName
);
$oldIndexName
=
$schema
.
'.'
.
$oldIndexName
;
}
return
array
(
'ALTER INDEX '
.
$oldIndexName
.
' RENAME TO '
.
$index
->
getQuotedName
(
$this
));
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
eeda97b6
...
...
@@ -514,6 +514,30 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
);
}
/**
* @group DBAL-807
*/
protected
function
getAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'DROP INDEX idx_foo ON myschema.mytable'
,
'CREATE INDEX idx_bar ON myschema.mytable (id)'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getQuotedAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'DROP INDEX `create` ON `schema`.`table`'
,
'CREATE INDEX `select` ON `schema`.`table` (id)'
,
'DROP INDEX `foo` ON `schema`.`table`'
,
'CREATE INDEX `bar` ON `schema`.`table` (id)'
,
);
}
public
function
testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes
()
{
$table
=
new
Table
(
"text_blob_default_value"
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
eeda97b6
...
...
@@ -716,4 +716,67 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
* @group DBAL-835
*/
abstract
protected
function
getQuotedAlterTableRenameColumnSQL
();
/**
* @group DBAL-807
*/
public
function
testAlterTableRenameIndexInSchema
()
{
$tableDiff
=
new
TableDiff
(
'myschema.mytable'
);
$tableDiff
->
fromTable
=
new
Table
(
'myschema.mytable'
);
$tableDiff
->
fromTable
->
addColumn
(
'id'
,
'integer'
);
$tableDiff
->
fromTable
->
setPrimaryKey
(
array
(
'id'
));
$tableDiff
->
renamedIndexes
=
array
(
'idx_foo'
=>
new
Index
(
'idx_bar'
,
array
(
'id'
))
);
$this
->
assertSame
(
$this
->
getAlterTableRenameIndexInSchemaSQL
(),
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
)
);
}
/**
* @group DBAL-807
*/
protected
function
getAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'DROP INDEX idx_foo'
,
'CREATE INDEX idx_bar ON myschema.mytable (id)'
,
);
}
/**
* @group DBAL-807
*/
public
function
testQuotesAlterTableRenameIndexInSchema
()
{
$tableDiff
=
new
TableDiff
(
'`schema`.table'
);
$tableDiff
->
fromTable
=
new
Table
(
'`schema`.table'
);
$tableDiff
->
fromTable
->
addColumn
(
'id'
,
'integer'
);
$tableDiff
->
fromTable
->
setPrimaryKey
(
array
(
'id'
));
$tableDiff
->
renamedIndexes
=
array
(
'create'
=>
new
Index
(
'select'
,
array
(
'id'
)),
'`foo`'
=>
new
Index
(
'`bar`'
,
array
(
'id'
)),
);
$this
->
assertSame
(
$this
->
getQuotedAlterTableRenameIndexInSchemaSQL
(),
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
)
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'DROP INDEX "schema"."create"'
,
'CREATE INDEX "select" ON "schema"."table" (id)'
,
'DROP INDEX "schema"."foo"'
,
'CREATE INDEX "bar" ON "schema"."table" (id)'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
View file @
eeda97b6
...
...
@@ -538,4 +538,25 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
'ALTER TABLE mytable RENAME COLUMN quoted3 TO "baz"'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'ALTER INDEX myschema.idx_foo RENAME TO idx_bar'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getQuotedAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'ALTER INDEX "schema"."create" RENAME TO "select"'
,
'ALTER INDEX "schema"."foo" RENAME TO "bar"'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
View file @
eeda97b6
...
...
@@ -881,4 +881,25 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
"sp_RENAME 'mytable.quoted3', '[baz]', 'COLUMN'"
,
);
}
/**
* @group DBAL-807
*/
protected
function
getAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
"EXEC sp_RENAME N'myschema.mytable.idx_foo', N'idx_bar', N'INDEX'"
,
);
}
/**
* @group DBAL-807
*/
protected
function
getQuotedAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
"EXEC sp_RENAME N'[schema].[table].[create]', N'[select]', N'INDEX'"
,
"EXEC sp_RENAME N'[schema].[table].[foo]', N'[bar]', N'INDEX'"
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
View file @
eeda97b6
...
...
@@ -434,4 +434,25 @@ class DB2PlatformTest extends AbstractPlatformTestCase
'RENAME COLUMN quoted3 TO "baz"'
);
}
/**
* @group DBAL-807
*/
protected
function
getAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'RENAME INDEX myschema.idx_foo TO idx_bar'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getQuotedAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'RENAME INDEX "schema"."create" TO "select"'
,
'RENAME INDEX "schema"."foo" TO "bar"'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php
View file @
eeda97b6
...
...
@@ -34,4 +34,25 @@ class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase
'ALTER TABLE `table` RENAME INDEX `foo` TO `bar`'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'ALTER TABLE myschema.mytable RENAME INDEX idx_foo TO idx_bar'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getQuotedAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'ALTER TABLE `schema`.`table` RENAME INDEX `create` TO `select`'
,
'ALTER TABLE `schema`.`table` RENAME INDEX `foo` TO `bar`'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
eeda97b6
...
...
@@ -455,4 +455,25 @@ class OraclePlatformTest extends AbstractPlatformTestCase
'ALTER TABLE mytable RENAME COLUMN quoted3 TO "baz"'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'ALTER INDEX myschema.idx_foo RENAME TO idx_bar'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getQuotedAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'ALTER INDEX "schema"."create" RENAME TO "select"'
,
'ALTER INDEX "schema"."foo" RENAME TO "bar"'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
View file @
eeda97b6
...
...
@@ -845,4 +845,25 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
'ALTER TABLE mytable RENAME quoted3 TO "baz"'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'ALTER INDEX idx_foo ON myschema.mytable RENAME TO idx_bar'
,
);
}
/**
* @group DBAL-807
*/
protected
function
getQuotedAlterTableRenameIndexInSchemaSQL
()
{
return
array
(
'ALTER INDEX "create" ON "schema"."table" RENAME TO "select"'
,
'ALTER INDEX "foo" ON "schema"."table" RENAME TO "bar"'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
eeda97b6
...
...
@@ -496,4 +496,26 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
'DROP TABLE __temp__mytable'
,
);
}
/**
* @group DBAL-807
*/
public
function
testAlterTableRenameIndexInSchema
()
{
$this
->
markTestIncomplete
(
'Test currently produces broken SQL due to SQLLitePlatform::getAlterTable being broken '
.
'when used with schemas.'
);
}
/**
* @group DBAL-807
*/
public
function
testQuotesAlterTableRenameIndexInSchema
()
{
$this
->
markTestIncomplete
(
'Test currently produces broken SQL due to SQLLitePlatform::getAlterTable being broken '
.
'when used with schemas.'
);
}
}
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