@dbml/core 2.4.3 → 2.5.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.
@@ -63,9 +63,12 @@ var PostgresExporter = /*#__PURE__*/function () {
63
63
  var line = '';
64
64
 
65
65
  if (field.increment) {
66
- var typeSerial = 'SERIAL';
67
- if (field.type.type_name.toLowerCase() === 'bigint') typeSerial = 'BIGSERIAL';else if (field.type.type_name.toLowerCase() === 'smallserial') typeSerial = 'SMALLSERIAL';
68
- line = "\"".concat(field.name, "\" ").concat(typeSerial);
66
+ var typicalIntergers = new Set(['BIGINT', 'INT', 'INTEGER', 'SMALLINT']);
67
+ var incrementIntergers = new Set(['SMALLSERIAL', 'SERIAL', 'BIGSERIAL']);
68
+ var typeRaw = field.type.type_name.toUpperCase();
69
+ var type = '';
70
+ if (typicalIntergers.has(typeRaw)) type = "".concat(typeRaw, " GENERATED BY DEFAULT AS IDENTITY");else if (incrementIntergers.has(typeRaw)) type = typeRaw;else type = 'SERIAL';
71
+ line = "\"".concat(field.name, "\" ").concat(type);
69
72
  } else {
70
73
  var schemaName = '';
71
74
 
@@ -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;
@@ -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