Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation: default values on enum fields should be valid for the enum #959

Closed
tomhoule opened this issue Jul 27, 2020 · 0 comments · Fixed by #979
Closed

Validation: default values on enum fields should be valid for the enum #959

tomhoule opened this issue Jul 27, 2020 · 0 comments · Fixed by #979
Assignees
Labels
tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema tech/engines Issue for tech Engines.

Comments

@tomhoule
Copy link
Contributor

The following schema currently (2.3.0) passes validation:

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

datasource db {
  provider = "postgresql"
  url      = "postgresql://postgres:prisma@localhost:5432/testdb"
}

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

model Cat {
  id    Int     @id
  meows Boolean @default(true)
  mood  CatMood @default(HANGRY)
}

enum CatMood {
  ANGRY
  HUNGRY
}

We do not validate that the @default() expression on the Cat.mood field is a variant of the CatMood enum. I think we could and should validate this.

@janpio janpio added tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema and removed engines/data model parser labels Jul 27, 2020
@mavilein mavilein added the tech/engines Issue for tech Engines. label Aug 5, 2020
@janpio janpio added this to the Backlog 2.5.0 milestone Aug 5, 2020
@do4gr do4gr closed this as completed in #979 Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema tech/engines Issue for tech Engines.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants