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

thread 'tokio-runtime-worker' panicked at 'called Option::unwrap() on a None value', /Users/runner/.cargo/git/checkouts/quaint-9f01e008b9a89c14/479e08a/src/connector/postgres/conversion/decimal.rs:81:39 #13219

Closed
ruheni opened this issue May 6, 2022 · 0 comments · Fixed by prisma/quaint#379
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: Decimal Scalar type `Decimal`
Milestone

Comments

@ruheni
Copy link
Contributor

ruheni commented May 6, 2022

Bug description

Create query returns a tokio-runtime-worker panicked error when creating/ updating values with Decimals

const entry = await prisma.entry.create({
  data: {
    value: '934310062234567898765456789098765456789034343600000.345678'
  }
})

Leads to the following error:

thread 'tokio-runtime-worker' panicked at 'called `Option::unwrap()` on a `None` value', /Users/runner/.cargo/git/checkouts/quaint-9f01e008b9a89c14/479e08a/src/connector/postgres/conversion/decimal.rs:81:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
/Users/ruheni/Documents/repos/work/prisma/temp/prisma-decimal-precision-repro/node_modules/@prisma/client/runtime/index.js:45633
        throw new PrismaClientUnknownRequestError(message, this.client._clientVersion);
              ^
PrismaClientUnknownRequestError: 
Invalid `prisma.entry.create()` invocation in
/Users/ruheni/Documents/repos/work/prisma/temp/prisma-decimal-precision-repro/index.ts:6:34

  3 const prisma = new PrismaClient()
  4 
  5 async function run() {
→ 6 const entry = await prisma.entry.create(
  called `Option::unwrap()` on a `None` value
    at Object.request (/Users/ruheni/Documents/repos/work/prisma/temp/prisma-decimal-precision-repro/node_modules/@prisma/client/runtime/index.js:45633:15)
    at async PrismaClient._request (/Users/ruheni/Documents/repos/work/prisma/temp/prisma-decimal-precision-repro/node_modules/@prisma/client/runtime/index.js:46456:18) {
  clientVersion: '3.13.0'
}

How to reproduce

git clone git@github.com:ruheni/tokio-decimal-repro.git
cd tokio-decimal-repro
yarn
docker-compose up -d
npx prisma db push
npx ts-node index.ts

Expected behavior

Throw a validation error or successfully persist the record in the database

Prisma information

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = "postgresql://postgres:postgres@localhost:5433/decimal-precision-repro?sslmode=disable"
}

model Entry {
  id    Int     @id @default(autoincrement())
  value Decimal
}

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL v 14
  • Node.js version: 16.13.1

Prisma Version

Environment variables loaded from .env
prisma                  : 3.13.0
@prisma/client          : 3.13.0
Current platform        : darwin
Query Engine (Node-API) : libquery-engine efdf9b1183dddfd4258cd181a72125755215ab7b (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli efdf9b1183dddfd4258cd181a72125755215ab7b (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core efdf9b1183dddfd4258cd181a72125755215ab7b (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt efdf9b1183dddfd4258cd181a72125755215ab7b (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : efdf9b1183dddfd4258cd181a72125755215ab7b
Studio                  : 0.459.0
@ruheni ruheni added the kind/bug A reported bug. label May 6, 2022
@ruheni ruheni changed the title thread 'tokio-runtime-worker' panicked at 'called Option::unwrap() on a None value', /Users/runner/.cargo/git/checkouts/quaint-9f01e008b9a89c14/479e08a/src/connector/postgres/conversion/decimal.rs:81:39 thread 'tokio-runtime-worker' panicked at 'called Option::unwrap() on a None value', /Users/runner/.cargo/git/checkouts/quaint-9f01e008b9a89c14/479e08a/src/connector/postgres/conversion/decimal.rs:81:39 May 6, 2022
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. topic: Decimal Scalar type `Decimal` labels May 7, 2022
@Weakky Weakky self-assigned this Jun 15, 2022
@janpio janpio added this to the 4.0.x milestone Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: Decimal Scalar type `Decimal`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants