@dbml/core 3.11.0-alpha-0 → 3.12.0-alpha-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/model_structure/database.js +36 -11
- package/lib/model_structure/dbState.js +1 -0
- package/lib/parse/ANTLR/ASTGeneration/constants.js +4 -2
- package/lib/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js +969 -28
- package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js +8 -14
- package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.js +8 -19
- package/lib/parse/ANTLR/README.md +6 -1
- package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.g4 +6 -0
- package/lib/parse/ANTLR/parsers/mssql/TSqlParser.g4 +6 -0
- package/package.json +3 -3
- package/types/model_structure/database.d.ts +30 -12
- package/types/parse/Parser.d.ts +1 -1
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _lodash = _interopRequireWildcard(require("lodash"));
|
|
9
9
|
var _schema = _interopRequireDefault(require("./schema"));
|
|
10
|
-
var
|
|
10
|
+
var _ref3 = _interopRequireDefault(require("./ref"));
|
|
11
11
|
var _enum2 = _interopRequireDefault(require("./enum"));
|
|
12
12
|
var _tableGroup = _interopRequireDefault(require("./tableGroup"));
|
|
13
13
|
var _table = _interopRequireDefault(require("./table"));
|
|
@@ -55,7 +55,7 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
55
55
|
_ref$aliases = _ref.aliases,
|
|
56
56
|
aliases = _ref$aliases === void 0 ? [] : _ref$aliases,
|
|
57
57
|
_ref$records = _ref.records,
|
|
58
|
-
records = _ref$records === void 0 ?
|
|
58
|
+
records = _ref$records === void 0 ? [] : _ref$records;
|
|
59
59
|
_classCallCheck(this, Database);
|
|
60
60
|
_this = _super.call(this);
|
|
61
61
|
_this.dbState = new _dbState["default"]();
|
|
@@ -69,8 +69,9 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
69
69
|
_this.name = project.name;
|
|
70
70
|
_this.token = project.token;
|
|
71
71
|
_this.aliases = aliases;
|
|
72
|
-
_this.records =
|
|
72
|
+
_this.records = [];
|
|
73
73
|
_this.processNotes(notes);
|
|
74
|
+
_this.processRecords(records);
|
|
74
75
|
// The process order is important. Do not change !
|
|
75
76
|
_this.processSchemas(schemas);
|
|
76
77
|
_this.processSchemaElements(enums, _config.ENUM);
|
|
@@ -95,6 +96,24 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
95
96
|
})));
|
|
96
97
|
});
|
|
97
98
|
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "processRecords",
|
|
101
|
+
value: function processRecords(rawRecords) {
|
|
102
|
+
var _this3 = this;
|
|
103
|
+
rawRecords.forEach(function (_ref2) {
|
|
104
|
+
var schemaName = _ref2.schemaName,
|
|
105
|
+
tableName = _ref2.tableName,
|
|
106
|
+
columns = _ref2.columns,
|
|
107
|
+
values = _ref2.values;
|
|
108
|
+
_this3.records.push({
|
|
109
|
+
id: _this3.dbState.generateId('recordId'),
|
|
110
|
+
schemaName: schemaName,
|
|
111
|
+
tableName: tableName,
|
|
112
|
+
columns: columns,
|
|
113
|
+
values: values
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
98
117
|
}, {
|
|
99
118
|
key: "pushNote",
|
|
100
119
|
value: function pushNote(note) {
|
|
@@ -113,10 +132,10 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
113
132
|
}, {
|
|
114
133
|
key: "processSchemas",
|
|
115
134
|
value: function processSchemas(rawSchemas) {
|
|
116
|
-
var
|
|
135
|
+
var _this4 = this;
|
|
117
136
|
rawSchemas.forEach(function (schema) {
|
|
118
|
-
|
|
119
|
-
database:
|
|
137
|
+
_this4.pushSchema(new _schema["default"](_objectSpread(_objectSpread({}, schema), {}, {
|
|
138
|
+
database: _this4
|
|
120
139
|
})));
|
|
121
140
|
});
|
|
122
141
|
}
|
|
@@ -138,16 +157,16 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
138
157
|
}, {
|
|
139
158
|
key: "processSchemaElements",
|
|
140
159
|
value: function processSchemaElements(elements, elementType) {
|
|
141
|
-
var
|
|
160
|
+
var _this5 = this;
|
|
142
161
|
var schema;
|
|
143
162
|
elements.forEach(function (element) {
|
|
144
163
|
if (element.schemaName) {
|
|
145
|
-
schema =
|
|
164
|
+
schema = _this5.findOrCreateSchema(element.schemaName);
|
|
146
165
|
if (element.schemaName === _config.DEFAULT_SCHEMA_NAME) {
|
|
147
166
|
// this.hasDefaultSchema = true;
|
|
148
167
|
}
|
|
149
168
|
} else {
|
|
150
|
-
schema =
|
|
169
|
+
schema = _this5.findOrCreateSchema(_config.DEFAULT_SCHEMA_NAME);
|
|
151
170
|
}
|
|
152
171
|
switch (elementType) {
|
|
153
172
|
case _config.TABLE:
|
|
@@ -166,7 +185,7 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
166
185
|
})));
|
|
167
186
|
break;
|
|
168
187
|
case _config.REF:
|
|
169
|
-
schema.pushRef(new
|
|
188
|
+
schema.pushRef(new _ref3["default"](_objectSpread(_objectSpread({}, element), {}, {
|
|
170
189
|
schema: schema
|
|
171
190
|
})));
|
|
172
191
|
break;
|
|
@@ -262,6 +281,9 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
262
281
|
}),
|
|
263
282
|
notes: this.notes.map(function (n) {
|
|
264
283
|
return n["export"]();
|
|
284
|
+
}),
|
|
285
|
+
records: this.records.map(function (r) {
|
|
286
|
+
return _objectSpread({}, r);
|
|
265
287
|
})
|
|
266
288
|
};
|
|
267
289
|
}
|
|
@@ -295,7 +317,7 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
295
317
|
indexes: {},
|
|
296
318
|
indexColumns: {},
|
|
297
319
|
fields: {},
|
|
298
|
-
records:
|
|
320
|
+
records: {}
|
|
299
321
|
};
|
|
300
322
|
this.schemas.forEach(function (schema) {
|
|
301
323
|
return schema.normalize(normalizedModel);
|
|
@@ -303,6 +325,9 @@ var Database = /*#__PURE__*/function (_Element) {
|
|
|
303
325
|
this.notes.forEach(function (note) {
|
|
304
326
|
return note.normalize(normalizedModel);
|
|
305
327
|
});
|
|
328
|
+
this.records.forEach(function (record) {
|
|
329
|
+
return normalizedModel.records[record.id] = _objectSpread({}, record);
|
|
330
|
+
});
|
|
306
331
|
return normalizedModel;
|
|
307
332
|
}
|
|
308
333
|
}]);
|
|
@@ -9,7 +9,8 @@ var TABLE_CONSTRAINT_KIND = {
|
|
|
9
9
|
INDEX: 'index',
|
|
10
10
|
FK: 'fk',
|
|
11
11
|
UNIQUE: 'unique',
|
|
12
|
-
PK: 'pk'
|
|
12
|
+
PK: 'pk',
|
|
13
|
+
DEFAULT: 'default'
|
|
13
14
|
};
|
|
14
15
|
exports.TABLE_CONSTRAINT_KIND = TABLE_CONSTRAINT_KIND;
|
|
15
16
|
var COLUMN_CONSTRAINT_KIND = {
|
|
@@ -19,7 +20,8 @@ var COLUMN_CONSTRAINT_KIND = {
|
|
|
19
20
|
DEFAULT: 'dbdefault',
|
|
20
21
|
INCREMENT: 'increment',
|
|
21
22
|
INLINE_REF: 'inline_ref',
|
|
22
|
-
NOTE: 'note'
|
|
23
|
+
NOTE: 'note',
|
|
24
|
+
CHECK: 'check'
|
|
23
25
|
};
|
|
24
26
|
exports.COLUMN_CONSTRAINT_KIND = COLUMN_CONSTRAINT_KIND;
|
|
25
27
|
var DATA_TYPE = {
|