next-admin icon indicating copy to clipboard operation
next-admin copied to clipboard

[BUG] - can't have an empty array for Prisma fields

Open ianwatts22 opened this issue 1 year ago • 1 comments

Description

Prisma arrays technically cannot be optional, so when you don't enter values it creates an empty array. When trying to edit an entry in NextAdmin, it won't let me leave this array empty, as it requires a value. Need it to write an empty array by default. We're getting around it right now by disabling editing on this field.

image

Reproduction URL

cannot share

Reproduction steps

Any Prisma value with an empty array. Below is the structure we have.

model Collection {
  id          Int       @id @default(autoincrement())
  createdAt   DateTime  @default(now())
  type        CollectionType
  overrides   Override[]
}

enum Override {
  ROTATE
  AUTOCROP
  DUPLICATE
}

Next router

App router

Next Admin version

7.0.1

Screenshots

![DESCRIPTION](LINK.png)

Next Admin options

No response

Logs

No response

Browsers

Chrome, Safari

ianwatts22 avatar Dec 02 '24 19:12 ianwatts22

Hello, would it not be possible for you to add @default([]) to your field ?

foyarash avatar Dec 06 '24 11:12 foyarash