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
50557fc0
Commit
50557fc0
authored
Oct 17, 2014
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #693 from deeky666/DBAL-1010
[DBAL-1010] Fix renaming column with default value on SQL Server
parents
1b7e522b
9cfbc216
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
109 additions
and
1 deletion
+109
-1
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+4
-1
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+10
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+29
-0
AbstractPostgreSqlPlatformTestCase.php
...sts/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+10
-0
AbstractSQLServerPlatformTestCase.php
...ests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+12
-0
DB2PlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
+10
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+10
-0
SQLAnywherePlatformTest.php
...Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+10
-0
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+14
-0
No files found.
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
50557fc0
...
...
@@ -506,7 +506,10 @@ class SQLServerPlatform extends AbstractPlatform
// Recreate default constraint with new column name if necessary (for future reference).
if
(
$column
->
getDefault
()
!==
null
)
{
$queryParts
[]
=
$this
->
getAlterTableDropDefaultConstraintClause
(
$diff
->
name
,
$oldColumnName
);
$queryParts
[]
=
$this
->
getAlterTableDropDefaultConstraintClause
(
$diff
->
name
,
$oldColumnName
->
getQuotedName
(
$this
)
);
$queryParts
[]
=
$this
->
getAlterTableAddDefaultConstraintClause
(
$diff
->
name
,
$column
);
}
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
50557fc0
...
...
@@ -604,4 +604,14 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
{
$this
->
assertSame
(
'CHAR(36)'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
/**
* {@inheritdoc}
*/
public
function
getAlterTableRenameColumnSQL
()
{
return
array
(
"ALTER TABLE foo CHANGE bar baz INT DEFAULT 666 NOT NULL COMMENT 'rename test'"
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
50557fc0
...
...
@@ -5,6 +5,7 @@ namespace Doctrine\Tests\DBAL\Platforms;
use
Doctrine\Common\EventManager
;
use
Doctrine\DBAL\Events
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\Column
;
use
Doctrine\DBAL\Schema\Comparator
;
use
Doctrine\DBAL\Schema\ForeignKeyConstraint
;
use
Doctrine\DBAL\Schema\Index
;
...
...
@@ -956,4 +957,32 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
());
}
/**
* @group DBAL-1010
*/
public
function
testGeneratesAlterTableRenameColumnSQL
()
{
$table
=
new
Table
(
'foo'
);
$table
->
addColumn
(
'bar'
,
'integer'
,
array
(
'notnull'
=>
true
,
'default'
=>
666
,
'comment'
=>
'rename test'
)
);
$tableDiff
=
new
TableDiff
(
'foo'
);
$tableDiff
->
fromTable
=
$table
;
$tableDiff
->
renamedColumns
[
'bar'
]
=
new
Column
(
'baz'
,
Type
::
getType
(
'integer'
),
array
(
'notnull'
=>
true
,
'default'
=>
666
,
'comment'
=>
'rename test'
)
);
$this
->
assertSame
(
$this
->
getAlterTableRenameColumnSQL
(),
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
));
}
/**
* @return array
*/
abstract
public
function
getAlterTableRenameColumnSQL
();
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
View file @
50557fc0
...
...
@@ -672,4 +672,14 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
{
$this
->
assertSame
(
'UUID'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
/**
* {@inheritdoc}
*/
public
function
getAlterTableRenameColumnSQL
()
{
return
array
(
'ALTER TABLE foo RENAME COLUMN bar TO baz'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
View file @
50557fc0
...
...
@@ -1125,4 +1125,16 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
{
$this
->
assertSame
(
'UNIQUEIDENTIFIER'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
/**
* {@inheritdoc}
*/
public
function
getAlterTableRenameColumnSQL
()
{
return
array
(
"sp_RENAME 'foo.bar', 'baz', 'COLUMN'"
,
'ALTER TABLE foo DROP CONSTRAINT DF_8C736521_76FF8CAA'
,
'ALTER TABLE foo ADD CONSTRAINT DF_8C736521_78240498 DEFAULT 666 FOR baz'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
View file @
50557fc0
...
...
@@ -471,4 +471,14 @@ class DB2PlatformTest extends AbstractPlatformTestCase
{
$this
->
assertSame
(
'CHAR(36)'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
/**
* {@inheritdoc}
*/
public
function
getAlterTableRenameColumnSQL
()
{
return
array
(
'ALTER TABLE foo RENAME COLUMN bar TO baz'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
50557fc0
...
...
@@ -492,4 +492,14 @@ class OraclePlatformTest extends AbstractPlatformTestCase
{
$this
->
assertSame
(
'CHAR(36)'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
/**
* {@inheritdoc}
*/
public
function
getAlterTableRenameColumnSQL
()
{
return
array
(
'ALTER TABLE foo RENAME COLUMN bar TO baz'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
View file @
50557fc0
...
...
@@ -863,4 +863,14 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
{
$this
->
assertSame
(
'UNIQUEIDENTIFIER'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
/**
* {@inheritdoc}
*/
public
function
getAlterTableRenameColumnSQL
()
{
return
array
(
'ALTER TABLE foo RENAME bar TO baz'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
50557fc0
...
...
@@ -560,4 +560,18 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
{
$this
->
assertSame
(
'CHAR(36)'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
/**
* {@inheritdoc}
*/
public
function
getAlterTableRenameColumnSQL
()
{
return
array
(
'CREATE TEMPORARY TABLE __temp__foo AS SELECT bar FROM foo'
,
'DROP TABLE foo'
,
'CREATE TABLE foo (baz INTEGER DEFAULT 666 NOT NULL)'
,
'INSERT INTO foo (baz) SELECT bar FROM __temp__foo'
,
'DROP TABLE __temp__foo'
,
);
}
}
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