Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUMERIC, Scientific, NaN #651

Open
jchia opened this issue Dec 13, 2022 · 1 comment
Open

NUMERIC, Scientific, NaN #651

jchia opened this issue Dec 13, 2022 · 1 comment

Comments

@jchia
Copy link

jchia commented Dec 13, 2022

A Postgresql NUMERIC value can be NaN, but a Haskell Scientific value cannot.

However, numeric links NUMERIC to Scientific. What can I do if I want to use NUMERIC columns with NaN values?

The next best thing I can do is to make the column nullable, but I would rather simply use NaN since Postgresql allows it.

decimal does what I want except that I am trying to use decimal fixed-point numbers, which Scientific affords, not binary floating-point numbers.

If instead of:

numeric :: BeamSqlBackend be => Maybe (Word, Maybe Word) -> DataType be Scientific

there is:

numeric :: BeamSqlBackend be => Maybe (Word, Maybe Word) -> DataType be (Maybe Scientific)

Then NaN could be represented as Nothing and my immediate problem would be fixed, though +/-Inf would still be problematic.

@LaurentRDC
Copy link
Member

Low-level mapping between basic Haskell types and PostgreSQL types is handled by the postgresql-simple library. Since Scientific is such a foundational type, I am weary of messing with it in beam

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

No branches or pull requests

3 participants