Prisma-client-js: UUID joins not working after 0.20 upgrade

Created on 24 Jan 2020  Â·  14Comments  Â·  Source: prisma/prisma-client-js

includes and selects have stopped working after i upgraded to the 0.20

[email protected], binary version: 45dd3493ff2fd09b5a8cdf697de276e368f7ebee
db: postgres 11.5

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

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

model Event {
  id          String          @id @default(uuid())
  title       String?
  rawTitle    String          @unique
  createdAt   DateTime?       @default(now())
  updatedAt   DateTime?       @default(now())
  startDate   DateTime?       @default(now())
  endDate     DateTime?       @default(now())
  poster      EventPosters[]
  ticketUrl   String?
  url         String?
  facebook    String?
  description String?
  instagram   String?
  twitter     String?
  lineup      Lineup[]
  tags        EventTag[]
  schedule    EventSchedule[]
  venue       Venue?
  userCreated Boolean         @default(false)
}

model EventPosters {
  id        String    @id @default(uuid())
  createdAt DateTime? @default(now())
  url       String    @unique
  type      String
  event     Event
}

model EventTag {
  id   String @id @default(uuid())
  name String
}

model EventSchedule {
  id        String    @id @default(uuid())
  date      DateTime?
  event     Event
  startTime DateTime?
  endTime   DateTime?
  lineup    Artist[]
}

model Lineup {
  id     String @id @default(uuid())
  event  Event
  pos    Int
  artist Artist
  // @@unique([event, artist])
}

model Artist {
  id             String          @id @default(uuid())
  name           String
  musicServiceId String?
  raw            String          @unique
  lineup         Lineup[]
  schedule       EventSchedule[]
}

model Organizer {
  id    String  @id @default(uuid())
  name  String  @unique
  phone String
  email String
  event Event[]
}

model Venue {
  id      String  @id @default(uuid())
  name    String
  rawName String  @unique
  address String?
  country String?
  zip     String?
  city    String?
  url     String?
  region  String?
  event   Event[]
}
const { PrismaClient } = require('@prisma/client')

const prisma = new PrismaClient()

const eventId = 'cc3c6af4-26af-4132-a39a-af406e466e0b'
const start = async () => {
  try {
    const item = await prisma.events.findMany({
      include: { lineup: true },
    })
    console.log('item', item)
    const lineup = await prisma.lineups.findMany({
      where: { event: { id: eventId } },
      select: { pos: true, artist: true },
      orderBy: { pos: 'asc' },
    })
    console.log('item', lineup)
    // const posters = await item.poster()

    // console.log(lineup)
    await prisma.disconnect()
  } catch (e) {
    console.log('e', e)
  }

  // process.exit()
}

start()

0.20

item [
  {
    id: 'cc3c6af4-26af-4132-a39a-af406e466e0b',
    title: 'hijinx 2019',
    rawTitle: 'hijinx2019',
    createdAt: 2020-01-24T09:41:17.683Z,
    updatedAt: 2020-01-24T09:41:17.683Z,
    startDate: 2019-12-27T11:00:00.000Z,
    endDate: 2020-01-24T09:41:17.687Z,
    ticketUrl: null,
    url: 'hijinxfest.com',
    facebook: null,
    description: null,
    instagram: null,
    twitter: null,
    userCreated: true,
    lineup: []
  }
]
Invalid `lineup = await prisma.lineups.findMany()` invocation in
dbtest.js:12:41

   8 const item = await prisma.events.findMany({
   9   include: { lineup: true },
  10 })
  11 console.log('item', item)
→ 12 const lineup = await prisma.lineups.findMany(

Engine exited {"target":"exit","timestamp":"2020-01-24T11:20:58.170Z","level":"error","fields":{"message":"255"}}
    at PrismaClientFetcher.request (/node_modules/@prisma/client/index.js:62:23)

0.19

item [
  {
    id: 'cc3c6af4-26af-4132-a39a-af406e466e0b',
    title: null,
    rawTitle: 'hijinx2019',
    createdAt: null,
    updatedAt: null,
    startDate: null,
    endDate: null,
    ticketUrl: null,
    url: null,
    facebook: null,
    description: null,
    instagram: null,
    twitter: null,
    userCreated: true,
    lineup: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object]
    ]
  }
]

lineup : [
   ...bunch of results, not really relevant
]
bu2-confirmed kinregression

Most helpful comment

Thanks for the information everyone.
First of all, we didn't return a proper error, that's now fixed in the latest alpha.

It turns out, that the problem is related to UUID.
A simple intermediate fix for you can be to change the id column default from @id @default(uuid()) to @id @default(cuid()).

We'll update this next week once we have a fix for this.

All 14 comments

Could you try doing npx prisma2@alpha generate and remove the pluralization ie prisma.events.findMany -> prisma.event.findMany
prisma.lineups.findMany -> prisma.lineup.findMany

The pluralization was removed in alpha

No i get Cannot read property 'findMany' of undefined

i get plurals in my types definition
"version": "2.0.0-alpha.637",

    get events(): EventDelegate;
    get eventPosters(): EventPostersDelegate;
    get eventTags(): EventTagDelegate;
    get eventSchedules(): EventScheduleDelegate;
    get lineups(): LineupDelegate;
    get artists(): ArtistDelegate;
    get organizers(): OrganizerDelegate;
    get venues(): VenueDelegate;

@pantharshit00 I tried to reproduce this, but couldn't with Postgres 10.7.
Please try it out with Postgres 11.5.

ok i am able to remove the pluralization with npx but the outcome is still the same as above.

steps taken.

  • removed all global instances of prisma2
  • truncated _Migration table
  • ran yarn add @prisma/client@alpha
  • ran npx prisma2@alpha migrate save --experimental --name init && npx prisma2@alpha migrate up --experimental && npx prisma2@alpha generate
  • run the test file and get the same results as above
    const item = await prisma.event.findMany({
      include: { lineup: true },
    })
   console.log('item', item)
  • copied out the entire folder and ran in isolation with introspection and only with npm instead of yarn.

bonus, found that its probably a good idea to add nohoist to mono repo package.json, might be worth to mention somewhere if it isnt

  "workspaces": {
    "packages": [
      "services/*"
    ],
    "nohoist": [
      "**/@prisma",
      "**/@prisma/**"
    ]
  },

how else can i roll anything back?

I'm experiencing the same issue tried on preview020.3 and on latest alpha doesn't fetch anything. Debug shows that it making request with query engine and it just returns null

I can reproduce this. This is actually a duplicate of https://github.com/prisma/prisma-client-js/issues/430.

Since this has more context now, I am going to close the other issue.

Ready to go reproduction here: https://github.com/harshit-test-org/prisma2-client-430

Any ETA on this one?

Thanks for the information everyone.
First of all, we didn't return a proper error, that's now fixed in the latest alpha.

It turns out, that the problem is related to UUID.
A simple intermediate fix for you can be to change the id column default from @id @default(uuid()) to @id @default(cuid()).

We'll update this next week once we have a fix for this.

@timsuchanek Oh, make sense because I use UUID everywhere...

Update: Changing the id type to UUID will not fix the current data, but only new data that will be fixed. That means you would have to clean up your existing data.
So you might just wait for the fix next week.

I tested this on the latest alpha and this is fixed now. I used this version:
[email protected], binary version: 7a3d094948ee1fa2553d41214721e615e1ef92eb

@jaywalklabs @impowski Can you please test with the current alpha and confirm?

@janpio @mavilein unable to test it for now because alpha.754 doesn't work with [email protected] for some reason.

I can also no longer reproduce this with [email protected], binary version: 7a3d094948ee1fa2553d41214721e615e1ef92eb

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrmntte picture mrmntte  Â·  3Comments

samrith-s picture samrith-s  Â·  3Comments

divyenduz picture divyenduz  Â·  3Comments

maartenraes picture maartenraes  Â·  4Comments

julien1619 picture julien1619  Â·  3Comments