prisma-dbml-generator icon indicating copy to clipboard operation
prisma-dbml-generator copied to clipboard

Multi-line documentation comments generate invalid DBML with unescaped newlines

Open colmanhumphrey opened this issue 10 months ago • 1 comments

When using Prisma's triple-slash (///) documentation comments that span multiple lines (e.g. for JSON examples), the generator creates DBML with unescaped newlines in string literals, producing invalid DBML syntax (at least https://dbdiagram.io/ can't parse them).

E.g.:

model Example {
  /// JSON structure example:
  /// {
  ///   "key": "value",
  ///   "nested": {
  ///     "data": "here"
  ///   }
  /// }
  data Json
}

We get something like:

Table Example {
  data Json [note: 'JSON structure example:
{
  "key": "value",
  "nested": {
    "data": "here"
  }
}']
}

I think we'd want something like this instead:

Table Example {
  data Json [note: 'JSON structure example:\n{\n  "key": "value",\n  "nested": {\n    "data": "here"\n  }\n}']
}

Could we do one of (or have the option of):

  • Escape newlines with \n
  • Convert multi-line comments to single-line
  • Omit multi-line comments from DBML output

Thanks for the package!

colmanhumphrey avatar Jan 16 '25 20:01 colmanhumphrey

It's the same case for model notes.

Prisma:

/// Multi-line
/// Comment
/// Does not
/// work
model Example {
  id Int @id
}

DBML:

Table Example {
  id Int [pk]

  Note: 'Multi-line
Comment
Does not
work'
}

erictuvesson avatar Jun 02 '25 06:06 erictuvesson