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
c8d97d3e
Commit
c8d97d3e
authored
Apr 06, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-106] Fix default precision handling.
parent
ad86e915
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
Column.php
lib/Doctrine/DBAL/Schema/Column.php
+9
-1
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+1
-1
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+14
-0
No files found.
lib/Doctrine/DBAL/Schema/Column.php
View file @
c8d97d3e
...
...
@@ -159,6 +159,10 @@ class Column extends AbstractAsset
*/
public
function
setPrecision
(
$precision
)
{
if
(
!
is_numeric
(
$precision
))
{
$precision
=
10
;
// defaults to 10 when no valid precision is given.
}
$this
->
_precision
=
(
int
)
$precision
;
return
$this
;
}
...
...
@@ -169,7 +173,11 @@ class Column extends AbstractAsset
*/
public
function
setScale
(
$scale
)
{
$this
->
_scale
=
$scale
;
if
(
!
is_numeric
(
$scale
))
{
$scale
=
0
;
}
$this
->
_scale
=
(
int
)
$scale
;
return
$this
;
}
...
...
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
c8d97d3e
...
...
@@ -335,7 +335,7 @@ class Comparator
}
if
(
$column1
->
getType
()
instanceof
\Doctrine\DBAL\Types\DecimalType
)
{
if
(
$column1
->
getPrecision
()
!=
$column2
->
getPrecision
(
))
{
if
(
(
$column1
->
getPrecision
()
?:
10
)
!=
(
$column2
->
getPrecision
()
?:
10
))
{
$changedProperties
[]
=
'precision'
;
}
if
(
$column1
->
getScale
()
!=
$column2
->
getScale
())
{
...
...
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
c8d97d3e
...
...
@@ -653,6 +653,20 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
0
,
count
(
$tableDiff
->
removedColumns
));
}
/**
* @group DBAL-106
*/
public
function
testDiffDecimalWithNullPrecision
()
{
$column
=
new
Column
(
'foo'
,
Type
::
getType
(
'decimal'
));
$column
->
setPrecision
(
null
);
$column2
=
new
Column
(
'foo'
,
Type
::
getType
(
'decimal'
));
$c
=
new
Comparator
();
$this
->
assertEquals
(
array
(),
$c
->
diffColumn
(
$column
,
$column2
));
}
/**
* @param SchemaDiff $diff
* @param int $newTableCount
...
...
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