omar-dulaimi / prisma-zod-generator

Prisma 2+ generator to emit Zod schemas from your Prisma schema
MIT License
535 stars 45 forks source link

Generator doesn't generate schema from column type decimal #11

Closed omar-dulaimi closed 2 years ago

omar-dulaimi commented 2 years ago

Bug description

A decimal field is not getting generated in the schemas

How to reproduce

Expected behavior

No response

Prisma information

generator client {
  provider               = "prisma-client-js"
  output                 = "./client"
  customPrismaImportPath = "../client"
}

generator trpc {
  provider       = "prisma-trpc-generator"
  withMiddleware = false
  withShield     = false
  contextPath    = "../../../../src/context"
  output         = "./trpc"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

generator zod {
  provider = "zod-prisma"
  output   = "./zod" // (default) the directory where generated zod schemas will be saved

  relationModel = true // (default) Create and export both plain and related models.
  // relationModel         = "default" // Do not export model without relations.
  // relationModel         = false // Do not generate related model

  // modelCase                = "PascalCase" // (default) Output models using pascal case (ex. UserModel, PostModel)
  modelCase = "camelCase" // Output models using camel case (ex. userModel, postModel)

  modelSuffix = "Model" // (default) Suffix to apply to your prisma models when naming Zod schemas

  // useDecimalJs          = false // (default) represent the prisma Decimal type using as a JS number
  useDecimalJs = true // represent the prisma Decimal type using Decimal.js (as Prisma does)

  // https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-by-null-values
  prismaJsonNullability = true // (default) uses prisma's scheme for JSON field nullability
  // prismaJsonNullability = false // allows null assignment to optional JSON fields
}

model Test {
  id        Int      @id @default(autoincrement())
  name      String?
  amount    Decimal? @db.Decimal(9, 2)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Environment & setup

Prisma Version

prisma                  : 4.1.1
@prisma/client          : 4.1.1
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at ../../node_modules/prisma/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at ../../node_modules/prisma/node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at ../../node_modules/prisma/node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at ../../node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash    : 8d8414deb360336e4698a65aa45a1fbaf1ce13d8
Studio                  : 0.469.0