steebchen / prisma-client-go

Prisma Client Go is an auto-generated and fully type-safe database client
https://goprisma.org
Apache License 2.0
2.09k stars 94 forks source link

support for "jsonProtocol" #878

Open stillmatic opened 1 year ago

stillmatic commented 1 year ago

Minimally reproducible example -- take quickstart and add a JS generator. See https://github.com/steebchen/prisma-client-go/issues/877, but you can generate with npx prisma db push and then run go run main.go

datasource db {
  // could be postgresql or mysql
  provider = "sqlite"
  url      = "file:dev.db"
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["jsonProtocol", "views"]
}

generator db {
  provider = "go run github.com/steebchen/prisma-client-go"
}

model Post {
  id        String   @default(cuid()) @id
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title     String
  published Boolean
  desc      String?
}

However, I get error

{"level":"fatal","error":"request failed: http status code 422 with response {\"is_panic\":false,\"message\":\"Error parsing Json query. data did not match any variant of untagged enum JsonBody\",\"backtrace\":null}","time":"2023-06-17T14:04:38-04:00","message":"Could not connect to Prisma."}

Removing the jsonProtocol from JS client works, as does generating the clients one at a time (e.g. commenting out the JS generator with jsonProtocol enabled).

steebchen commented 1 year ago

Yes, jsonProtocol is currently not supported in the Go client, and it should not be a big deal to implement. Just haven't gotten to it yet

anupriya17 commented 5 months ago

any update?