@dbml/core
Advanced tools
Comparing version 3.1.5 to 3.1.6
@@ -39,3 +39,14 @@ "use strict"; | ||
value: function escapeNote(str) { | ||
return str.replaceAll("'", "\\'"); | ||
if (str === null) { | ||
return ''; | ||
} | ||
var newStr = str.replaceAll('\\', '\\\\'); | ||
if (!newStr.match(/[\n\r']/)) { | ||
// Only safe chars, no simple quotes nor CR/LF | ||
return "'".concat(newStr, "'"); | ||
} | ||
// see https://dbml.dbdiagram.io/docs/#multi-line-string | ||
newStr = newStr.replaceAll("'''", "\\'''"); | ||
newStr = newStr.replaceAll('\r\n', '\n'); // turn all CRLF to LF | ||
return "'''".concat(newStr, "'''"); | ||
} | ||
@@ -49,3 +60,3 @@ }, { | ||
return "Enum ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(_enum.name, "\" {\n").concat(_enum.valueIds.map(function (valueId) { | ||
return " \"".concat(model.enumValues[valueId].name, "\"").concat(model.enumValues[valueId].note ? " [note: '".concat(DbmlExporter.escapeNote(model.enumValues[valueId].note), "']") : ''); | ||
return " \"".concat(model.enumValues[valueId].name, "\"").concat(model.enumValues[valueId].note ? " [note: ".concat(DbmlExporter.escapeNote(model.enumValues[valueId].note), "]") : ''); | ||
}).join('\n'), "\n}\n"); | ||
@@ -98,3 +109,3 @@ }); | ||
if (field.note) { | ||
constraints.push("note: '".concat(DbmlExporter.escapeNote(field.note), "'")); | ||
constraints.push("note: ".concat(DbmlExporter.escapeNote(field.note))); | ||
} | ||
@@ -191,3 +202,3 @@ if (constraints.length > 0) { | ||
} | ||
var tableNote = table.note ? " Note: '".concat(DbmlExporter.escapeNote(table.note), "'\n") : ''; | ||
var tableNote = table.note ? " Note: ".concat(DbmlExporter.escapeNote(table.note), "\n") : ''; | ||
var tableStr = "Table ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(table.name, "\"").concat(tableSettingStr, " {\n").concat(tableContent.fieldContents.map(function (line) { | ||
@@ -194,0 +205,0 @@ return " ".concat(line); |
{ | ||
"name": "@dbml/core", | ||
"version": "3.1.5", | ||
"version": "3.1.6", | ||
"description": "> TODO: description", | ||
@@ -35,3 +35,3 @@ "author": "Holistics <dev@holistics.io>", | ||
"dependencies": { | ||
"@dbml/parse": "^3.1.5", | ||
"@dbml/parse": "^3.1.6", | ||
"antlr4": "^4.13.1", | ||
@@ -63,3 +63,3 @@ "lodash": "^4.17.15", | ||
}, | ||
"gitHead": "ff90597690710144dafb2464b3d1a5134ef4e019" | ||
"gitHead": "f82965d9636209e22f31794111f37e05c5da79ce" | ||
} |
9266949
41372
Updated@dbml/parse@^3.1.6