@dbml/core 3.15.0-alpha.0 → 4.0.0
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.
- package/lib/index.js +1 -1
- package/lib/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js +39 -144
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.g4 +1 -1
- package/lib/parse/schemarb/parser.pegjs +1 -1
- package/lib/parse/schemarbParser.js +1 -1
- package/package.json +3 -3
- package/types/model_structure/constraint.d.ts +5 -5
package/lib/index.js
CHANGED
|
@@ -41,7 +41,7 @@ Object.defineProperty(exports, "importer", {
|
|
|
41
41
|
});
|
|
42
42
|
var _ModelExporter = _interopRequireDefault(require("./export/ModelExporter"));
|
|
43
43
|
var _Parser = _interopRequireDefault(require("./parse/Parser"));
|
|
44
|
-
var _error = require("
|
|
44
|
+
var _error = require("./parse/error");
|
|
45
45
|
var _import = _interopRequireDefault(require("./import"));
|
|
46
46
|
var _export = _interopRequireDefault(require("./export"));
|
|
47
47
|
var _version = require("./utils/version");
|
|
@@ -14,6 +14,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
|
14
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
16
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
18
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
20
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
17
21
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
18
22
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
19
23
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -26,10 +30,6 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
26
30
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
27
31
|
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
28
32
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
29
|
-
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
30
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
|
-
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
32
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
33
33
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
34
34
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
35
35
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -37,10 +37,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
37
37
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
38
38
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /* eslint-disable class-methods-use-this */
|
|
39
39
|
var ADD_DESCRIPTION_FUNCTION_NAME = 'sp_addextendedproperty';
|
|
40
|
-
var CHECK_CONSTRAINT_CONDITION_TYPE = {
|
|
41
|
-
RAW: 'raw',
|
|
42
|
-
ENUM: 'enum'
|
|
43
|
-
};
|
|
44
40
|
var getSchemaAndTableName = function getSchemaAndTableName(names) {
|
|
45
41
|
var tableName = (0, _lodash.last)(names);
|
|
46
42
|
var schemaName = names.length > 1 ? (0, _lodash.nth)(names, -2) : undefined;
|
|
@@ -107,7 +103,6 @@ var splitColumnDefTableConstraints = function splitColumnDefTableConstraints(col
|
|
|
107
103
|
};
|
|
108
104
|
var parseFieldsAndInlineRefsFromFieldsData = function parseFieldsAndInlineRefsFromFieldsData(fieldsData, tableName, schemaName) {
|
|
109
105
|
var _fieldsData$reduce = fieldsData.reduce(function (acc, fieldData) {
|
|
110
|
-
var _acc$;
|
|
111
106
|
var inlineRefs = fieldData.inline_refs.map(function (inlineRef) {
|
|
112
107
|
inlineRef.endpoints[0].tableName = tableName;
|
|
113
108
|
inlineRef.endpoints[0].schemaName = schemaName;
|
|
@@ -116,17 +111,14 @@ var parseFieldsAndInlineRefsFromFieldsData = function parseFieldsAndInlineRefsFr
|
|
|
116
111
|
});
|
|
117
112
|
acc[0].push(inlineRefs);
|
|
118
113
|
acc[1].push(fieldData.field);
|
|
119
|
-
(_acc$ = acc[2]).push.apply(_acc$, _toConsumableArray(fieldData.enumCheckConstraints));
|
|
120
114
|
return acc;
|
|
121
115
|
}, [[], [], []]),
|
|
122
|
-
_fieldsData$reduce2 = _slicedToArray(_fieldsData$reduce,
|
|
116
|
+
_fieldsData$reduce2 = _slicedToArray(_fieldsData$reduce, 2),
|
|
123
117
|
resInlineRefs = _fieldsData$reduce2[0],
|
|
124
|
-
fields = _fieldsData$reduce2[1]
|
|
125
|
-
enumCheckConstraints = _fieldsData$reduce2[2];
|
|
118
|
+
fields = _fieldsData$reduce2[1];
|
|
126
119
|
return {
|
|
127
120
|
inlineRefs: resInlineRefs,
|
|
128
|
-
fields: fields
|
|
129
|
-
enumCheckConstraints: enumCheckConstraints
|
|
121
|
+
fields: fields
|
|
130
122
|
};
|
|
131
123
|
};
|
|
132
124
|
var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor) {
|
|
@@ -605,51 +597,19 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
605
597
|
tableCheckConstraints = _splitColumnDefTableC.checkConstraints;
|
|
606
598
|
var _parseFieldsAndInline = parseFieldsAndInlineRefsFromFieldsData(fieldsData, tableName, schemaName),
|
|
607
599
|
inlineRefs = _parseFieldsAndInline.inlineRefs,
|
|
608
|
-
fields = _parseFieldsAndInline.fields
|
|
609
|
-
columnEnumCheckConstraints = _parseFieldsAndInline.enumCheckConstraints;
|
|
600
|
+
fields = _parseFieldsAndInline.fields;
|
|
610
601
|
(_this$data$refs = this.data.refs).push.apply(_this$data$refs, _toConsumableArray((0, _lodash.flatten)(inlineRefs)));
|
|
611
602
|
(_this$data$refs2 = this.data.refs).push.apply(_this$data$refs2, _toConsumableArray(tableRefs.map(function (tableRef) {
|
|
612
603
|
tableRef.endpoints[0].tableName = tableName;
|
|
613
604
|
tableRef.endpoints[0].schemaName = schemaName;
|
|
614
605
|
return tableRef;
|
|
615
606
|
})));
|
|
616
|
-
var allCheckConstraints = columnEnumCheckConstraints.concat(tableCheckConstraints);
|
|
617
|
-
var rawTableConstraints = [];
|
|
618
|
-
allCheckConstraints.forEach(function (checkConstraint) {
|
|
619
|
-
if (checkConstraint.isRaw) {
|
|
620
|
-
var constraintObj = {
|
|
621
|
-
expression: checkConstraint.expression
|
|
622
|
-
};
|
|
623
|
-
if (checkConstraint.name) {
|
|
624
|
-
constraintObj.name = checkConstraint.name;
|
|
625
|
-
}
|
|
626
|
-
rawTableConstraints.push(constraintObj);
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
var field = fields.find(function (fieldItem) {
|
|
630
|
-
return fieldItem.name === checkConstraint.column;
|
|
631
|
-
});
|
|
632
|
-
if (!field) return;
|
|
633
|
-
var enumObject = new _AST.Enum({
|
|
634
|
-
name: "".concat(tableName, "_").concat(field.name, "_enum"),
|
|
635
|
-
values: checkConstraint.columnValues.map(function (value) {
|
|
636
|
-
return {
|
|
637
|
-
name: value
|
|
638
|
-
};
|
|
639
|
-
}),
|
|
640
|
-
schemaName: schemaName
|
|
641
|
-
});
|
|
642
|
-
_this8.data.enums.push(enumObject);
|
|
643
|
-
// TODO: Handle multiple enums for the same field
|
|
644
|
-
field.type.type_name = enumObject.name;
|
|
645
|
-
field.type.schemaName = enumObject.schemaName;
|
|
646
|
-
});
|
|
647
607
|
var table = new _AST.Table({
|
|
648
608
|
name: tableName,
|
|
649
609
|
schemaName: schemaName,
|
|
650
610
|
fields: fields,
|
|
651
611
|
indexes: tableIndices.concat(indexes),
|
|
652
|
-
constraints:
|
|
612
|
+
constraints: tableCheckConstraints
|
|
653
613
|
});
|
|
654
614
|
this.data.tables.push(table);
|
|
655
615
|
}
|
|
@@ -729,8 +689,7 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
729
689
|
kind: _constants.TABLE_CONSTRAINT_KIND.FIELD,
|
|
730
690
|
value: {
|
|
731
691
|
field: field,
|
|
732
|
-
inline_refs: []
|
|
733
|
-
enumCheckConstraints: []
|
|
692
|
+
inline_refs: []
|
|
734
693
|
}
|
|
735
694
|
};
|
|
736
695
|
var columnDefinitions = ctx.column_definition_element().map(function (columnDef) {
|
|
@@ -767,25 +726,18 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
767
726
|
case _constants.COLUMN_CONSTRAINT_KIND.CHECK:
|
|
768
727
|
{
|
|
769
728
|
var _columnDef$value = columnDef.value,
|
|
770
|
-
|
|
771
|
-
value = _columnDef$value.value,
|
|
729
|
+
_expression = _columnDef$value.expression,
|
|
772
730
|
name = _columnDef$value.name;
|
|
773
|
-
if (
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
var constraintObj = {
|
|
782
|
-
expression: value
|
|
783
|
-
};
|
|
784
|
-
if (name) {
|
|
785
|
-
constraintObj.name = name;
|
|
786
|
-
}
|
|
787
|
-
field.constraints.push(constraintObj);
|
|
731
|
+
if (!field.constraints) {
|
|
732
|
+
field.constraints = [];
|
|
733
|
+
}
|
|
734
|
+
var constraintObj = {
|
|
735
|
+
expression: _expression
|
|
736
|
+
};
|
|
737
|
+
if (name) {
|
|
738
|
+
constraintObj.name = name;
|
|
788
739
|
}
|
|
740
|
+
field.constraints.push(constraintObj);
|
|
789
741
|
break;
|
|
790
742
|
}
|
|
791
743
|
default:
|
|
@@ -894,8 +846,6 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
894
846
|
}
|
|
895
847
|
};
|
|
896
848
|
}
|
|
897
|
-
|
|
898
|
-
// we do not handle check constraint since it is complicated and hard to extract enum from it
|
|
899
849
|
if (ctx.check_constraint()) {
|
|
900
850
|
var constraintName = ctx.id_() ? ctx.id_().accept(this) : null;
|
|
901
851
|
var checkConstraintResult = ctx.check_constraint().accept(this);
|
|
@@ -926,24 +876,8 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
926
876
|
}, {
|
|
927
877
|
key: "visitSearch_condition",
|
|
928
878
|
value: function visitSearch_condition(ctx) {
|
|
929
|
-
// we will parse the enum from the most basic condition - map to the old behavior
|
|
930
|
-
// others, we will get the check constraint to ensure the constraint is applied - enhance the old behavior
|
|
931
|
-
if (!ctx.predicate() || ctx.NOT().length) {
|
|
932
|
-
return {
|
|
933
|
-
type: CHECK_CONSTRAINT_CONDITION_TYPE.RAW,
|
|
934
|
-
value: (0, _helpers.getOriginalText)(ctx)
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
var predicate = ctx.predicate().accept(this);
|
|
938
|
-
if (!predicate) {
|
|
939
|
-
return {
|
|
940
|
-
type: CHECK_CONSTRAINT_CONDITION_TYPE.RAW,
|
|
941
|
-
value: (0, _helpers.getOriginalText)(ctx)
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
879
|
return {
|
|
945
|
-
|
|
946
|
-
value: predicate
|
|
880
|
+
expression: (0, _helpers.getOriginalText)(ctx)
|
|
947
881
|
};
|
|
948
882
|
}
|
|
949
883
|
|
|
@@ -1143,22 +1077,11 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
1143
1077
|
}
|
|
1144
1078
|
if (ctx.check_constraint()) {
|
|
1145
1079
|
var checkConstraint = ctx.check_constraint().accept(this);
|
|
1146
|
-
|
|
1147
|
-
// If it's an ENUM type (simple IN clause), return for enum extraction
|
|
1148
|
-
if (checkConstraint.type === CHECK_CONSTRAINT_CONDITION_TYPE.ENUM) {
|
|
1149
|
-
return {
|
|
1150
|
-
kind: _constants.TABLE_CONSTRAINT_KIND.CHECK,
|
|
1151
|
-
value: checkConstraint.value
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
// For RAW constraints, return them too so they can be added to table.constraints
|
|
1156
1080
|
return {
|
|
1157
1081
|
kind: _constants.TABLE_CONSTRAINT_KIND.CHECK,
|
|
1158
1082
|
value: {
|
|
1159
|
-
expression: checkConstraint.
|
|
1160
|
-
name: name
|
|
1161
|
-
isRaw: true // Mark as raw constraint
|
|
1083
|
+
expression: checkConstraint.expression,
|
|
1084
|
+
name: name
|
|
1162
1085
|
}
|
|
1163
1086
|
};
|
|
1164
1087
|
}
|
|
@@ -1223,11 +1146,7 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
1223
1146
|
}, {
|
|
1224
1147
|
key: "visitAlter_table",
|
|
1225
1148
|
value: function visitAlter_table(ctx) {
|
|
1226
|
-
var _this$data$refs3,
|
|
1227
|
-
_this$data$refs4,
|
|
1228
|
-
_table$fields,
|
|
1229
|
-
_table$indexes,
|
|
1230
|
-
_this16 = this;
|
|
1149
|
+
var _this$data$refs3, _this$data$refs4, _table$fields, _table$indexes;
|
|
1231
1150
|
// table_name() returns an array because there are multiple table_name in the clause (REFERENCES table_name ...)
|
|
1232
1151
|
var names = ctx.table_name()[0].accept(this);
|
|
1233
1152
|
var _getSchemaAndTableNam3 = getSchemaAndTableName(names),
|
|
@@ -1264,37 +1183,13 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
1264
1183
|
field.dbdefault = columnDefault.defaultValue;
|
|
1265
1184
|
});
|
|
1266
1185
|
checkConstraints.forEach(function (checkConstraint) {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
if (checkConstraint.name) {
|
|
1273
|
-
constraintObj.name = checkConstraint.name;
|
|
1274
|
-
}
|
|
1275
|
-
table.constraints.push(constraintObj);
|
|
1276
|
-
return;
|
|
1186
|
+
var constraintObj = {
|
|
1187
|
+
expression: checkConstraint.expression
|
|
1188
|
+
};
|
|
1189
|
+
if (checkConstraint.name) {
|
|
1190
|
+
constraintObj.name = checkConstraint.name;
|
|
1277
1191
|
}
|
|
1278
|
-
|
|
1279
|
-
// Handle ENUM constraints: simple IN clauses like CHECK (status IN ('a', 'b', 'c'))
|
|
1280
|
-
// These get converted to actual Enum objects and the field type is updated
|
|
1281
|
-
var field = table.fields.find(function (fieldItem) {
|
|
1282
|
-
return fieldItem.name === checkConstraint.column;
|
|
1283
|
-
});
|
|
1284
|
-
if (!field) return;
|
|
1285
|
-
var enumObject = new _AST.Enum({
|
|
1286
|
-
name: "".concat(tableName, "_").concat(field.name, "_enum"),
|
|
1287
|
-
values: checkConstraint.columnValues.map(function (value) {
|
|
1288
|
-
return {
|
|
1289
|
-
name: value
|
|
1290
|
-
};
|
|
1291
|
-
}),
|
|
1292
|
-
schemaName: schemaName
|
|
1293
|
-
});
|
|
1294
|
-
_this16.data.enums.push(enumObject);
|
|
1295
|
-
// TODO: handle multiple enums for the same field
|
|
1296
|
-
field.type.type_name = enumObject.name;
|
|
1297
|
-
field.type.schemaName = enumObject.schemaName;
|
|
1192
|
+
table.constraints.push(constraintObj);
|
|
1298
1193
|
});
|
|
1299
1194
|
}
|
|
1300
1195
|
|
|
@@ -1438,12 +1333,12 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
1438
1333
|
}, {
|
|
1439
1334
|
key: "visitFunc_proc_name_server_database_schema",
|
|
1440
1335
|
value: function visitFunc_proc_name_server_database_schema(ctx) {
|
|
1441
|
-
var
|
|
1336
|
+
var _this16 = this;
|
|
1442
1337
|
if (ctx.func_proc_name_database_schema()) {
|
|
1443
1338
|
return ctx.func_proc_name_database_schema().accept(this);
|
|
1444
1339
|
}
|
|
1445
1340
|
return ctx.id_().map(function (id) {
|
|
1446
|
-
return id.accept(
|
|
1341
|
+
return id.accept(_this16);
|
|
1447
1342
|
});
|
|
1448
1343
|
}
|
|
1449
1344
|
|
|
@@ -1454,12 +1349,12 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
1454
1349
|
}, {
|
|
1455
1350
|
key: "visitFunc_proc_name_database_schema",
|
|
1456
1351
|
value: function visitFunc_proc_name_database_schema(ctx) {
|
|
1457
|
-
var
|
|
1352
|
+
var _this17 = this;
|
|
1458
1353
|
if (ctx.func_proc_name_schema()) {
|
|
1459
1354
|
return ctx.func_proc_name_schema().accept(this);
|
|
1460
1355
|
}
|
|
1461
1356
|
return ctx.id_().map(function (id) {
|
|
1462
|
-
return id.accept(
|
|
1357
|
+
return id.accept(_this17);
|
|
1463
1358
|
});
|
|
1464
1359
|
}
|
|
1465
1360
|
|
|
@@ -1469,9 +1364,9 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
1469
1364
|
}, {
|
|
1470
1365
|
key: "visitFunc_proc_name_schema",
|
|
1471
1366
|
value: function visitFunc_proc_name_schema(ctx) {
|
|
1472
|
-
var
|
|
1367
|
+
var _this18 = this;
|
|
1473
1368
|
return ctx.id_().map(function (id) {
|
|
1474
|
-
return id.accept(
|
|
1369
|
+
return id.accept(_this18);
|
|
1475
1370
|
});
|
|
1476
1371
|
}
|
|
1477
1372
|
|
|
@@ -1482,14 +1377,14 @@ var MssqlASTGen = exports["default"] = /*#__PURE__*/function (_TSqlParserVisitor
|
|
|
1482
1377
|
}, {
|
|
1483
1378
|
key: "visitExecute_statement_arg",
|
|
1484
1379
|
value: function visitExecute_statement_arg(ctx) {
|
|
1485
|
-
var
|
|
1380
|
+
var _this19 = this;
|
|
1486
1381
|
if (ctx.execute_statement_arg_unnamed()) {
|
|
1487
1382
|
return ctx.execute_statement_arg_unnamed().map(function (item) {
|
|
1488
|
-
return item.accept(
|
|
1383
|
+
return item.accept(_this19);
|
|
1489
1384
|
});
|
|
1490
1385
|
}
|
|
1491
1386
|
return ctx.execute_statement_arg_named().map(function (item) {
|
|
1492
|
-
return item.accept(
|
|
1387
|
+
return item.accept(_this19);
|
|
1493
1388
|
});
|
|
1494
1389
|
}
|
|
1495
1390
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
function addCheckConstraintToTable(tableName, expression, name) {
|
|
26
26
|
const table = data.tables.find(t => t.name === tableName);
|
|
27
27
|
if (!table) {
|
|
28
|
-
error("Table
|
|
28
|
+
error("Table ${tableName} not found");
|
|
29
29
|
}
|
|
30
30
|
if (!table.constraints) {
|
|
31
31
|
table.constraints = [];
|
|
@@ -2464,7 +2464,7 @@ function peg$parse(input, options) {
|
|
|
2464
2464
|
return t.name === tableName;
|
|
2465
2465
|
});
|
|
2466
2466
|
if (!table) {
|
|
2467
|
-
error("Table
|
|
2467
|
+
error("Table ${tableName} not found");
|
|
2468
2468
|
}
|
|
2469
2469
|
if (!table.constraints) {
|
|
2470
2470
|
table.constraints = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
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": "^
|
|
35
|
+
"@dbml/parse": "^4.0.0",
|
|
36
36
|
"antlr4": "^4.13.1",
|
|
37
37
|
"lodash": "^4.17.15",
|
|
38
38
|
"parsimmon": "^1.13.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"^lodash-es$": "lodash"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "defacb4ec78893de46225948499feea5bf2932e2",
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=16"
|
|
68
68
|
}
|
|
@@ -7,7 +7,7 @@ import TablePartial from './tablePartial';
|
|
|
7
7
|
interface RawConstraint {
|
|
8
8
|
token: Token;
|
|
9
9
|
name: string;
|
|
10
|
-
expression:
|
|
10
|
+
expression: string;
|
|
11
11
|
table: Table;
|
|
12
12
|
column?: Field | null;
|
|
13
13
|
injectedPartial?: TablePartial | null;
|
|
@@ -15,7 +15,7 @@ interface RawConstraint {
|
|
|
15
15
|
|
|
16
16
|
declare class Constraint extends Element {
|
|
17
17
|
name: string;
|
|
18
|
-
expression:
|
|
18
|
+
expression: string;
|
|
19
19
|
table: Table;
|
|
20
20
|
column: Field | null;
|
|
21
21
|
injectedPartial: TablePartial | null;
|
|
@@ -24,7 +24,7 @@ declare class Constraint extends Element {
|
|
|
24
24
|
generateId(): void;
|
|
25
25
|
export(): {
|
|
26
26
|
name: string;
|
|
27
|
-
expression:
|
|
27
|
+
expression: string;
|
|
28
28
|
};
|
|
29
29
|
exportParentIds(): {
|
|
30
30
|
tableId: number;
|
|
@@ -33,7 +33,7 @@ declare class Constraint extends Element {
|
|
|
33
33
|
};
|
|
34
34
|
shallowExport(): {
|
|
35
35
|
name: string;
|
|
36
|
-
expression:
|
|
36
|
+
expression: string;
|
|
37
37
|
};
|
|
38
38
|
normalize(model: NormalizedDatabase): void;
|
|
39
39
|
}
|
|
@@ -42,7 +42,7 @@ export interface NormalizedConstraint {
|
|
|
42
42
|
[_id: number]: {
|
|
43
43
|
id: number;
|
|
44
44
|
name: string;
|
|
45
|
-
expression:
|
|
45
|
+
expression: string;
|
|
46
46
|
tableId: number;
|
|
47
47
|
columnId: number | null;
|
|
48
48
|
injectedPartialId: number | null;
|