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
24c1d54e
Commit
24c1d54e
authored
Dec 09, 2011
by
Jan Sorgalla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor duplicate event code in platforms
parent
8a207e03
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
210 deletions
+143
-210
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+99
-1
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+8
-41
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+9
-42
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+9
-42
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+9
-42
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+9
-42
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
24c1d54e
...
...
@@ -27,12 +27,17 @@ use Doctrine\DBAL\DBALException,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\TableDiff
,
Doctrine\DBAL\Schema\Column
,
Doctrine\DBAL\Schema\ColumnDiff
,
Doctrine\DBAL\Types\Type
,
Doctrine\DBAL\Events
,
Doctrine\Common\EventManager
,
Doctrine\DBAL\Event\SchemaCreateTableEventArgs
,
Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs
,
Doctrine\DBAL\Event\SchemaDropTableEventArgs
;
Doctrine\DBAL\Event\SchemaDropTableEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
;
/**
* Base class for all DatabasePlatforms. The DatabasePlatforms are the central
...
...
@@ -1285,6 +1290,99 @@ abstract class AbstractPlatform
throw
DBALException
::
notSupported
(
__METHOD__
);
}
/**
* @param Column $column
* @param TableDiff $diff
* @param array $columnSql
*/
protected
function
onSchemaAlterTableAddColumn
(
Column
$column
,
TableDiff
$diff
,
&
$columnSql
)
{
if
(
null
===
$this
->
_eventManager
)
{
return
false
;
}
if
(
!
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableAddColumn
))
{
return
false
;
}
$eventArgs
=
new
SchemaAlterTableAddColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableAddColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
return
$eventArgs
->
isDefaultPrevented
();
}
/**
* @param Column $column
* @param TableDiff $diff
* @param array $columnSql
*/
protected
function
onSchemaAlterTableRemoveColumn
(
Column
$column
,
TableDiff
$diff
,
&
$columnSql
)
{
if
(
null
===
$this
->
_eventManager
)
{
return
false
;
}
if
(
!
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRemoveColumn
))
{
return
false
;
}
$eventArgs
=
new
SchemaAlterTableRemoveColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRemoveColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
return
$eventArgs
->
isDefaultPrevented
();
}
/**
* @param ColumnDiff $columnDiff
* @param TableDiff $diff
* @param array $columnSql
*/
protected
function
onSchemaAlterTableChangeColumn
(
ColumnDiff
$columnDiff
,
TableDiff
$diff
,
&
$columnSql
)
{
if
(
null
===
$this
->
_eventManager
)
{
return
false
;
}
if
(
!
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableChangeColumn
))
{
return
false
;
}
$eventArgs
=
new
SchemaAlterTableChangeColumnEventArgs
(
$columnDiff
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableChangeColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
return
$eventArgs
->
isDefaultPrevented
();
}
/**
* @param string $oldColumnName
* @param Column $column
* @param TableDiff $diff
* @param array $columnSql
*/
protected
function
onSchemaAlterTableRenameColumn
(
$oldColumnName
,
Column
$column
,
TableDiff
$diff
,
&
$columnSql
)
{
if
(
null
===
$this
->
_eventManager
)
{
return
false
;
}
if
(
!
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRenameColumn
))
{
return
false
;
}
$eventArgs
=
new
SchemaAlterTableRenameColumnEventArgs
(
$oldColumnName
,
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRenameColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
return
$eventArgs
->
isDefaultPrevented
();
}
protected
function
getPreAlterTableIndexForeignKeySQL
(
TableDiff
$diff
)
{
$tableName
=
$diff
->
name
;
...
...
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
24c1d54e
...
...
@@ -22,11 +22,6 @@ namespace Doctrine\DBAL\Platforms;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\DBAL\Events
;
use
Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
;
use
Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
;
use
Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
;
use
Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
;
class
DB2Platform
extends
AbstractPlatform
{
...
...
@@ -382,45 +377,24 @@ class DB2Platform extends AbstractPlatform
$queryParts
=
array
();
foreach
(
$diff
->
addedColumns
AS
$fieldName
=>
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableAddColumn
))
{
$eventArgs
=
new
SchemaAlterTableAddColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableAddColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableAddColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$queryParts
[]
=
'ADD COLUMN '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
}
foreach
(
$diff
->
removedColumns
AS
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRemoveColumn
))
{
$eventArgs
=
new
SchemaAlterTableRemoveColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRemoveColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRemoveColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$queryParts
[]
=
'DROP COLUMN '
.
$column
->
getQuotedName
(
$this
);
}
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableChangeColumn
))
{
$eventArgs
=
new
SchemaAlterTableChangeColumnEventArgs
(
$columnDiff
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableChangeColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableChangeColumn
(
$columnDiff
,
$diff
,
$columnSql
))
{
continue
;
}
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
...
...
@@ -430,15 +404,8 @@ class DB2Platform extends AbstractPlatform
}
foreach
(
$diff
->
renamedColumns
AS
$oldColumnName
=>
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRenameColumn
))
{
$eventArgs
=
new
SchemaAlterTableRenameColumnEventArgs
(
$oldColumnName
,
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRenameColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRenameColumn
(
$oldColumnName
,
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$queryParts
[]
=
'RENAME '
.
$oldColumnName
.
' TO '
.
$column
->
getQuotedName
(
$this
);
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
24c1d54e
...
...
@@ -23,12 +23,7 @@ namespace Doctrine\DBAL\Platforms;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Schema\Index
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Events
,
Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
;
Doctrine\DBAL\Schema\Table
;
/**
* The MsSqlPlatform provides the behavior, features and SQL dialect of the
...
...
@@ -290,45 +285,24 @@ class MsSqlPlatform extends AbstractPlatform
}
foreach
(
$diff
->
addedColumns
AS
$fieldName
=>
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableAddColumn
))
{
$eventArgs
=
new
SchemaAlterTableAddColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableAddColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableAddColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$queryParts
[]
=
'ADD '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
}
foreach
(
$diff
->
removedColumns
AS
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRemoveColumn
))
{
$eventArgs
=
new
SchemaAlterTableRemoveColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRemoveColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRemoveColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$queryParts
[]
=
'DROP COLUMN '
.
$column
->
getQuotedName
(
$this
);
}
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableChangeColumn
))
{
$eventArgs
=
new
SchemaAlterTableChangeColumnEventArgs
(
$columnDiff
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableChangeColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableChangeColumn
(
$columnDiff
,
$diff
,
$columnSql
))
{
continue
;
}
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
...
...
@@ -338,15 +312,8 @@ class MsSqlPlatform extends AbstractPlatform
}
foreach
(
$diff
->
renamedColumns
AS
$oldColumnName
=>
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRenameColumn
))
{
$eventArgs
=
new
SchemaAlterTableRenameColumnEventArgs
(
$oldColumnName
,
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRenameColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRenameColumn
(
$oldColumnName
,
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$sql
[]
=
"sp_RENAME '"
.
$diff
->
name
.
"."
.
$oldColumnName
.
"' , '"
.
$column
->
getQuotedName
(
$this
)
.
"', 'COLUMN'"
;
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
24c1d54e
...
...
@@ -22,12 +22,7 @@ namespace Doctrine\DBAL\Platforms;
use
Doctrine\DBAL\DBALException
,
Doctrine\DBAL\Schema\TableDiff
,
Doctrine\DBAL\Schema\Index
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Events
,
Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
;
Doctrine\DBAL\Schema\Table
;
/**
* The MySqlPlatform provides the behavior, features and SQL dialect of the
...
...
@@ -466,15 +461,8 @@ class MySqlPlatform extends AbstractPlatform
}
foreach
(
$diff
->
addedColumns
AS
$fieldName
=>
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableAddColumn
))
{
$eventArgs
=
new
SchemaAlterTableAddColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableAddColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableAddColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$columnArray
=
$column
->
toArray
();
...
...
@@ -483,30 +471,16 @@ class MySqlPlatform extends AbstractPlatform
}
foreach
(
$diff
->
removedColumns
AS
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRemoveColumn
))
{
$eventArgs
=
new
SchemaAlterTableRemoveColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRemoveColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRemoveColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$queryParts
[]
=
'DROP '
.
$column
->
getQuotedName
(
$this
);
}
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableChangeColumn
))
{
$eventArgs
=
new
SchemaAlterTableChangeColumnEventArgs
(
$columnDiff
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableChangeColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableChangeColumn
(
$columnDiff
,
$diff
,
$columnSql
))
{
continue
;
}
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
...
...
@@ -518,15 +492,8 @@ class MySqlPlatform extends AbstractPlatform
}
foreach
(
$diff
->
renamedColumns
AS
$oldColumnName
=>
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRenameColumn
))
{
$eventArgs
=
new
SchemaAlterTableRenameColumnEventArgs
(
$oldColumnName
,
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRenameColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRenameColumn
(
$oldColumnName
,
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$columnArray
=
$column
->
toArray
();
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
24c1d54e
...
...
@@ -19,12 +19,7 @@
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\DBAL\Schema\TableDiff
,
Doctrine\DBAL\Events
,
Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
;
use
Doctrine\DBAL\Schema\TableDiff
;
/**
* OraclePlatform.
...
...
@@ -549,15 +544,8 @@ LEFT JOIN all_cons_columns r_cols
$fields
=
array
();
foreach
(
$diff
->
addedColumns
AS
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableAddColumn
))
{
$eventArgs
=
new
SchemaAlterTableAddColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableAddColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableAddColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$fields
[]
=
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
...
...
@@ -571,15 +559,8 @@ LEFT JOIN all_cons_columns r_cols
$fields
=
array
();
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableChangeColumn
))
{
$eventArgs
=
new
SchemaAlterTableChangeColumnEventArgs
(
$columnDiff
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableChangeColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableChangeColumn
(
$columnDiff
,
$diff
,
$columnSql
))
{
continue
;
}
$column
=
$columnDiff
->
column
;
...
...
@@ -593,15 +574,8 @@ LEFT JOIN all_cons_columns r_cols
}
foreach
(
$diff
->
renamedColumns
AS
$oldColumnName
=>
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRenameColumn
))
{
$eventArgs
=
new
SchemaAlterTableRenameColumnEventArgs
(
$oldColumnName
,
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRenameColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRenameColumn
(
$oldColumnName
,
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME COLUMN '
.
$oldColumnName
.
' TO '
.
$column
->
getQuotedName
(
$this
);
...
...
@@ -609,15 +583,8 @@ LEFT JOIN all_cons_columns r_cols
$fields
=
array
();
foreach
(
$diff
->
removedColumns
AS
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRemoveColumn
))
{
$eventArgs
=
new
SchemaAlterTableRemoveColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRemoveColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRemoveColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$fields
[]
=
$column
->
getQuotedName
(
$this
);
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
24c1d54e
...
...
@@ -20,12 +20,7 @@
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\DBAL\Schema\TableDiff
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Events
,
Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
,
Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
;
Doctrine\DBAL\Schema\Table
;
/**
* PostgreSqlPlatform.
...
...
@@ -388,15 +383,8 @@ class PostgreSqlPlatform extends AbstractPlatform
$columnSql
=
array
();
foreach
(
$diff
->
addedColumns
as
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableAddColumn
))
{
$eventArgs
=
new
SchemaAlterTableAddColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableAddColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableAddColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$query
=
'ADD '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
...
...
@@ -407,15 +395,8 @@ class PostgreSqlPlatform extends AbstractPlatform
}
foreach
(
$diff
->
removedColumns
as
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRemoveColumn
))
{
$eventArgs
=
new
SchemaAlterTableRemoveColumnEventArgs
(
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRemoveColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRemoveColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$query
=
'DROP '
.
$column
->
getQuotedName
(
$this
);
...
...
@@ -423,15 +404,8 @@ class PostgreSqlPlatform extends AbstractPlatform
}
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableChangeColumn
))
{
$eventArgs
=
new
SchemaAlterTableChangeColumnEventArgs
(
$columnDiff
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableChangeColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableChangeColumn
(
$columnDiff
,
$diff
,
$columnSql
))
{
continue
;
}
$oldColumnName
=
$columnDiff
->
oldColumnName
;
...
...
@@ -473,15 +447,8 @@ class PostgreSqlPlatform extends AbstractPlatform
}
foreach
(
$diff
->
renamedColumns
as
$oldColumnName
=>
$column
)
{
if
(
null
!==
$this
->
_eventManager
&&
$this
->
_eventManager
->
hasListeners
(
Events
::
onSchemaAlterTableRenameColumn
))
{
$eventArgs
=
new
SchemaAlterTableRenameColumnEventArgs
(
$oldColumnName
,
$column
,
$diff
,
$this
);
$this
->
_eventManager
->
dispatchEvent
(
Events
::
onSchemaAlterTableRenameColumn
,
$eventArgs
);
$columnSql
=
array_merge
(
$columnSql
,
$eventArgs
->
getSql
());
if
(
$eventArgs
->
isDefaultPrevented
())
{
continue
;
}
if
(
$this
->
onSchemaAlterTableRenameColumn
(
$oldColumnName
,
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME COLUMN '
.
$oldColumnName
.
' TO '
.
$column
->
getQuotedName
(
$this
);
...
...
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