Skip to content

Input validation is being ignored when using increment functionality #2303

@Huh-David

Description

@Huh-David

Description and expected behavior
Taken from the examples in the docs I have created a Content model with a viewCount field.

model Content {
    id        Int      @id @default(autoincrement())
    name      String
    createdAt DateTime @default(now())
    owner     User     @relation(fields: [ownerId], references: [id])
    ownerId   Int
    viewCount Int      @default(0) @gte(0)
    type      String

    @@delegate(type)
}

The viewCount field has an input validator to check if its greater or equal to 0. When trying to create or update the content object, it will properly check (after regenerating the client) the viewCount to match this condition. When using the increment functionality on update, this validation does not happen.

await db.content.update({
       where: { id: contentId },
       data: {
           viewCount: {
               increment: incrementBy,
           },
       },
   });

Environment (please complete the following information):

  • ZenStack version: 3.0.0-beta.24
  • Database type: PostgreSQL

Additional context
Is this a known caveat of the Input Validation at ORM level?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions