Skip to content

Instantly share code, notes, and snippets.

@Abrifq
Created January 28, 2022 23:05
Show Gist options
  • Save Abrifq/b6646e3348871175870b5122a4002223 to your computer and use it in GitHub Desktop.
Save Abrifq/b6646e3348871175870b5122a4002223 to your computer and use it in GitHub Desktop.
Prisma bug occuring on one-to-one relationships

Command:

DEBUG="*" prisma format --schema="./schema.prisma"
# Edited schema path to upload as a gist

Output:

  prisma:loadEnv project root found at /tmp/package.json +0ms
  prisma:tryLoadEnv Environment variables loaded from /tmp/.env +0ms
Environment variables loaded from .env
  prisma:engines binaries to download libquery-engine, migration-engine, introspection-engine, prisma-fmt +0ms
Prisma schema loaded from prisma/schema.prisma
  prisma:getDMMF Using CLI Query Engine (Node-API) at: /usr/lib/node_modules/prisma/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node +0ms
Error: Error: Schema parsing
error: Error parsing attribute "@relation": The relation fields `Description` on Model `Tester` and `Tester` on Model `TesterDescription` both provide the `references` argument in the @relation attribute. You have to provide it only on one of the two fields.
  -->  schema.prisma:18
   | 
17 |   Ingredients               TesterIngredients[]
18 |   Description               TesterDescription   @relation(fields: [testerDescriptionTesterID], references: [TesterID])
19 |   testerDescriptionTesterID String              @db.Uuid
   | 
error: Error parsing attribute "@relation": The relation fields `Description` on Model `Tester` and `Tester` on Model `TesterDescription` both provide the `references` argument in the @relation attribute. You have to provide it only on one of the two fields.
  -->  schema.prisma:44
   | 
43 | 
44 |   Tester Tester @relation(fields: [TesterID], references: [TesterID])
45 | }
   | 
error: Error parsing attribute "@relation": The relation fields `Description` on Model `Tester` and `Tester` on Model `TesterDescription` both provide the `fields` argument in the @relation attribute. You have to provide it only on one of the two fields.
  -->  schema.prisma:18
   | 
17 |   Ingredients               TesterIngredients[]
18 |   Description               TesterDescription   @relation(fields: [testerDescriptionTesterID], references: [TesterID])
19 |   testerDescriptionTesterID String              @db.Uuid
   | 
error: Error parsing attribute "@relation": The relation fields `Description` on Model `Tester` and `Tester` on Model `TesterDescription` both provide the `fields` argument in the @relation attribute. You have to provide it only on one of the two fields.
  -->  schema.prisma:44
   | 
43 | 
44 |   Tester Tester @relation(fields: [TesterID], references: [TesterID])
45 | }
   | 
error: Error parsing attribute "@relation": The relation fields `Description` on Model `Ingredient` and `Ingredient` on Model `IngredientDescription` both provide the `references` argument in the @relation attribute. You have to provide it only on one of the two fields.
  -->  schema.prisma:27
   | 
26 |   UsedIn                            TesterIngredients[]
27 |   Description                       IngredientDescription @relation(fields: [ingredientDescriptionIngredientID], references: [IngredientID])
28 |   ingredientDescriptionIngredientID String                @db.Uuid
   | 
error: Error parsing attribute "@relation": The relation fields `Description` on Model `Ingredient` and `Ingredient` on Model `IngredientDescription` both provide the `references` argument in the @relation attribute. You have to provide it only on one of the two fields.
  -->  schema.prisma:36
   | 
35 | 
36 |   Ingredient Ingredient @relation(fields: [IngredientID], references: [IngredientID])
37 | }
   | 
error: Error parsing attribute "@relation": The relation fields `Description` on Model `Ingredient` and `Ingredient` on Model `IngredientDescription` both provide the `fields` argument in the @relation attribute. You have to provide it only on one of the two fields.
  -->  schema.prisma:27
   | 
26 |   UsedIn                            TesterIngredients[]
27 |   Description                       IngredientDescription @relation(fields: [ingredientDescriptionIngredientID], references: [IngredientID])
28 |   ingredientDescriptionIngredientID String                @db.Uuid
   | 
error: Error parsing attribute "@relation": The relation fields `Description` on Model `Ingredient` and `Ingredient` on Model `IngredientDescription` both provide the `fields` argument in the @relation attribute. You have to provide it only on one of the two fields.
  -->  schema.prisma:36
   | 
35 | 
36 |   Ingredient Ingredient @relation(fields: [IngredientID], references: [IngredientID])
37 | }
   | 

Validation Error Count: 8
    at getDmmfNodeAPI (/usr/lib/node_modules/prisma/build/index.js:37108:15)
    at async getDMMF (/usr/lib/node_modules/prisma/build/index.js:37085:17)
    at async Object.parse (/usr/lib/node_modules/prisma/build/index.js:104929:5)
    at async main (/usr/lib/node_modules/prisma/build/index.js:106144:18)
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Tester {
TesterID String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
Name String @db.Text
Ingredients TesterIngredients[]
Description TesterDescription
}
model Ingredient {
IngredientID String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
IngredientName String @db.Text
UsedIn TesterIngredients[]
Description IngredientDescription
}
model IngredientDescription {
IngredientID String @id @db.Uuid
Description String @db.Text
ImagePath String? @db.Text
Ingredient Ingredient @relation(fields:[IngredientID],references:[IngredientID])
}
model TesterDescription {
TesterID String @db.Uuid @id
Description String @db.Text
ImagePath String? @db.Text
Tester Tester @relation(fields:[TesterID],references:[TesterID])
}
model TesterIngredients {
TesterID String @db.Uuid
IngredientID String @db.Uuid
@@id([TesterID,IngredientID])
Tester Tester @relation(fields:[TesterID],references:[TesterID])
Ingredient Ingredient @relation(fields:[IngredientID],references:[IngredientID])
}

Node Version

v17.4.0

Npm Version

8.3.1

Prisma Version

prisma                  : 3.8.1
@prisma/client          : 3.8.1
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at ../usr/lib/node_modules/prisma/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at ../usr/lib/node_modules/prisma/node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at ../usr/lib/node_modules/prisma/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at ../usr/lib/node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f
Studio                  : 0.452.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment