Support for prisma `enum`?
Closed this issue · 4 comments
canadaduane commented
We have several enum
declarations in our schema.prisma file, e.g.:
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")
}
However, when running prisma-lint I see the following syntax error:
MismatchedTokenException: Expecting --> '}' <-- but found --> '@' <--
at RecognizerEngine.consumeInternalError (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/chevrotain@10.5.0/node_modules/chevrotain/lib/src/parse/parser/traits/recognizer_engine.js:500:31)
at RecognizerEngine.consumeInternal (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/chevrotain@10.5.0/node_modules/chevrotain/lib/src/parse/parser/traits/recognizer_engine.js:475:22)
at RecognizerApi.CONSUME (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/chevrotain@10.5.0/node_modules/chevrotain/lib/src/parse/parser/traits/recognizer_api.js:47:21)
at PrismaParser.<anonymous> (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/@mrleebo+prisma-ast@0.11.0/node_modules/@mrleebo/prisma-ast/dist/prisma-ast.cjs.development.js:475:13)
at PrismaParser.invokeRuleWithTry [as block] (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/chevrotain@10.5.0/node_modules/chevrotain/lib/src/parse/parser/traits/recognizer_engine.js:133:26)
at RecognizerEngine.subruleInternal (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/chevrotain@10.5.0/node_modules/chevrotain/lib/src/parse/parser/traits/recognizer_engine.js:447:37)
at RecognizerApi.SUBRULE (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/chevrotain@10.5.0/node_modules/chevrotain/lib/src/parse/parser/traits/recognizer_api.js:77:21)
at PrismaParser.<anonymous> (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/@mrleebo+prisma-ast@0.11.0/node_modules/@mrleebo/prisma-ast/dist/prisma-ast.cjs.development.js:620:13)
at PrismaParser.invokeRuleWithTry [as component] (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/chevrotain@10.5.0/node_modules/chevrotain/lib/src/parse/parser/traits/recognizer_engine.js:133:26)
at RecognizerEngine.subruleInternal (/Users/duane/schoolai/Coteacher/node_modules/.pnpm/chevrotain@10.5.0/node_modules/chevrotain/lib/src/parse/parser/traits/recognizer_engine.js:447:37) {
token: {
image: '@',
startOffset: 35,
endOffset: 35,
startLine: 2,
endLine: 2,
startColumn: 18,
endColumn: 18,
tokenTypeIdx: 18,
tokenType: {
name: 'FieldAttribute',
PATTERN: /@/,
CATEGORIES: [Array],
tokenTypeIdx: 18,
categoryMatches: [],
categoryMatchesMap: {},
isParent: false,
LABEL: "'@'"
}
},
resyncedTokens: [],
previousToken: {
image: 'KINDERGARTEN',
startOffset: 20,
endOffset: 31,
startLine: 2,
endLine: 2,
startColumn: 3,
endColumn: 14,
tokenTypeIdx: 3,
tokenType: {
name: 'Identifier',
PATTERN: /[a-zA-Z][\w-]*/,
tokenTypeIdx: 3,
CATEGORIES: [],
categoryMatches: [],
categoryMatchesMap: {},
isParent: false
}
},
context: {
ruleStack: [ 'schema', 'component', 'block' ],
ruleOccurrenceStack: [ 0, 0, 0 ]
}
}
Is the @map
syntax not supported in enum
, perhaps?
canadaduane commented
I've added a request to support this new-ish syntax here: MrLeebo/prisma-ast#41
maxh commented
Perfect, once that library supports it we can upgrade.
canadaduane commented
They were remarkably quick in implementing! Can we bump the dependency version?
canadaduane commented
Thank you!