Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested update operation throw error when is not the data argument is not provided #2017

Open
cesarve77 opened this issue Feb 27, 2025 · 0 comments

Comments

@cesarve77
Copy link

Description and expected behavior
Nested update operation throw error when is not the data argument is not provided

Screenshots

   //THIS WORKS
    await prisma.user.update({
        where: {id: 1},
        data: {
            video: {
                update: {
                    data: {
                        viewCount: {increment: 1}
                    }
                }
            }
        }
    })
    //This does not work (but is allowed by types)
    await prisma.user.update({
        where: {id: 1},
        data: {
            video: {
                update: {
                    viewCount: {increment: 1}
                }
            }
        }
    })

error

Error calling enhanced Prisma method `user.update`: 
Invalid `prisma.user.update()` invocation:

{
  where: {
    id: 1
  },
  data: {
    video: {
      update: {
        viewCount: {
        ~~~~~~~~~
          increment: 1
        },
?       duration?: Int | IntFieldUpdateOperationsInput,
?       url?: String | StringFieldUpdateOperationsInput,
?       delegate_aux_asset?: AssetUpdateOneRequiredWithoutDelegate_aux_videoNestedInput
      }
    }
  },
  select: {
    id: true
  }
}

Unknown argument `viewCount`. Available options are marked with ?.
    at main (/Users/cesar/www/zens_bug/src/index.ts:42:23) {
  name: 'PrismaClientValidationError',
  clientVersion: '6.4.1',
  internalStack: 'Error calling enhanced Prisma method `user.update`: \n' +
    'Invalid `prisma.user.update()` invocation:\n' +
    '\n' +
    '{\n' +
    '  where: {\n' +
    '    id: 1\n' +
    '  },\n' +
    '  data: {\n' +
    '    video: {\n' +
    '      update: {\n' +
    '        viewCount: {\n' +
    '        ~~~~~~~~~\n' +
    '          increment: 1\n' +
    '        },\n' +
    '?       duration?: Int | IntFieldUpdateOperationsInput,\n' +
    '?       url?: String | StringFieldUpdateOperationsInput,\n' +
    '?       delegate_aux_asset?: AssetUpdateOneRequiredWithoutDelegate_aux_videoNestedInput\n' +
    '      }\n' +
    '    }\n' +
    '  },\n' +
    '  select: {\n' +
    '    id: true\n' +
    '  }\n' +
    '}\n' +
    '\n' +
    'Unknown argument `viewCount`. Available options are marked with ?.\n' +
    '    at PolicyProxyHandler.<anonymous> (/Users/cesar/www/zens_bug/node_modules/@zenstackhq/src/enhancements/node/policy/handler.ts:1199:45),\n' +
    '    at Generator.next (<anonymous>),\n' +
    '    at fulfilled (/Users/cesar/www/zens_bug/node_modules/@zenstackhq/src/enhancements/node/policy/handler.ts:1:56)'
}

Process finished with exit code 1


Environment (please complete the following information):

  • ZenStack version: 2.12.0
  • Prisma version: 6.4.1
  • Database type: any

Reproduce Repo
https://github.com/cesarve77/zenstack_bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant