@dbml/core 2.4.1 → 2.4.3

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.
@@ -59,6 +59,13 @@ data_type "VALID TYPE" = c1:"CHARACTER"i _ c2:"VARYING"i _ args:("("expression")
59
59
  args: args ? args[1] : null
60
60
  }
61
61
  }
62
+ / "timestamptz"i _ number:("(" _ numeric_constant _ ")" _)? dimensions:(array_extension)? {
63
+ const args = number ? number[2] : null;
64
+ return {
65
+ type_name: (args !== null ? `timestamptz(${args})`: `timestamptz`) + (dimensions ? dimensions.map((dimension) => '[' + dimension + ']').join('') : ''),
66
+ args
67
+ }
68
+ }
62
69
  / "timestamp"i _ number:("(" _ numeric_constant _ ")" _)? (("without"i/"with"i) _ "time"i _ "zone"i)? dimensions:(array_extension)? {
63
70
  const args = number ? number[2] : null;
64
71
  return {
@@ -66,6 +73,13 @@ data_type "VALID TYPE" = c1:"CHARACTER"i _ c2:"VARYING"i _ args:("("expression")
66
73
  args
67
74
  }
68
75
  }
76
+ / "timetz"i _ number:("(" _ numeric_constant _ ")" _)? dimensions:(array_extension)? {
77
+ const args = number ? number[2] : null;
78
+ return {
79
+ type_name: (args !== null ? `timetz(${args})`: `timetz`) + (dimensions ? dimensions.map((dimension) => '[' + dimension + ']').join('') : ''),
80
+ args
81
+ }
82
+ }
69
83
  / "time"i _ number:("(" _ numeric_constant _ ")" _)? (("without"i/"with"i) _ "time"i _ "zone"i)? dimensions:(array_extension)? {
70
84
  const args = number ? number[2] : null;
71
85
  return {
@@ -1,4 +1,4 @@
1
- create_table_normal =
1
+ create_table_normal =
2
2
  _ CREATE __ ( ( GLOBAL __ / LOCAL __ )? ( TEMPORARY / TEMP ) __ / UNLOGGED __)? TABLE (__ IF_NOT_EXISTS)? __ table_name:table_name _ "(" _
3
3
  table_properties:table_properties _ ")"
4
4
  (__ INHERITS _ "(" _ parent_tables:table_names _ ")")?
@@ -56,6 +56,7 @@ create_table_normal =
56
56
  field.inline_refs = [];
57
57
  }
58
58
  field.inline_refs.push({
59
+ name: ref.name,
59
60
  endpoint: ref.endpoints[1],
60
61
  onDelete: ref.onDelete,
61
62
  onUpdate: ref.onUpdate
@@ -78,7 +79,7 @@ table_properties = first:table_property rest: (_ comma _ table_property)* {
78
79
  return [first, ...rest.map(r => r[3])];
79
80
  }
80
81
 
81
- table_property =
82
+ table_property =
82
83
  table_constraint:table_constraint {
83
84
  return {
84
85
  table_property_name: "table_constraint",
@@ -93,7 +94,7 @@ table_property =
93
94
  }
94
95
  / column_name:column_name __ data_type:data_type (__ COLLATE __ collation:identifier)? column_constraints:(_ column_constraint)* {
95
96
  const column = { name: column_name , type: data_type};
96
-
97
+
97
98
  // process type (if type === "serial")
98
99
  if (column.type.type_name.toLowerCase() === "serial") {
99
100
  column.type.type_name = "int";
@@ -132,7 +133,7 @@ table_property =
132
133
  }
133
134
 
134
135
  // return { type, value}
135
- column_constraint = (CONSTRAINT __ constraint_name:identifier __)?
136
+ column_constraint = constraint_name:(CONSTRAINT __ constraint_name:identifier __ { return constraint_name })?
136
137
  column_constraint:( NOT __ NULL { return { type: "not_null" , value: true } }
137
138
  / NULL { return { type: "not_null" , value: false } }
138
139
  / CHECK _ "("_ expression _")" (__ NO __ INHERIT)? { return { type: "not_supported" } }
@@ -155,6 +156,7 @@ column_constraint = (CONSTRAINT __ constraint_name:identifier __)?
155
156
  return {
156
157
  type: "fk",
157
158
  value: {
159
+ name: constraint_name,
158
160
  endpoint: {
159
161
  tableName: reftable.name,
160
162
  schemaName: reftable.schemaName,
@@ -170,7 +172,7 @@ column_constraint = (CONSTRAINT __ constraint_name:identifier __)?
170
172
  }
171
173
 
172
174
  // return { type, t_value }
173
- table_constraint = (CONSTRAINT __ constraint_name:identifier __)?
175
+ table_constraint = constraint_name:(CONSTRAINT __ constraint_name:identifier __ { return constraint_name })?
174
176
  table_constraint: ( CHECK _ "("_ expression _")" (__ NO __ INHERIT)? { return { type:"not_supported" } }
175
177
  / UNIQUE _ "(" _ column_names:column_names _ ")" (__ index_parameters)? { return { type: "unique", t_value: column_names } }
176
178
  / PRIMARY_KEY _ "("_ column_names:column_names _ ")" (__ index_parameters)? { return { type: "pk", t_value: column_names } }
@@ -186,6 +188,7 @@ table_constraint = (CONSTRAINT __ constraint_name:identifier __)?
186
188
  //throw Error(`Line ${location().start.line}: ${column_name} do not have referenced column.`)
187
189
  //}
188
190
  const v = {
191
+ name: constraint_name,
189
192
  endpoints: [
190
193
  {
191
194
  tableName: null,
@@ -210,7 +213,7 @@ table_constraint = (CONSTRAINT __ constraint_name:identifier __)?
210
213
  value.push(v);
211
214
  return {
212
215
  type: "fk",
213
- t_value: value
216
+ t_value: value
214
217
  }
215
218
  }
216
219
  ) (__ DEFERRABLE /__ NOT __ DEFERRABLE)? (__ INITIALLY __ DEFERRED /__ INITIALLY __ IMMEDIATE)? {
@@ -22,6 +22,7 @@ parser = commands:command* {
22
22
  if (field.inline_refs) {
23
23
  refs.push(...field.inline_refs.map(ref => {
24
24
  return {
25
+ name: ref.name,
25
26
  endpoints: [
26
27
  {
27
28
  tableName: table.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbml/core",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "> TODO: description",
5
5
  "author": "Holistics <dev@holistics.io>",
6
6
  "license": "Apache-2.0",
@@ -56,5 +56,5 @@
56
56
  "\\.(?!json$)[^.]*$": "jest-raw-loader"
57
57
  }
58
58
  },
59
- "gitHead": "4a4ec93db569e677bf15eb53964bd6b26762a421"
59
+ "gitHead": "9cc6f3b75433df2cfc482d305de9f53587e9f22c"
60
60
  }