Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Lift "duplicate column name:" #28

Closed
Bjoernstjerne opened this issue Jun 27, 2019 · 3 comments
Closed

Lift "duplicate column name:" #28

Bjoernstjerne opened this issue Jun 27, 2019 · 3 comments
Assignees
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug.
Milestone

Comments

@Bjoernstjerne
Copy link

I tried to reference one model two times. This leads to not correct named fields.

tested with prisma2@0.0.99

extended hello-prisma schema:

datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
  default  = true
}

generator photon {
  provider = "photonjs"
  output   = "node_modules/@generated/photon"
}

generator nexus_prisma {
  provider = "nexus-prisma"
  output   = "node_modules/@generated/nexus-prisma"
}

model User {
  id      String  @default(cuid()) @id @unique
  email   String  @unique
  name    String?
  posts   Post[]
  visited Visit[] @relation(name: "visited")
  visitors Visit[] @relation(name: "visitor")
}

model Post {
  id        String   @default(cuid()) @id @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  published Boolean
  title     String
  content   String?
  author    User?
}

model Visit {
  id      Int  @id
  self    User @relation(name: "visited")
  visitor User @relation(name: "visitor")
}

Lift save created this SQL:

CREATE TABLE "file:dev"."Visit"("id" INTEGER NOT NULL DEFAULT 0 ,"self" TEXT NOT NULL  REFERENCES User(id),"self" TEXT NOT NULL  REFERENCES User(id),PRIMARY KEY ("id"));
@matthewmueller matthewmueller transferred this issue from another repository Jun 27, 2019
@matthewmueller matthewmueller added bug/1-repro-available A reproduction exists and needs to be confirmed. team/engineering labels Jun 27, 2019
@timsuchanek timsuchanek added the kind/bug A reported bug. label Jul 2, 2019
@Bjoernstjerne
Copy link
Author

Bjoernstjerne commented Jul 2, 2019

I saw that in my project this works on another model so I tried to change some things:

for the example this works

datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
  default  = true
}

generator photon {
  provider = "photonjs"
  output   = "node_modules/@generated/photon"
}

generator nexus_prisma {
  provider = "nexus-prisma"
  output   = "node_modules/@generated/nexus-prisma"
}

model User {
  id      String  @default(cuid()) @id @unique
  email   String  @unique
  name    String?
  posts   Post[]
  visited Visit[] @relation(name: "visited")
  visitor Visit[] @relation(name: "visitor")
}

model Post {
  id        String   @default(cuid()) @id @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  published Boolean
  title     String
  content   String?
  author    User?
}

model Visit {
  id      Int  @id
  visited User @relation(name: "visited")
  visitor User @relation(name: "visitor")
}

Changes:

  • remove the s from visitors
  • rename self to visited

the related fields must have the same name in both models.

@pantharshit00 pantharshit00 added bug/2-confirmed We have confirmed that this is a bug. and removed bug/1-repro-available A reproduction exists and needs to be confirmed. labels Jul 15, 2019
@pantharshit00
Copy link
Contributor

I can confirm this. Related: https://github.com/prisma/photonjs/issues/131

@mavilein
Copy link
Member

mavilein commented Aug 5, 2019

A fix for this is available on alpha.

@mavilein mavilein closed this as completed Aug 5, 2019
@janpio janpio added this to the Preview 6 milestone Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

6 participants