I have a flutter application that I want to use SQLite database with Prisma ORM based on the work done at https://prisma.pub.
everything seems to work fine until I run the command dart run build_runner build
then it fails to generate the dart prisma client to work with the Prisma generated Client.
This is the prisma schema I'm working with for now
generator client {
provider = "dart run orm"
}
datasource db {
provider = "sqlite"
url = "file:./source.db"
}
model User {
id String @id @default(uuid())
email String @unique
firstname String?
lastname String?
userpass String
role String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
status Boolean @default(true)
userID String? @unique
}
on running
npx prisma generate
,
the prisma client is successfully generated and expects this file
part 'prisma_client.g.dart';
however when I run
dart run build_runner build
I get the following error:
$ dart run build_runner build
[INFO] Generating build script completed, took 296ms
[INFO] Reading cached asset graph completed, took 89ms
[INFO] Checking for updates since last build completed, took 800ms
[INFO] Running build completed, took 21ms
[INFO] Caching finalized dependency graph completed, took 46ms
[SEVERE] json_serializable on lib/src/generated/prisma/prisma_client.dart (cached):
Could not generate `fromJson` code for `equals`.
To support the type `InvalidType` you can:
* Use `JsonConverter`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html
* Use `JsonKey` fields `fromJson` and `toJson`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html
package:class_wise/src/generated/prisma/prisma_client.dart:567:30
╷
567 │ final StringFieldRefInput? equals;
│ ^^^^^^
╵
[SEVERE] Failed after 83ms
Since i would be adding more models, I would like a permanent solution to this so that I dont have to manually code the toJson of every unavailable data type conversion error that will arise.
I have searched onlne but it seems there is very little engagement with this stack combination, any help in any form will be very much appreciated. thank you.
what he said :
Unfortunately, Prisma for Dart does not currently support Prisma 5.x version (due to huge changes). Also you should see my tweets, I am now committed to my normal life due to the bankruptcy of my company. I'm really sorry, I don't know when I will have time to come back and continue to maintain it, but I have always paid attention to this project. Once I get my debt out of the way, I'll go back to open source and continue maintaining Prisma for Dart.
you can check this link https://github.com/odroe/prisma-dart/issues/259