Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Mutating a Float sometimes results on sightly different value written to Postgres #555

Closed
snake575 opened this issue Mar 6, 2020 · 4 comments
Assignees
Labels
bug/1-repro-available A reproduction exists and needs to be confirmed. kind/bug A reported bug. topic: types
Milestone

Comments

@snake575
Copy link

snake575 commented Mar 6, 2020

Hi, I found a problem that may be related to #537

I'm using the same reproduction repo with a different amount 0.00071832 on the mutation.

snake575/prisma-float-error

Mutation:

const transaction = await prisma.transaction.create({
  data: {
    amount: 0.00071832,
    currency: 'BTC',
  },
})
console.log({ transaction })

Returns correct amount:

{ transaction: { id: 2, amount: 0.00071832, currency: 'BTC' } }

But a sightly different value is written to Postgres:

2020-03-06 17:00:27.304 -03 [33] LOG: execute s0: INSERT INTO "public"."Transaction" ("amount","currency") VALUES ($1,$2) RETURNING "public"."Transaction"."id"
2020-03-06 17:00:27.304 -03 [33] DETAIL: parameters: $1 = '0.0007183200000000001', $2 = 'BTC
@tomhoule
Copy link

Fixed in alpha 927 - it will be in the next preview :) Also see #537

@janpio
Copy link
Member

janpio commented Mar 18, 2020

@snake575 Can you maybe try out with alpha 927 and report back if the error is fixed for you? That would be awesome.

@snake575
Copy link
Author

@janpio I confirm it's fixed on alpha 927, it's also fixed on preview-24 😃

@janpio
Copy link
Member

janpio commented Mar 18, 2020

Wonderful. Thanks! 🐰

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/1-repro-available A reproduction exists and needs to be confirmed. kind/bug A reported bug. topic: types
Projects
None yet
Development

No branches or pull requests

3 participants