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
585672e8
Commit
585672e8
authored
Dec 22, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-585] Quote Old column Names when generating ALTER TABLE SQL.
parent
8be725c4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
4 deletions
+32
-4
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+1
-1
DrizzlePlatform.php
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
+1
-1
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+1
-1
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+1
-1
ColumnDiff.php
lib/Doctrine/DBAL/Schema/ColumnDiff.php
+8
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+20
-0
No files found.
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
585672e8
...
...
@@ -391,7 +391,7 @@ class DB2Platform extends AbstractPlatform
/* @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */
$column
=
$columnDiff
->
column
;
$queryParts
[]
=
'ALTER '
.
(
$columnDiff
->
oldColumnName
)
.
' '
$queryParts
[]
=
'ALTER '
.
(
$columnDiff
->
getOldColumnName
()
->
getQuotedName
(
$this
)
)
.
' '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
}
...
...
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
View file @
585672e8
...
...
@@ -410,7 +410,7 @@ class DrizzlePlatform extends AbstractPlatform
$column
=
$columnDiff
->
column
;
$columnArray
=
$column
->
toArray
();
$columnArray
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
$queryParts
[]
=
'CHANGE '
.
(
$columnDiff
->
oldColumnName
)
.
' '
$queryParts
[]
=
'CHANGE '
.
(
$columnDiff
->
getOldColumnName
()
->
getQuotedName
(
$this
)
)
.
' '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$columnArray
);
}
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
585672e8
...
...
@@ -557,7 +557,7 @@ class MySqlPlatform extends AbstractPlatform
$column
=
$columnDiff
->
column
;
$columnArray
=
$column
->
toArray
();
$columnArray
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
$queryParts
[]
=
'CHANGE '
.
(
$columnDiff
->
oldColumnName
)
.
' '
$queryParts
[]
=
'CHANGE '
.
(
$columnDiff
->
getOldColumnName
()
->
getQuotedName
(
$this
)
)
.
' '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$columnArray
);
}
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
585672e8
...
...
@@ -418,7 +418,7 @@ class PostgreSqlPlatform extends AbstractPlatform
continue
;
}
$oldColumnName
=
$columnDiff
->
oldColumnName
;
$oldColumnName
=
$columnDiff
->
getOldColumnName
()
->
getQuotedName
(
$this
)
;
$column
=
$columnDiff
->
column
;
if
(
$columnDiff
->
hasChanged
(
'type'
)
||
$columnDiff
->
hasChanged
(
'precision'
)
||
$columnDiff
->
hasChanged
(
'scale'
))
{
...
...
lib/Doctrine/DBAL/Schema/ColumnDiff.php
View file @
585672e8
...
...
@@ -71,4 +71,12 @@ class ColumnDiff
{
return
in_array
(
$propertyName
,
$this
->
changedProperties
);
}
/**
* @return \Doctrine\DBAL\Schema\Identifier
*/
public
function
getOldColumnName
()
{
return
new
Identifier
(
$this
->
oldColumnName
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
585672e8
...
...
@@ -494,4 +494,24 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$sql
=
$this
->
_platform
->
getCreateTableSQL
(
$table
,
AbstractPlatform
::
CREATE_FOREIGNKEYS
);
$this
->
assertEquals
(
$this
->
getQuotedColumnInForeignKeySQL
(),
$sql
);
}
/**
* @group DBAL-585
*/
public
function
testAlterTableChangeQuotedColumn
()
{
$tableDiff
=
new
\Doctrine\DBAL\Schema\TableDiff
(
'mytable'
);
$tableDiff
->
fromTable
=
new
\Doctrine\DBAL\Schema\Table
(
'mytable'
);
$tableDiff
->
changedColumns
[
'foo'
]
=
new
\Doctrine\DBAL\Schema\ColumnDiff
(
'select'
,
new
\Doctrine\DBAL\Schema\Column
(
'select'
,
\Doctrine\DBAL\Types\Type
::
getType
(
'string'
)
),
array
(
'type'
)
);
$this
->
assertContains
(
$this
->
_platform
->
quoteIdentifier
(
'select'
),
implode
(
';'
,
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
))
);
}
}
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