Skip to content

Commit 6ade511

Browse files
authored
Fix multiline dbml comment export (#550)
1 parent b62471c commit 6ade511

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/utils/exportAs/dbml.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ function fieldSize(field, database) {
7474
return "";
7575
}
7676

77+
function processComment(comment) {
78+
if (comment.includes("\n")) {
79+
return `'''${comment}'''`;
80+
}
81+
82+
return `'${escapeQuotes(comment)}'`;
83+
}
84+
7785
export function toDBML(diagram) {
7886
const generateRelString = (rel) => {
7987
const { fields: startTableFields, name: startTableName } =
@@ -139,7 +147,7 @@ export function toDBML(diagram) {
139147
: ""
140148
}${
141149
table.comment && table.comment.trim() !== ""
142-
? `\n\n\tNote: '${escapeQuotes(table.comment)}'`
150+
? `\n\n\tNote: ${processComment(table.comment)}`
143151
: ""
144152
}\n}`,
145153
)

0 commit comments

Comments
 (0)