zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.15k stars 88 forks source link

Decimal.js-light is not compatible with Prisma.Decimal #1702

Open sarioglu opened 2 months ago

sarioglu commented 2 months ago

Description and expected behavior I saw that @zenstackhq/runtime replaced decimal.js with its light version. This breaks the compatibility with Prisma. I use nextjs app router with prisma on server-side and zenstack with swr on client-side for things like modals, etc. For some scenarios I use a conversion like new Prisma.Decimal(someDecimalComingFromZenstack ?? aNumber). With 2.5.0 such conversions does not work because decimal.js checks if input to constructor is instanceof Decimal.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

ymc9 commented 2 weeks ago

Hi @sarioglu , I understand it's not ideal, but feel that over all it's worth the reduced bundle size. A workaround could be use the string constructor?

new Prisma.Decimal(someDecimalComingFromZenstack?.toString() ?? aNumber)
sarioglu commented 1 week ago

Hi 👋 Thank you for your response. I did that as an interim solution. But it won't prevent us from having the same issue in the future. I wonder if there's another way to make sure Decimal-light works with Decimal.