Skip to content

[Bug] Optimistic updates and undefined in @zenstackhq/tanstack-query plug-inΒ #2292

@ellie-xpawn

Description

@ellie-xpawn

Description and expected behavior
I'm using the optimistic update flag in my mutation useUpdate[model]({ optimisticUpdate: true }), and when I pass undefined to a field, it is getting stored in the cache - Prisma will ignore a field if it is set to undefined, so it won't update in the DB. This doesn't happen when the data is initially fetched from the server.

There is an easy workaround in this case, as I only have one field to update. I can just pass an empty object if my value is undefined.

Screenshots

Image Image

query.data affected by the mutation logged to console:
Image

Environment (please complete the following information):

  • ZenStack version: 2.21.0
  • Prisma version: 6.17.1
  • Database type: Postgres (Neon)

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