-
Notifications
You must be signed in to change notification settings - Fork 115
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
PGNumeric support #230
Comments
There's haskell-opaleye/src/Opaleye/Order.hs Line 79 in 7b5e780
But I guess you are saying that we are missing pgNumeric :: Integer -> Column PGNumeric
instance C.PGNum PGNumeric where
pgFromInteger = pgNumeric Do we need anything else? Please feel free to submit a PR! |
I'm pretty new to Haskell and even newer to Opaleye, so sorry for sticking in like this. Shouldn't Numeric be arbitrary precision decimal numbers? Considering that, wouldn't it be better to use
https://www.postgresql.org/docs/9.2/static/datatype-numeric.html |
Sure, that sounds better. |
Just got bitten by this. Is the |
It's absent because no one's ever got round to doing anything about it. According to the postgresql-simple documentation |
Will submit a PR after getting it to work in our app. |
So, we need both instances, right? |
which
|
You need You can try |
Perhaps ideally you need to create |
I've gotten it to work with the following, but I'm not happy:
Problems:
How about https://hackage.haskell.org/package/Decimal-0.4.2 ? Anything better? |
That's fair enough. Use
Why not |
AnnouncementNB I'm taking a holiday from my open source projects until at least 16th January :) Good luck getting this to work. If you really need help from someone before then perhaps you can contact some of the other users who have been posting in the issues pages. |
@tomjaguarpaw one last question before you go :) Is this error related?
|
As this comment says #230 (comment) you need a |
You'll have to work out how to implement |
Now I really am out of here! Bye. |
(If you need any more help with |
Closing as stale. Feel free to reopen if necessary. I'd like to add PGNumeric support to Opaleye but I'm not going to do it unless someone's going to use it. |
@saurabhnanda What's the status on this? |
@ruhatch I don't think anyone attempted it but it should be very easy. |
We've got a version working in our project, but it's not correct. Creating a Decimal requires the knowledge of a precision, IIRC.
|
@saurabhnanda I don't understand what's difficult about this. Could you explain? @ruhatch Perhaps you'd like to open a new issue with a specific request. I've never fully grasped what was being asked for in this thread. |
@tomjaguarpaw can you please reopen this issue. I'd like to pick this up and submit a PR. |
Sure, though perhaps you could clarify exactly what this issue is about. |
This PR isn't going to be easy, and may need some brainstorming. Quoting from the relevant PG documentation:
If I'm reading this correctly, a
|
It seems that the |
I see, thanks. |
I think the lowest common denominator here is to treat Opaleye |
Later one we can consider type-level Natural indexing for the types with specific precision and scale, but I think we should solve the simple case first. |
An important use-case for Quoting https://www.postgresql.org/docs/current/static/datatype-numeric.html -
Quoting https://hackage.haskell.org/package/Decimal-0.4.2 -
I'd really like to setup proper NUMERIC<=>Data.Decimal support, but I'm not sure how to do it. The precision/mantissa part in |
Do you know how persistent deals with this? |
I have no idea. I've never used persistent. |
postgresql-simple uses |
I have no concrete answer, except that "arbitrary precision" and "monetary values" in the same sentence sound dangerous to me. |
Hmm, I would have thought it was the opposite. |
I have this working with @saurabhnanda Can you explain why you think |
In the case of NUMERIC(precision, scale), will Scientific be able to
represent every number that PG can, without any rounding errors (common
IEEE problem with floating points)?
…On 06-Nov-2017 9:59 PM, "Rupert Horlick" ***@***.***> wrote:
I have this working with Scientific and can submit a PR.
@saurabhnanda <https://github.com/saurabhnanda> Can you explain why you
think Scientific wouldn't work?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#230 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABu0aVG3WghmQ-X3IV6sgbJFRM5V7Cbks5szzQGgaJpZM4KqanA>
.
|
Oh, scientific isn't floating point! It's arbitrary precision: https://hackage.haskell.org/package/scientific |
@saurabhnanda I see you said above that |
(Scientific is basically a worse version of |
I'd like to express my support for working numerics in opaleye. If it helps, my use case is for storing monetary values as well, so Decimal -> PGNumeric would help. Unfortunately I dont have the time right now to fix it myself. I should have more free time after christmas though, so if this hasnt been fixed by then I'll try to make a pr. |
I'm not really sure what's holding this up. postgresql-simple already supports conversions to |
I can pick this up next week, unless someone beats me to it before that.
…On 14-Nov-2017 10:19 PM, "tomjaguarpaw" ***@***.***> wrote:
I'm not really sure what's holding this up. postgresql-simple already
supports conversions to Ratio Integer and Scientific. I propose we just
expose them. We can convert to Decimal by adding support to
postgresql-simple or quite easily by going via Scientific, for example.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#230 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABu0d7bYAXMj8CNif1pk_-bNd15_NQ8ks5s2cSSgaJpZM4KqanA>
.
|
@saurabhnanda did you have a chance to look at this yet? I'm considering jumping in here as well, but I won't have the time for another few weeks most likely. |
I only saw a
PGNumeric
instance forIsSqlType
. Am I missing something or is the PGNumeric support incomplete?The text was updated successfully, but these errors were encountered: