@dbml/core 2.4.4 → 2.5.1

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.
@@ -85,7 +85,8 @@ var Database = /*#__PURE__*/function (_Element) {
85
85
 
86
86
  _this.hasDefaultSchema = false;
87
87
  _this.schemas = [];
88
- _this.note = project.note;
88
+ _this.note = project.note ? project.note.value : null;
89
+ _this.noteToken = project.note ? project.note.token : null;
89
90
  _this.databaseType = project.database_type;
90
91
  _this.name = project.name;
91
92
  _this.aliases = aliases; // The process order is important. Do not change !
@@ -190,7 +191,9 @@ var Database = /*#__PURE__*/function (_Element) {
190
191
  if (!schema) {
191
192
  schema = new _schema["default"]({
192
193
  name: schemaName,
193
- note: schemaName === _config.DEFAULT_SCHEMA_NAME ? "Default ".concat(_lodash["default"].capitalize(_config.DEFAULT_SCHEMA_NAME), " Schema") : '',
194
+ note: {
195
+ value: schemaName === _config.DEFAULT_SCHEMA_NAME ? "Default ".concat(_lodash["default"].capitalize(_config.DEFAULT_SCHEMA_NAME), " Schema") : null
196
+ },
194
197
  database: this
195
198
  });
196
199
  this.pushSchema(schema);
@@ -65,7 +65,8 @@ var Enum = /*#__PURE__*/function (_Element) {
65
65
  }
66
66
 
67
67
  _this.name = name;
68
- _this.note = note;
68
+ _this.note = note ? note.value : null;
69
+ _this.noteToken = note ? note.token : null;
69
70
  _this.values = [];
70
71
  _this.fields = [];
71
72
  _this.schema = schema;
@@ -60,7 +60,8 @@ var EnumValue = /*#__PURE__*/function (_Element) {
60
60
  }
61
61
 
62
62
  _this.name = name;
63
- _this.note = note;
63
+ _this.note = note ? note.value : null;
64
+ _this.noteToken = note ? note.token : null;
64
65
  _this._enum = _enum;
65
66
  _this.dbState = _this._enum.dbState;
66
67
 
@@ -53,7 +53,7 @@ var Field = /*#__PURE__*/function (_Element) {
53
53
  unique = _ref.unique,
54
54
  pk = _ref.pk,
55
55
  token = _ref.token,
56
- not_null = _ref.not_null,
56
+ notNull = _ref.not_null,
57
57
  note = _ref.note,
58
58
  dbdefault = _ref.dbdefault,
59
59
  increment = _ref.increment,
@@ -77,8 +77,9 @@ var Field = /*#__PURE__*/function (_Element) {
77
77
  _this.type = type;
78
78
  _this.unique = unique;
79
79
  _this.pk = pk;
80
- _this.not_null = not_null;
81
- _this.note = note;
80
+ _this.not_null = notNull;
81
+ _this.note = note ? note.value : null;
82
+ _this.noteToken = note ? note.token : null;
82
83
  _this.dbdefault = dbdefault;
83
84
  _this.increment = increment;
84
85
  _this.endpoints = [];
@@ -64,7 +64,8 @@ var Index = /*#__PURE__*/function (_Element) {
64
64
  _this.name = name;
65
65
  _this.type = type;
66
66
  _this.unique = unique;
67
- _this.note = note;
67
+ _this.note = note ? note.value : null;
68
+ _this.noteToken = note ? note.token : null;
68
69
  _this.pk = pk;
69
70
  _this.columns = [];
70
71
  _this.table = table;
@@ -11,8 +11,6 @@ var _element = _interopRequireDefault(require("./element"));
11
11
 
12
12
  var _enum2 = _interopRequireDefault(require("./enum"));
13
13
 
14
- var _config = require("./config");
15
-
16
14
  var _utils = require("./utils");
17
15
 
18
16
  var _tableGroup = _interopRequireDefault(require("./tableGroup"));
@@ -81,7 +79,8 @@ var Schema = /*#__PURE__*/function (_Element) {
81
79
  _this.tableGroups = [];
82
80
  _this.refs = [];
83
81
  _this.name = name;
84
- _this.note = note;
82
+ _this.note = note ? note.value : null;
83
+ _this.noteToken = note ? note.token : null;
85
84
  _this.alias = alias;
86
85
  _this.database = database;
87
86
  _this.dbState = _this.database.dbState;
@@ -186,7 +185,13 @@ var Schema = /*#__PURE__*/function (_Element) {
186
185
  if (this.refs.some(function (r) {
187
186
  return r.equals(ref);
188
187
  })) {
189
- ref.error('Reference with same endpoints duplicated');
188
+ var endpoint1 = ref.endpoints[0];
189
+ var fieldList1 = endpoint1.fieldNames.map(JSON.stringify).join(', ');
190
+ var endpoint2 = ref.endpoints[1];
191
+ var fieldList2 = endpoint2.fieldNames.map(JSON.stringify).join(', ');
192
+ var ref1 = "\"".concat(endpoint1.schemaName ? "".concat(endpoint1.schemaName, "\".\"") : '').concat(endpoint1.tableName, "\"(").concat(fieldList1, ")");
193
+ var ref2 = "\"".concat(endpoint2.schemaName ? "".concat(endpoint2.schemaName, "\".\"") : '').concat(endpoint2.tableName, "\"(").concat(fieldList2, ")");
194
+ ref.error("Reference with the same endpoints already exists: ".concat(ref1, " references ").concat(ref2));
190
195
  }
191
196
  }
192
197
  }, {
@@ -71,7 +71,8 @@ var Table = /*#__PURE__*/function (_Element) {
71
71
  _this = _super.call(this, token);
72
72
  _this.name = name;
73
73
  _this.alias = alias;
74
- _this.note = note;
74
+ _this.note = note ? note.value : null;
75
+ _this.noteToken = note ? note.token : null;
75
76
  _this.headerColor = headerColor;
76
77
  _this.fields = [];
77
78
  _this.indexes = [];
@@ -556,9 +556,19 @@ IndexName
556
556
  = "name:"i _ val:StringLiteral { return val.value }
557
557
  ObjectNoteElement
558
558
  = note: ObjectNote { return note }
559
- / "note"i _ "{" _ val:StringLiteral _ "}" { return val.value }
559
+ / "note"i _ "{" _ val:StringLiteral _ "}" {
560
+ return {
561
+ value: val.value,
562
+ token: location(),
563
+ }
564
+ }
560
565
  ObjectNote
561
- = "note:"i _ val:StringLiteral { return val.value }
566
+ = "note:"i _ val:StringLiteral {
567
+ return {
568
+ value: val.value,
569
+ token: location(),
570
+ }
571
+ }
562
572
  IndexType
563
573
  = "type:"i _ val:(btree/hash) { return val }
564
574
  RefInline