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
4ce45f76
Commit
4ce45f76
authored
Dec 18, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-614' into 2.4
parents
f27a56a2
ef859c75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletion
+50
-1
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+1
-1
PostgreSqlPlatformTest.php
.../Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+49
-0
No files found.
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
4ce45f76
...
@@ -421,7 +421,7 @@ class PostgreSqlPlatform extends AbstractPlatform
...
@@ -421,7 +421,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$oldColumnName
=
$columnDiff
->
oldColumnName
;
$oldColumnName
=
$columnDiff
->
oldColumnName
;
$column
=
$columnDiff
->
column
;
$column
=
$columnDiff
->
column
;
if
(
$columnDiff
->
hasChanged
(
'type'
))
{
if
(
$columnDiff
->
hasChanged
(
'type'
)
||
$columnDiff
->
hasChanged
(
'precision'
)
||
$columnDiff
->
hasChanged
(
'scale'
)
)
{
$type
=
$column
->
getType
();
$type
=
$column
->
getType
();
// here was a server version check before, but DBAL API does not support this anymore.
// here was a server version check before, but DBAL API does not support this anymore.
...
...
tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
View file @
4ce45f76
...
@@ -4,6 +4,8 @@ namespace Doctrine\Tests\DBAL\Platforms;
...
@@ -4,6 +4,8 @@ namespace Doctrine\Tests\DBAL\Platforms;
use
Doctrine\DBAL\Platforms\PostgreSqlPlatform
;
use
Doctrine\DBAL\Platforms\PostgreSqlPlatform
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\TableDiff
;
class
PostgreSqlPlatformTest
extends
AbstractPlatformTestCase
class
PostgreSqlPlatformTest
extends
AbstractPlatformTestCase
{
{
...
@@ -314,5 +316,52 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
...
@@ -314,5 +316,52 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$this
->
assertEquals
(
'1'
,
$platform
->
convertBooleans
(
true
));
$this
->
assertEquals
(
'1'
,
$platform
->
convertBooleans
(
true
));
$this
->
assertEquals
(
'0'
,
$platform
->
convertBooleans
(
false
));
$this
->
assertEquals
(
'0'
,
$platform
->
convertBooleans
(
false
));
}
}
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
)
),
array
(
'precision'
)
);
$tableDiff
->
changedColumns
[
'dloo2'
]
=
new
\Doctrine\DBAL\Schema\ColumnDiff
(
'dloo2'
,
new
\Doctrine\DBAL\Schema\Column
(
'dloo2'
,
\Doctrine\DBAL\Types\Type
::
getType
(
'decimal'
),
array
(
'precision'
=>
10
,
'scale'
=>
4
)
),
array
(
'scale'
)
);
$tableDiff
->
changedColumns
[
'dloo3'
]
=
new
\Doctrine\DBAL\Schema\ColumnDiff
(
'dloo3'
,
new
\Doctrine\DBAL\Schema\Column
(
'dloo3'
,
\Doctrine\DBAL\Types\Type
::
getType
(
'decimal'
),
array
(
'precision'
=>
10
,
'scale'
=>
6
)
),
array
()
);
$tableDiff
->
changedColumns
[
'dloo4'
]
=
new
\Doctrine\DBAL\Schema\ColumnDiff
(
'dloo4'
,
new
\Doctrine\DBAL\Schema\Column
(
'dloo4'
,
\Doctrine\DBAL\Types\Type
::
getType
(
'decimal'
),
array
(
'precision'
=>
16
,
'scale'
=>
8
)
),
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)'
,
'ALTER TABLE mytable ALTER dloo4 TYPE NUMERIC(16, 8)'
,
);
$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