adminjs-prisma icon indicating copy to clipboard operation
adminjs-prisma copied to clipboard

Integer arrays are not working properly

Open lok52 opened this issue 2 years ago • 1 comments

convertParam function doesn't handle arrays. When it converts an integer array property (prisma type is Int[]) it tries to parse it as a Number and it leads to undefined behaviour. I believe to fix that you need to override isArray method in the Property class and adjust convertParam accordingly. https://github.com/SoftwareBrothers/adminjs-prisma/blob/0cd6a63a18c0419942e00a3ed1a30847fd012a4b/src/utils/converters.ts#L8-L31

As a temporary fix I have to patch convertParam with something like this:

if (Array.isArray(value)) return value.map((v) => convertParam(property, fields, v));

lok52 avatar Mar 14 '24 10:03 lok52

Would love to see a fix for this, as any model with Type[] or JSONB arrays are no longer editable through the dashboard. All update requests send NaN for any Int[] fields that we're commonly using in our schema.

Ariastarcos avatar May 21 '24 11:05 Ariastarcos