MrLeebo / prisma-ast

Abstract Syntax Tree for parsing schema.prisma files
MIT License
140 stars 18 forks source link

Support for @map on enum fields #41

Closed canadaduane closed 5 months ago

canadaduane commented 5 months ago

An enum field can have a @map attribute that defines an explicit value:

https://www.prisma.io/docs/orm/prisma-schema/data-model/database-mapping#map-enum-names-and-values

For example:

enum GradeLevel {
  KINDERGARTEN   @map("kindergarten")
  FIRST          @map("first")
  SECOND         @map("second")
  THIRD          @map("third")
  FOURTH         @map("fourth")
  FIFTH          @map("fifth")
  SIXTH          @map("sixth")
  SEVENTH        @map("seventh")
  EIGHTH         @map("eighth")
  NINTH          @map("ninth")
  TENTH          @map("tenth")
  ELEVENTH       @map("eleventh")
  TWELFTH        @map("twelfth")
  THIRTEEN       @map("thirteen")
  POST_SECONDARY @map("post_secondary")
  OTHER          @map("other")
}

Could this be included?

MrLeebo commented 5 months ago

@canadaduane I have added parsing rules for attributes to enums and have published v0.12.0 with the new feature. Please check it out and verify that it works for you

canadaduane commented 5 months ago

Looks great, thank you!