prismix icon indicating copy to clipboard operation
prismix copied to clipboard

Attribute not known @db.VarChar

Open webnoob opened this issue 4 years ago • 4 comments
trafficstars

It appears that support for specific DB types isn't supported.

I'm merging:

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

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["orderByAggregateGroup", "selectRelationCount"]
}

model Company {
  id            Int           @id @default(autoincrement())
  createdDate   DateTime      @default(now())
  updatedDate   DateTime?
  name          String
}

with:

model JobGroup {
  id          Int     @id @default(autoincrement())
  createdDate DateTime  @default(now())
  updatedDate DateTime?

  company Company   @relation(fields: [companyId], references: [id])
  companyId Int

  user   User @relation(fields: [userId], references: [id])
  userId Int

  name    String  @db.VarChar(255)
  default Boolean @default(false)

  color String? @db.VarChar(30)
}

model Company {
  id            Int           @id @default(autoincrement())
}

model User {
  id            Int           @id @default(autoincrement())
}

It's valid prisma.schema syntax.

Are there any plans to support this?

webnoob avatar Aug 27 '21 13:08 webnoob

Hey after looking into this i believe this has nothing to do with Prismix and seems to be an issue with the prisma SDK image

The error is thrown by like 36 on the above image in this file which is a function provided by the prisma SDK.

But then again i've dug around the prisma code and they use the exact same function that we're calling 😢

sean-brydon avatar Sep 09 '21 08:09 sean-brydon

Ooof, a bug in prisma - what are the chances 😅

Are you planning on chasing this up with them or not? I need to know as I'll have to find another solution for multi file if you're not as it's a key part of my pluggable structure. I'm not in a rush, just need to know if it'll be sorted at some point.

webnoob avatar Sep 09 '21 15:09 webnoob

By all means I’ll take a look at it on our side as there has to be a reason why this works when prisma call this function but not when we call it…

Maybe @jamiepine had an idea why this is being serialised differently on our end

sean-brydon avatar Sep 09 '21 16:09 sean-brydon

I ran into this same issue. My solution was to include the datasource in every file that uses @db. types:

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

model JobGroup {

name    String  @db.VarChar(255)
// etc.
}

Given that the error with the missing datatype is coming from the prisma SDK itself, it probably won't be possible to fix within the context of prismix.

ddhorstman avatar Feb 15 '22 22:02 ddhorstman