Skip to content

Provider-specific type for arbitrary-length numeric #1651

Closed

Description

@abelykh0

Before submitting

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).

Exception message:
Stack trace:

Further technical details

Npgsql version:
PostgreSQL version:
Operating system:

Other details about my project setup:

Activity

  1. abelykh0 commented on Jul 28, 2017

    @abelykh0
    Author

    How to repeat:

    1. Create a table like that:
      CREATE TABLE long_number (a decimal(36,2));
      insert into long_number values (9999999999999999999999999999999999.99);

    2. 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

  2. roji commented on Jul 28, 2017

    @roji
    Member

    As a workaround, you can always have PostgreSQL convert to double by casting the value in SQL.

  3. 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
  4. abelykh0 commented on Aug 4, 2017

    @abelykh0
    Author

    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.

  5. roji commented on Aug 5, 2017

    @roji
    Member

    You're right, I forgot #448 existed. Closing as a dup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions