Skip to content

Multi-line documentation comments generate invalid DBML with unescaped newlines #60

Open
@colmanhumphrey

Description

@colmanhumphrey

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions