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

Regression bug: batched findUniqueOrThrow queries throw 'Field does not exist on enclosing type.' #16548

Closed
DarioSiroki opened this issue Nov 30, 2022 · 1 comment · Fixed by prisma/prisma-engines#3458
Labels
kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. topic: batching
Milestone

Comments

@DarioSiroki
Copy link

Bug description

I assume there was a query batching update in 4.7.0. which doesn't seem to be working properly. The provided example works with 4.6.1.

/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:34843
      throw new PrismaClientKnownRequestError(message, {
            ^
PrismaClientKnownRequestError: 
Invalid `prisma.user.findUniqueOrThrow()` invocation in
/Users/dar0/projects/prisma-demo/seed.ts:15:23

  12 // });
  13 
  14 names.forEach(async (id) => {
→ 15   await prisma.user.findUniqueOrThrow(
Failed to validate the query: `Field does not exist on enclosing type.` at `Query.findManyUserOrThrow`
    at RequestHandler.handleRequestError (/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:34843:13)
    at RequestHandler.handleAndLogRequestError (/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:34815:12)
    at RequestHandler.request (/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:34810:12)
    at async PrismaClient._request (/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:35900:16)
    at async /Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:34034:20
    at async /Users/dar0/projects/prisma-demo/seed.ts:15:5 {
  code: 'P2009',
  clientVersion: '4.7.0',
  meta: {
    query_validation_error: 'Field does not exist on enclosing type.',
    query_position: 'Query.findManyUserOrThrow'
  },
  batchRequestIdx: undefined
}

How to reproduce

Run my code

Expected behavior

No response

Prisma information

generator client {
    provider = "prisma-client-js"
}

datasource db {
    provider = "postgresql"
    url      = "postgres://postgres:root@localhost:5432/bug-demo"
}

model User {
    id   String @id @default(uuid())
    name String @unique
}
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

async function main() {
  const names = Array(100)
    .fill(0)
    .map((_, i) => `Number ${i}`);

  // Run this on first run to seed the database
  // await prisma.user.createMany({
  //   data: names.map((i) => ({ name: i })),
  // });

  names.forEach(async (id) => {
    await prisma.user.findUniqueOrThrow({
      where: {
        name: id,
      },
    });
  });
}

main();

Environment & setup

  • OS: macOS, AWS linux AMI
  • Database: psql
  • Node.js version: v16.15.0

Prisma Version

4.6.1 / 4.7.0
@DarioSiroki DarioSiroki added the kind/bug A reported bug. label Nov 30, 2022
@SevInf SevInf added kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. topic: batching and removed kind/bug A reported bug. labels Nov 30, 2022
@miguelff
Copy link
Contributor

miguelff commented Nov 30, 2022

There's indeed a bug in the way findUniqueOrThrow is being batched. We identified the root cause, and we are working towards resolution in prisma/prisma-engines#3458

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. topic: batching
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants