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

Issue with UK enum value #238

Open
guydunton opened this issue Oct 4, 2023 · 3 comments
Open

Issue with UK enum value #238

guydunton opened this issue Oct 4, 2023 · 3 comments

Comments

@guydunton
Copy link

I've found an issue with generation when an enum contains the value UK. e.g.

enum DeploymentRegions {
  EU
  UK
}

I get an error which looks like:

Command failed: "/Users/test/Documents/dev/api/node_modules/.bin/mmdc" -i "/var/folders/ky/5jpl226x1671bz_34h02wwg40000gn/T/prisma-erd-EtD1ko/prisma.mmd" -o "/Users/test/Documents/dev/api/prisma/ERD.svg" -c "/var/folders/ky/5jpl226x1671bz_34h02wwg40000gn/T/prisma-erd-EtD1ko/config.json" -p "/var/folders/ky/5jpl226x1671bz_34h02wwg40000gn/T/prisma-erd-EtD1ko/puppeteerConfig.json"

Running the command I get:

Error: Evaluation failed: Error: Parse error on line 28:
...     EU EUAP APUK UKNA NALA LAME ME
---------------------^
Expecting 'BLOCK_STOP', 'ATTRIBUTE_WORD', 'COMMA', 'COMMENT', got 'ATTRIBUTE_KEY'
    at aA.parseError (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/dist/index.html:226:13183)
    at aA.parse (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/dist/index.html:228:179)
    at HUe.parser.parse (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/dist/index.html:81:260)
    at HUe.parse (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/dist/index.html:81:498)
    at new HUe (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/dist/index.html:81:339)
    at yjA (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/dist/index.html:81:804)
    at async Object.jDt [as render] (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/dist/index.html:88:574)
    at ExecutionContext._ExecutionContext_evaluate (file:///Users/test/Documents/dev/api/node_modules/puppeteer-core/lib/esm/puppeteer/common/ExecutionContext.js:254:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ExecutionContext.evaluate (file:///Users/test/Documents/dev/api/node_modules/puppeteer-core/lib/esm/puppeteer/common/ExecutionContext.js:143:16)
    at async CDPJSHandle.evaluate (file:///Users/test/Documents/dev/api/node_modules/puppeteer-core/lib/esm/puppeteer/common/JSHandle.js:56:16)
    at async CDPElementHandle.$eval (file:///Users/test/Documents/dev/api/node_modules/puppeteer-core/lib/esm/puppeteer/common/ElementHandle.js:86:24)
    at async renderMermaid (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/src/index.js:246:22)
    at async parseMMD (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/src/index.js:218:20)
    at async run (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/src/index.js:479:20)
    at async cli (file:///Users/test/Documents/dev/api/node_modules/@mermaid-js/mermaid-cli/src/index.js:184:3)

It looks to be related to mermaids using UK to indicate unique key (link).

We've gotten around it by disabling enum generation but a fix would be nice, either by escaping the value in the .mmd file (I couldn't see if this was possible) or by moving away from mermaids (as a fix to #102)

@keonik
Copy link
Owner

keonik commented Oct 4, 2023

Most of the time its a mermaid thing. I'll see if I haven't wrapped enums in quotes already. That's typically the route to get around some mermaid specifics.

@keonik
Copy link
Owner

keonik commented Oct 17, 2023

Gave it a shot and it looks like the enums were not wrapped in quotes already. When I wrote out a schema

generator erd {
  provider = "node ./dist/index.js"
  output   = "../../__tests__/238.png"
}

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

model Deployment {
  id        String   @id @default(uuid()) @db.Uuid
    region DeploymentRegions
}

enum DeploymentRegions {
  EU
  UK
}

and ran locally with the quotes I was still getting an error. As it turns out the enums are not something you can wrap in quotes. All cases started to fail afterwards that used enums. I did get the above to pass by switching UK to anything else so it might be a reserved word for mermaid.

@keonik
Copy link
Owner

keonik commented Oct 17, 2023

What could be done is

  • Disabling enums in the output
generator erd {
  ...
  ignoreEnums = true
}
  • Asking maintainer to overwrite UK to U_K or something of that variety

What are your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants