Skip to content

Natural values don't fit into an sql database #1031

Closed

Description

@NorfairKing

instance PersistFieldSql Natural where
sqlType _ = SqlInt64

This fails to round-trip for naturals bigger than a Word64.
I would argue that this instance should be removed.
If you don't need naturals that big, then just use the Word64 instance instead.
If you do, then you expect them to roundtrip.

Activity

  1. parsonsmatt commented on Feb 10, 2020

    @parsonsmatt
    Collaborator

    Good catch, thanks! Removing the instance seems right, given that we don't provide an instance for Integer and there doesn't appear to be a truly unbounded number type. MySQL supports 65 digits in numeric, and Postgres supports 1000 digits, which are both huge but not infinite.

  2. added this to the 2.11 milestone on Feb 11, 2020
  3. hdgarrood commented on Feb 18, 2020

    @hdgarrood
    Contributor

    I think by this argument the Rational instances should be considered for removal, too? Currently Rational is represented as numeric(32,20):

    instance PersistFieldSql Rational where
    sqlType _ = SqlNumeric 32 20 -- need to make this field big enough to handle Rational to Mumber string conversion for ODBC

    but there are lots of rational numbers which can't be represented exactly this way. In particular, anything with more than 20 decimal places, anything with more than 32 significant figures, and also any fraction with a denominator which has prime factors other than 2 or 5 (such as 1/3).

  4. NorfairKing commented on Feb 18, 2020

    @NorfairKing
    ContributorAuthor

    Yes, please remove them too!

  5. NorfairKing commented on Feb 18, 2020

    @NorfairKing
    ContributorAuthor

    You could still have Ratio Int32 maybe..

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions