Closed austenstrine closed 2 months ago
This PR fixes the issue: https://github.com/omar-dulaimi/prisma-class-validator-generator/pull/15
Until such a time as this package approves the PR that adds support for Bytes (as Buffer), feel free to link this "build" branch directly in your projects. It's literally just a compiled version of the PR:
With yarn: yarn remove prisma-class-validator-generator yarn add prisma-class-validator-generator@https://github.com/austenstrine/prisma-class-validator-generator.git#build
With npm: npm uninstall prisma-class-validator-generator npm install austenstrine/prisma-class-validator-generator.git#build
Obviously not as good as the PR just getting merged, but better than waiting if you're in a pinch and need a solution "now" like I do.
Hey @austenstrine Thanks for the PR. will merge it now and release
Thank you for the quick response, sir.
My pleasure @austenstrine If you can, please consider supporting me :)
Bug description
When adding a Bytes field into a schema.prisma table, the resulting generated class sets the property as type Bytes, which is not a typescript type. This throws a type error. It should be Buffer instead.
How to reproduce
Add a Bytes type into the schema.prisma
Run npx prisma generate
Expected behavior
I expected the generator to convert Bytes into the Buffer type.
Prisma information
generator client { provider = "prisma-client-js" engineType = "binary" binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"] previewFeatures = ["fullTextSearch"] }
datasource db { provider = "postgresql" url = env("DATABASE_URL") }
generator class_validator { provider = "prisma-class-validator-generator" }
model FileUpload { id Int @unique @id @default(autoincrement()) businessId Int userId Int? email String? schema Json? lineItemCount Int pdfName String? pdfData Bytes? @db.ByteA pdfUri String? spreadsheetName String? spreadsheetData Bytes? @db.ByteA spreadsheetUri String? approved Boolean @default(false) errors String[] attempts Int @default(0) created DateTime @default(now()) updated DateTime @updatedAt }
Environment & setup
OS: Debian GNU/Linux 11 (bullseye)
DB: psql (PostgreSQL) 13.13 (Debian 13.13-0+deb11u1)
Node: v18.19.0
Prisma Version
prisma : 4.16.2 @prisma/client : 4.16.2 Current platform : debian-openssl-1.1.x Query Engine (Node-API) : libquery-engine 4bc8b6e1b66cb932731fb1bdbbc550d1e010de81 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node) Migration Engine : migration-engine-cli 4bc8b6e1b66cb932731fb1bdbbc550d1e010de81 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x) Format Wasm : @prisma/prisma-fmt-wasm 4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81 Default Engines Hash : 4bc8b6e1b66cb932731fb1bdbbc550d1e010de81 Studio : 0.484.0 Preview Features : fullTextSearch