question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No validation error on 1:m ambiguous relation

See original GitHub issue

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v10.20.1
OS darwin
Prisma 2.5.1

Logs

  prisma-client { engineConfig:
  prisma-client    { cwd: '/Users/user/project/prisma',
  prisma-client      enableDebugLogs: false,
  prisma-client      enableEngineDebugMode: undefined,
  prisma-client      datamodelPath:
  prisma-client       '/Users/project/node_modules/.prisma/client/schema.prisma',
  prisma-client      prismaPath: undefined,
  prisma-client      engineEndpoint: undefined,
  prisma-client      generator:
  prisma-client       { name: 'client',
  prisma-client         provider: 'prisma-client-js',
  prisma-client         output:
  prisma-client          '/Users/project/node_modules/@prisma/client',
  prisma-client         binaryTargets: [],
  prisma-client         previewFeatures: [],
  prisma-client         config: {} },
  prisma-client      showColors: false,
  prisma-client      logLevel: 'info',
  prisma-client      logQueries: true,
  prisma-client      flags: [],
  prisma-client      clientVersion: '2.5.1',
  prisma-client      enableExperimental: [],
  prisma-client      useUds: undefined } }  
  plusX Execution permissions of /Users/project/artemis/node_modules/.prisma/client/query-engine-darwin are fine  
  prisma-client Client Version 2.5.1  +29s
  prisma-client Engine Version 9a670138b1db276001d785a2adcba1584c869d24  

Prisma.schema

model AuthorBook {
  authorId            Int  
  booksId            String

  author         Author @relation(fields: [authorId], references: [id])
  books          Book  @relation(fields: [bookId], references: [id])

  @@id([authorId, bookId])
  @@map("author_book")
}
model Author {
  id            Int  
  name            String

  books       Book[]

  @@map("author")
}
model Book {
  id            Int  
  title            String
  description    String

  authors       Author[]

  @@map("book")
}

TS file

const books = await prisma.authorBook.findMany({
        where: {
          authorId: `${author.id}`,
        },
        include: {
          book: true,
        },
      });

The above is an abstracted example of how I’m trying to call this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
pantharshit00commented, Jan 22, 2021

Looks like query engine doesn’t panic with the schema in latest version anymore.

But migrate now tries to add two foreign keys with above schema:

CREATE TABLE "codes" (
    "id" TEXT NOT NULL,
    "type" TEXT NOT NULL,
    "singleUse" BOOLEAN NOT NULL,
    "userId" TEXT,
    "createdById" TEXT,
    "userId" TEXT,

    PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "users" (
    "id" TEXT NOT NULL,
    "name" TEXT,

    PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "codes" ADD FOREIGN KEY ("userId", "userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "codes" ADD FOREIGN KEY ("userId", "userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

So moving this to the migrate team now.

0reactions
do4grcommented, Feb 25, 2021

This should be solved by us splitting the parsing and formatting step here https://github.com/prisma/prisma-engines/pull/1662

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma throwing error: Ambiguous relation detected
I'm using prisma and trying to model a referral table for my Postgres database. Not sure if the db ...
Read more >
Column 'id' in field list is ambiguous select2 edit mode
Hi, i have a problem to take data from relationship belongstomany, i try take data when i edit post and i have this...
Read more >
Ambiguous About Ambiguity?: How to help your team deal ...
7 Ways to Help Your Team Deal with Ambiguity "Accepting that the world is full of uncertainty and ambiguity does not and should...
Read more >
I'm two weeks into no contact and my ex text a ... - Quora
Although it is a bit ambiguous, I would say no. If your ex had any kind of relationship with your daughter, she may...
Read more >
Attitudes Toward and Perceptions of the Ambiguity of House ...
conference, MEA conference and AREUEA-ASSA conference, All errors are our own. ... Ambiguity describes the situations where the odds of each outcome are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found