question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better error message when Enum Error Due To "Connector"

See original GitHub issue

See https://github.com/prisma/prisma/issues/3449#issuecomment-690278707 for current issue content.

Bug description

I started a fresh Blitz.js project recently with Prisma as the DB ORM. In playing with setting up my schemas I tried to use an enum and received the following error back when using enums with Postgres and MySQL:

error: Error validating: You defined the enum `ImageTypes`. But the current connector does not support enums.

Others report it as working, so I wonder if this is an issue with something in my specific setup or a deeper bug. @janpio mentioned to me on the Blitz.js Slack to drop an issue to go over this issue.

How to reproduce

Create a new Blitz.js project, add a new model using their generator which adds to the Prisma schema as expected. Then add an enum definition and you can either try to use it or just have it there.

Expected behavior

An enum is generated in the DB for use between it and the application.

Prisma information

...

model Image {
  id        Int      @default(autoincrement()) @id
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  url       String   
  type      ImageTypes @default(STEP)
  user      User     @relation(fields: [userId], references: [id])
  userId    Int      
}

enum ImageTypes {
  AVATAR
  STEP
  HEADER
}

Environment & setup

  • OS: Pop_OS 20.04 (Ubuntu 20.04)
  • Database: MySQL 8, Postgres 13 (via Docker)
  • Node.js version: 14.8.0
  • Prisma version: 2.5.1
@prisma/cli          : 2.5.1
Current platform     : debian-openssl-1.1.x
Query Engine         : query-engine c88925ce44a9b89b4351aec85ba6a28979d2658e (at node_modules/@prisma/cli/query-engine-debian-openssl-1.1.x)
Migration Engine     : migration-engine-cli c88925ce44a9b89b4351aec85ba6a28979d2658e (at node_modules/@prisma/cli/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core c88925ce44a9b89b4351aec85ba6a28979d2658e (at node_modules/@prisma/cli/introspection-engine-debian-openssl-1.1.x)
Format Binary        : prisma-fmt c88925ce44a9b89b4351aec85ba6a28979d2658e (at node_modules/@prisma/cli/prisma-fmt-debian-openssl-1.1.x)
Studio               : 0.261.0

I will feel really dumb if this is a syntax thing, but I think I have it correct.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
janpiocommented, Sep 10, 2020

Let’s reopen this as a problem in the error message then:

error: Error validating: You defined the enum `ImageTypes`. But the current connector does not support enums.

This should probably better be something along the lines of

error: Error validating: You defined the enum `ImageTypes`. But the provider `sqlite` you are using does not support enums.

(Problem 1: connector is not a user level concept. Problem 2: It does not list the limiting provider/connector)

2reactions
firraecommented, Sep 1, 2020

Sorry for the delay in response. Work has been very hectic for me so I haven’t had a chance to try this again after you tested it. There was also an update to Blitz so maybe after updating the whole stack something will click into place. I will test this weekend and see if I can recreate it in a minimal example repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom error message on enum field upon failed validation in ...
Thanks to the comments, I found a solution by using isAssignableFrom() to provide custom error messages for the failed enum validation:
Read more >
Rust: Enums to wrap multiple errors - fettblog.eu
To use this enum as an error, we need to implement the std:error::Error trait for it.
Read more >
ERROR (ENUM) - Schneider Electric
Name Initial Comment PARTIAL_TRANSFER 16#6 Only part of the expected data was transferred. CONNECTION_LOST 16#7 The messaging connection was lost. INVALID_ATTRIBUTE_VALUE 16#9 Invalid attribute data detected....
Read more >
MySQL 8.0 Reference Manual :: 11.3.5 The ENUM Type
If strict SQL mode is enabled, attempts to insert invalid ENUM values result in an error. If an ENUM column is declared to...
Read more >
Swift Error Handling (With Examples) - Programiz
The enum we create must conform to the Error protocol so that we can throw an error value inside the function. Let's see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found