You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provider-specific type for arbitrary-length numeric #1651
This repo is for Npgsql ADO.NET issues only. Entity Framework issues belong in Npgsql.EntityFrameworkCore.PostgreSQL for EF Core, or EntityFramework6.Npgsql for EF 6.x.
Steps to reproduce
Ideally include a complete code listing that we can run to reproduce the issue.
Alternatively, you can provide a project/solution that we can run.
The issue
Describe what is not working as expected.
If you are seeing an exception, include the full exceptions details (message and stack trace).
Create a table like that:
CREATE TABLE long_number (a decimal(36,2));
insert into long_number values (9999999999999999999999999999999999.99);
Try to read the data from this table:
....
return pgReader[columnIndex];
....
This will throw OverflowException (as expected). Well, at least that's what MS and Oracle providers do :) It seems that currently there's no way of getting the value from the table.
It was possible to get the value in NpgSql 2 by getting byte array and converting it to double.
Suggested fix:
Do the same thing what MS or Oracle does. Introduce a new type NpgsqlTypes.NpgsqlDecimal and add a new method NpgsqlDecimalDataReader.GetNpgsqlDecimal(). I should be able to use NpgsqlDecimal.ToDouble() and NpgsqlDecimal.ToString().
Npgsql version: 3.2.5.0
PostgreSQL version: 9.1.8
Operating system: Windows 7 64 bit
changed the title [-]Impossible to retrieve decimal value if it doesn't fit into .Net System.Decimal[/-][+]Provider-specific type for arbitrary-length numeric[/+]on Jul 28, 2017
Roji, I am not sure why you changed this to feature as you have a similar feature already )#448). All I am interested in is to be able to read the number and convert it to either string or double.
Activity
abelykh0 commentedon Jul 28, 2017
How to repeat:
Create a table like that:
CREATE TABLE long_number (a decimal(36,2));
insert into long_number values (9999999999999999999999999999999999.99);
Try to read the data from this table:
....
return pgReader[columnIndex];
....
This will throw OverflowException (as expected). Well, at least that's what MS and Oracle providers do :) It seems that currently there's no way of getting the value from the table.
It was possible to get the value in NpgSql 2 by getting byte array and converting it to double.
Suggested fix:
Do the same thing what MS or Oracle does. Introduce a new type NpgsqlTypes.NpgsqlDecimal and add a new method NpgsqlDecimalDataReader.GetNpgsqlDecimal(). I should be able to use NpgsqlDecimal.ToDouble() and NpgsqlDecimal.ToString().
Npgsql version: 3.2.5.0
PostgreSQL version: 9.1.8
Operating system: Windows 7 64 bit
roji commentedon Jul 28, 2017
As a workaround, you can always have PostgreSQL convert to double by casting the value in SQL.
[-]Impossible to retrieve decimal value if it doesn't fit into .Net System.Decimal[/-][+]Provider-specific type for arbitrary-length numeric[/+]abelykh0 commentedon Aug 4, 2017
Roji, I am not sure why you changed this to feature as you have a similar feature already )#448). All I am interested in is to be able to read the number and convert it to either string or double.
roji commentedon Aug 5, 2017
You're right, I forgot #448 existed. Closing as a dup.