@dbml/core 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,6 +33,11 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
33
33
|
value: function isExpression(str) {
|
|
34
34
|
return /\s*(\*|\+|-|\([A-Za-z0-9_]+\)|\(\))/g.test(str);
|
|
35
35
|
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "escapeNote",
|
|
38
|
+
value: function escapeNote(str) {
|
|
39
|
+
return str.replaceAll("'", "\\'");
|
|
40
|
+
}
|
|
36
41
|
}, {
|
|
37
42
|
key: "exportEnums",
|
|
38
43
|
value: function exportEnums(enumIds, model) {
|
|
@@ -40,7 +45,7 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
40
45
|
var _enum = model.enums[enumId];
|
|
41
46
|
var schema = model.schemas[_enum.schemaId];
|
|
42
47
|
return "Enum ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(_enum.name, "\" {\n").concat(_enum.valueIds.map(function (valueId) {
|
|
43
|
-
return " \"".concat(model.enumValues[valueId].name, "\"").concat(model.enumValues[valueId].note ? " [note: '".concat(model.enumValues[valueId].note, "']") : '');
|
|
48
|
+
return " \"".concat(model.enumValues[valueId].name, "\"").concat(model.enumValues[valueId].note ? " [note: '".concat(DbmlExporter.escapeNote(model.enumValues[valueId].note), "']") : '');
|
|
44
49
|
}).join('\n'), "\n}\n");
|
|
45
50
|
});
|
|
46
51
|
return enumStrs.length ? enumStrs.join('\n') : '';
|
|
@@ -88,7 +93,7 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
88
93
|
constraints.push(value);
|
|
89
94
|
}
|
|
90
95
|
if (field.note) {
|
|
91
|
-
constraints.push("note: '".concat(field.note, "'"));
|
|
96
|
+
constraints.push("note: '".concat(DbmlExporter.escapeNote(field.note), "'"));
|
|
92
97
|
}
|
|
93
98
|
if (constraints.length > 0) {
|
|
94
99
|
line += " [".concat(constraints.join(', '), "]");
|
|
@@ -180,7 +185,7 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
180
185
|
return " ".concat(indexLine);
|
|
181
186
|
}).join('\n'), "\n}");
|
|
182
187
|
}
|
|
183
|
-
var tableNote = table.note ? " Note: '".concat(table.note, "'\n") : '';
|
|
188
|
+
var tableNote = table.note ? " Note: '".concat(DbmlExporter.escapeNote(table.note), "'\n") : '';
|
|
184
189
|
var tableStr = "Table ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(table.name, "\"").concat(tableSettingStr, " {\n").concat(tableContent.fieldContents.map(function (line) {
|
|
185
190
|
return " ".concat(line);
|
|
186
191
|
}).join('\n'), "\n").concat(indexStr ? "".concat(indexStr, "\n") : '').concat(tableNote, "}\n");
|
|
@@ -49,6 +49,12 @@ var findTable = function findTable(tables, schemaName, tableName) {
|
|
|
49
49
|
});
|
|
50
50
|
return table;
|
|
51
51
|
};
|
|
52
|
+
var escapeStr = function escapeStr(str) {
|
|
53
|
+
if (str) {
|
|
54
|
+
return str.replaceAll("''", "'");
|
|
55
|
+
}
|
|
56
|
+
return str;
|
|
57
|
+
};
|
|
52
58
|
var PostgresASTGen = /*#__PURE__*/function (_PostgreSQLParserVisi) {
|
|
53
59
|
_inherits(PostgresASTGen, _PostgreSQLParserVisi);
|
|
54
60
|
var _super = _createSuper(PostgresASTGen);
|
|
@@ -991,7 +997,7 @@ var PostgresASTGen = /*#__PURE__*/function (_PostgreSQLParserVisi) {
|
|
|
991
997
|
if (!table) return;
|
|
992
998
|
var _note = ctx.comment_text().accept(this);
|
|
993
999
|
table.note = {
|
|
994
|
-
value: _note
|
|
1000
|
+
value: escapeStr(_note)
|
|
995
1001
|
};
|
|
996
1002
|
}
|
|
997
1003
|
}
|
|
@@ -1007,7 +1013,7 @@ var PostgresASTGen = /*#__PURE__*/function (_PostgreSQLParserVisi) {
|
|
|
1007
1013
|
if (!field) return;
|
|
1008
1014
|
var _note2 = ctx.comment_text().accept(this);
|
|
1009
1015
|
field.note = {
|
|
1010
|
-
value: _note2
|
|
1016
|
+
value: escapeStr(_note2)
|
|
1011
1017
|
};
|
|
1012
1018
|
}
|
|
1013
1019
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Holistics <dev@holistics.io>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepublish": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@dbml/parse": "^3.1.
|
|
35
|
+
"@dbml/parse": "^3.1.2",
|
|
36
36
|
"antlr4": "^4.13.1",
|
|
37
37
|
"lodash": "^4.17.15",
|
|
38
38
|
"parsimmon": "^1.13.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"\\.(?!json$)[^.]*$": "@glen/jest-raw-loader"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "25628d4ad260b497fb2d1d03bafb2aa253b56978"
|
|
63
63
|
}
|