Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.83k stars 108 forks source link

BigInt serialization configuration #266

Open beeb opened 1 year ago

beeb commented 1 year ago

When using BigInt, the generated client uses i64 which leads RSPC to generate a TS binding using bigint as the type.

However, when passing this as value to the RSPC endpoint, JS complains that it can't serialize it as JSON. How can I overcome this limitation to use prisma-client-rust with RSPC using Bigint? Not sure if this is an RSPC issue or prisma one, sorry if I posted in the wrong repo.

Cheers

beeb commented 1 year ago

It seems bigint is not supported (or at least won't be in 0.2.0) by rspc: https://github.com/oscartbeaumont/rspc/issues/106

What's the plan for prisma-client-rust? Generating bindings that use string and automatically serialize/deserialize i64 maybe?

Brendonovich commented 1 year ago

Usually if people have issues with BigInt and Specta we tell them to use #[specta(type = String)] and serialize as string, but you're right in that you can't exactly do that with a Prisma client. Perhaps I could add an option to the generator that would do so.

beeb commented 1 year ago

That would be very helpful I think, thanks for the acknowledgment!