Prisma-client-js: Multi relations in query

Created on 6 Apr 2020  路  7Comments  路  Source: prisma/prisma-client-js

I would like it to create a poem with 4 accounts, unfortunately I have some mistake in every possible way.
I was cleaning the database.
I deleted migrations and created them again.
after uploading the schema and run "prisma introspect" disappear all relations with the schema.

Error

PANIC: assertion failed: index < len in

Please create an issue in https://github.com/prisma/prisma-client-js describing the last Prisma Client query you called

prisma SQL

prisma.options.create({
        data: {
          file:{
            create: {
              name: args.filename,
            },
          },
          Routes: {
            create: {
              index: args.routename,
            },
          },
          Car:{
            create: {
              carnumber: args.carnumber,
            },
          },
          Value:{
            create: {
              value: args.value,
            },
          },
        },
      }),

schema.prisma
```generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model Car {
id Int @default(autoincrement()) @id
carnumber Int @unique
createdAt DateTime? @default(now())
updatedAt DateTime? @default(now())
opts Options[]

}

model File {
id Int @default(autoincrement()) @id
name String @unique
createdAt DateTime? @default(now())
updatedAt DateTime? @default(now())
opts Options[]
}

model Routetovalue {
id Int @default(autoincrement()) @id
index String @unique
createdAt DateTime? @default(now())
updatedAt DateTime? @default(now())
opts Options[]
}

model Values {
id Int @default(autoincrement()) @id
value String @unique
createdAt DateTime? @default(now())
updatedAt DateTime? @default(now())
opts Options[]
}

model Options {
id Int @default(autoincrement()) @id
createdAt DateTime? @default(now())
updatedAt DateTime? @default(now())
routeName String?
Routes Routetovalue? @relation(fields: [routeName], references: [index])
fileName String?
file File? @relation(fields: [fileName], references: [name])
carnr Int?
Car Car? @relation(fields: [carnr], references: [carnumber])
val String?
Value Values? @relation(fields: [val], references: [value])
}


**package.json**

{
"name": "graphql-expres-API",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --exec babel-node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"@nexus/schema": "^0.13.1",
"@prisma/client": "^2.0.0-beta.1",
"@types/node-fetch": "^2.5.5",
"apollo-server": "^2.11.0",
"babel-cli": "^6.26.0",
"babel-preset-latest": "^6.24.1",
"fs": "0.0.1-security",
"graphql": "^14.6.0",
"nexus": "^0.12.0",
"nexus-prisma": "^0.12.0",
"pg": "^7.18.2"
},
"devDependencies": {
"@prisma/cli": "^2.0.0-beta.1",
"@types/node": "^13.11.0",
"eslint": "^6.8.0",
"eslint-config-google": "^0.14.0",
"ts-node": "^8.8.1",
"typescript": "^3.8.3"
},
"prettier": {
"singleQuote": true,
"semi": false,
"trailingComma": "all"
}
}

```

  • OS: Windows and Ubuntu
  • Database: PostgreSQL - REMOTE
  • Prisma version: 2.0.0-beta.2
  • Node.js version: 12.30.0
bu2-confirmed kinbug tecengines

All 7 comments

Reproduce

  1. download https://mega.nz/file/q8QjzCQD#S7oa80XoDxhsX7FCxOHe5qpk6QryCjh55bJ5Ph_SRdk
  2. unpack
  3. npx prisma migrate save --experimental
  4. npx prisma migrate up --experimental
  5. npx prisma generate
  6. npx prisma studio --experimental
  7. add option in studia or try prisma.option.create in resolvers.js

After upgrading to beta.2, the problem persists.
In Studio, however, I can add new row in 'options' now.

I've been having a lot of funky issues with multi-relations, but the issue that I mentioned this one in (above) brought me to the same error of panic.

In my case, creating the model that has the problem from the query errors this way, but nested within another query simply ignores its creation, but makes the nested creations.

I can reproduce this issue, here is a minimal reproduction: https://github.com/harshit-test-org/prisma-client-633

We will need to fix this.

I pinned the issue, however, it's fairly complicated. Will update the issue once a fix is available.

A fix is available on alpha-1141 onwards. Please validate that it works for you now.

A fix is available on alpha-1141 onwards. Please validate that it works for you now.

Yes, it's works! :D

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samrith-s picture samrith-s  路  3Comments

FluorescentHallucinogen picture FluorescentHallucinogen  路  3Comments

Vergil333 picture Vergil333  路  3Comments

divyenduz picture divyenduz  路  3Comments

julien1619 picture julien1619  路  3Comments