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
efaff48b
Commit
efaff48b
authored
Dec 21, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-591] Fix issue with drop constraint + column ordering in ALTER TABLE of PostgreSQL.
parent
feedcfae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+1
-1
PostgreSqlPlatformTest.php
.../Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+32
-6
No files found.
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
efaff48b
...
...
@@ -508,7 +508,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME TO '
.
$diff
->
newName
;
}
$sql
=
array_merge
(
$
sql
,
$this
->
_ge
tAlterTableIndexForeignKeySQL
(
$diff
),
$commentsSQL
);
$sql
=
array_merge
(
$
this
->
getPreAlterTableIndexForeignKeySQL
(
$diff
),
$sql
,
$this
->
getPos
tAlterTableIndexForeignKeySQL
(
$diff
),
$commentsSQL
);
}
return
array_merge
(
$sql
,
$tableSql
,
$columnSql
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
View file @
efaff48b
...
...
@@ -336,19 +336,18 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$this
->
assertEquals
(
$expected
,
$actual
);
}
}
public
function
testAlterDecimalPrecisionScale
()
{
$table
=
new
Table
(
'mytable'
);
$table
->
addColumn
(
'dfoo1'
,
'decimal'
);
$table
->
addColumn
(
'dfoo2'
,
'decimal'
,
array
(
'precision'
=>
10
,
'scale'
=>
6
));
$table
->
addColumn
(
'dfoo3'
,
'decimal'
,
array
(
'precision'
=>
10
,
'scale'
=>
6
));
$table
->
addColumn
(
'dfoo4'
,
'decimal'
,
array
(
'precision'
=>
10
,
'scale'
=>
6
));
$tableDiff
=
new
TableDiff
(
'mytable'
);
$tableDiff
->
fromTable
=
$table
;
$tableDiff
->
changedColumns
[
'dloo1'
]
=
new
\Doctrine\DBAL\Schema\ColumnDiff
(
'dloo1'
,
new
\Doctrine\DBAL\Schema\Column
(
'dloo1'
,
\Doctrine\DBAL\Types\Type
::
getType
(
'decimal'
),
array
(
'precision'
=>
16
,
'scale'
=>
6
)
...
...
@@ -373,9 +372,9 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
),
array
(
'precision'
,
'scale'
)
);
$sql
=
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
);
$expectedSql
=
array
(
'ALTER TABLE mytable ALTER dloo1 TYPE NUMERIC(16, 6)'
,
'ALTER TABLE mytable ALTER dloo2 TYPE NUMERIC(10, 4)'
,
...
...
@@ -384,4 +383,31 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$this
->
assertEquals
(
$expectedSql
,
$sql
);
}
/**
* @group DBAL-365
*/
public
function
testDroppingConstraintsBeforeColumns
()
{
$newTable
=
new
Table
(
'mytable'
);
$newTable
->
addColumn
(
'id'
,
'integer'
);
$newTable
->
setPrimaryKey
(
array
(
'id'
));
$oldTable
=
clone
$newTable
;
$oldTable
->
addColumn
(
'parent_id'
,
'integer'
);
$oldTable
->
addUnnamedForeignKeyConstraint
(
'mytable'
,
array
(
'parent_id'
),
array
(
'id'
));
$comparator
=
new
\Doctrine\DBAL\Schema\Comparator
();
$tableDiff
=
$comparator
->
diffTable
(
$oldTable
,
$newTable
);
$sql
=
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
);
$expectedSql
=
array
(
'ALTER TABLE mytable DROP CONSTRAINT FK_6B2BD609727ACA70'
,
'DROP INDEX IDX_6B2BD609727ACA70'
,
'ALTER TABLE mytable DROP parent_id'
,
);
$this
->
assertEquals
(
$expectedSql
,
$sql
);
}
}
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