DDC-365: The return of the numeric columns with more than two decimal places is wrong #453

Closed
opened 2026-01-22 12:38:51 +01:00 by admin · 8 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 23, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user zarpelon:

When I run a select on a column of numbers that is with 4 decimal places and value 0.1500, the object has returned me the following value 0.0015, generating inconsistency in data.

Originally created by @doctrinebot on GitHub (Feb 23, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user zarpelon: When I run a select on a column of numbers that is with 4 decimal places and value 0.1500, the object has returned me the following value 0.0015, generating inconsistency in data.
admin added the Bug label 2026-01-22 12:38:51 +01:00
admin closed this issue 2026-01-22 12:38:52 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 23, 2010):

Comment created by romanb:

We need example code to reproduce the problem.

@doctrinebot commented on GitHub (Feb 23, 2010): Comment created by romanb: We need example code to reproduce the problem.
Author
Owner

@doctrinebot commented on GitHub (Feb 23, 2010):

Comment created by zarpelon:

My column in my example.yml

value_base:
type: decimal
precision: 14
scale: 4

My function in ExampleRepository

public function getQueryBuilder()
{
$qb = $this->_em->createQueryBuilder()
->select('e')
->from('Project\DomainModel\Example, 'e');

    return $qb;
}
@doctrinebot commented on GitHub (Feb 23, 2010): Comment created by zarpelon: # My column in my example.yml value_base: type: decimal precision: 14 scale: 4 # My function in ExampleRepository public function getQueryBuilder() { $qb = $this->_em->createQueryBuilder() ->select('e') ->from('Project\DomainModel\Example, 'e'); ``` return $qb; } ```
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2010):

Comment created by @beberlei:

Works for me, i added a test-case with your numbers in Doctrine\Tests\ORM\Functional\TypeTest. Please make it break with your use-case, until then this issue is invalid.

@doctrinebot commented on GitHub (Feb 26, 2010): Comment created by @beberlei: Works for me, i added a test-case with your numbers in Doctrine\Tests\ORM\Functional\TypeTest. Please make it break with your use-case, until then this issue is invalid.
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2010):

Comment created by zarpelon:

I saw your test, but as I have the test environment setup, could not complement the test case. I believe that when the value of highscale for example 0.1500 to 0.0015 will return. You can try, please?

@doctrinebot commented on GitHub (Feb 26, 2010): Comment created by zarpelon: I saw your test, but as I have the test environment setup, could not complement the test case. I believe that when the value of highscale for example 0.1500 to 0.0015 will return. You can try, please?
Author
Owner

@doctrinebot commented on GitHub (Mar 14, 2010):

Comment created by @beberlei:

It still works for me, can you report your locale options please?

@doctrinebot commented on GitHub (Mar 14, 2010): Comment created by @beberlei: It still works for me, can you report your locale options please?
Author
Owner

@doctrinebot commented on GitHub (Apr 5, 2010):

Comment created by zarpelon:

Locale = pt_BR.UTF-8

@doctrinebot commented on GitHub (Apr 5, 2010): Comment created by zarpelon: Locale = pt_BR.UTF-8
Author
Owner

@doctrinebot commented on GitHub (Apr 5, 2010):

Comment created by @guilhermeblanco:

@zarpelon
It is not a bug of Doctrine. It's a DB issue.
When dealing with locales in DB and PHP is not so obvious. Brazil uses commas for decimal and points for million information.
When you define the value 0.0015, it contains 4 numbers when it expects to have only 3. So it ignores padded 0 values from value, leading the 0015 => 15. Finally, it returns the vaue since 0 (of 0.) is < 3 chars expected.

To solve it, you have to manually deal with number_format and define locale specific settings in order to work correctly.
I'll make a note here if we can do anything related to that, but I doubt it'll be possible.

Cheers,

@doctrinebot commented on GitHub (Apr 5, 2010): Comment created by @guilhermeblanco: @zarpelon It is not a bug of Doctrine. It's a DB issue. When dealing with locales in DB and PHP is not so obvious. Brazil uses commas for decimal and points for million information. When you define the value 0.0015, it contains 4 numbers when it expects to have only 3. So it ignores padded 0 values from value, leading the 0015 => 15. Finally, it returns the vaue since 0 (of 0.) is < 3 chars expected. To solve it, you have to manually deal with number_format and define locale specific settings in order to work correctly. I'll make a note here if we can do anything related to that, but I doubt it'll be possible. Cheers,
Author
Owner

@doctrinebot commented on GitHub (Apr 5, 2010):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Apr 5, 2010): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#453