Skip to content

Incorrect filter injection for nested reads #624

Closed
@ymc9

Description

@ymc9
{
  where: {
    styleId: "at523y9a7chunoinnqh00zix",
    organizationId: "clgwngf8p0000rvjrpyf2km8t", // Added by Zenstack
    comments: {  // Added by Zenstack
      createdBy: {  // Added by Zenstack and ERRORed
      ~~~~~~~~~
        orgMembership: {
          some: {
            organizationId: {
              equals: "clgwngf8p0000rvjrpyf2km8t"
            }
          }
        }
      },
?     every?: CommentWhereInput,
?     some?: CommentWhereInput,
?     none?: CommentWhereInput
    }
  },
  select: {
    id: true,
    title: true,
    comments: {
      // SHOULDN'T ZENSTACK ADD WHERE CLAUSE HERE
      // where: { organizationId } 
      select: {
        _count: {
          select: {
            readReceipts: {
              where: {
                AND: [
                  {
                    createdById: "682387bd-ef05-43a2-90eb-b6ba10992f4f"
                  },
                  {
                    organizationId: {  // Added by Zenstack ✅
                      equals: "clgwngf8p0000rvjrpyf2km8t"
                    }
                  }
                ]
              }
            }
          }
        }

Repro project: https://github.com/bvkimball/zenstack-multitenant-repro

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