Skip to content

Many-to-many update check failing with connect #2531

Description

@f8k8

Description and expected behavior
When trying to create and connect an object, in the same operation, which has the following policy:
@@allow('read,update', auth() != null && parents?[id == auth().id])

The create fails with a model not updatable error:
ORMError: many-to-many relation participant model "Child" not updatable

The read back should succeed though, as the parent would be connected as part of the operation:

const child = await authedClient.child.create({
    data: {
      name: "Child",
      parents: {
        connect: { id: userId },
      },
    },
  });

Environment:

  • ZenStack version: 3.5.2
  • Database type: Postgres / SQLite
  • Node.js version: 24.11.1
  • Package manager: npm

Additional context
There's a reproduction repo here: https://github.com/f8k8/ZenstackConnectPermissionIssue
Running npm install will install the dependencies and seed the database, then run npm run start to see the error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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