@dbml/core 2.4.3 → 2.4.4

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
 
@@ -190,7 +190,7 @@ UniqueSyntax
190
190
  // "KEY is normally a synonym for INDEX".
191
191
  IndexInLineSyntax = _ unique:index_in_line
192
192
  _ name:name? _ type1:index_type? _
193
- "(" _ columns:IndexColumnValues _")" IndexOption? type2:index_type?
193
+ "(" _ columns:IndexColumnValues _")" type2:(_ IndexOption)?
194
194
  {
195
195
  const index = { columns };
196
196
  if(name) {
@@ -199,9 +199,8 @@ IndexInLineSyntax = _ unique:index_in_line
199
199
  if(unique) {
200
200
  index.unique = true;
201
201
  }
202
- const type = type2 || type1;
203
- if(type)
204
- index.type = type;
202
+ if(type2 && type2[1] && type2[1].type === 'index_type' && type2[1].value ) index.type = type2[1].value;
203
+ else if(type1) index.type = type1;
205
204
  return index;
206
205
  }
207
206
  index_in_line // keyword
@@ -257,6 +256,7 @@ FieldSetting "field setting"
257
256
  ) { return "not_supported" }
258
257
  / _ v:Default {return {type: "default", value: v} }
259
258
  / _ v:Comment { return {type: "comment", value: v }}
259
+ / _ "ON"i _ "UPDATE"i _ type { return "not_supported" }
260
260
 
261
261
  // Default: Support "DEFAULT (value|expr)" syntax
262
262
  Default
@@ -357,8 +357,7 @@ function peg$parse(input, options) {
357
357
  index.unique = true;
358
358
  }
359
359
 
360
- var type = type2 || type1;
361
- if (type) index.type = type;
360
+ if (type2 && type2[1] && type2[1].type === 'index_type' && type2[1].value) index.type = type2[1].value;else if (type1) index.type = type1;
362
361
  return index;
363
362
  },
364
363
  peg$c30 = "index",
@@ -2428,7 +2427,7 @@ function peg$parse(input, options) {
2428
2427
  }
2429
2428
 
2430
2429
  function peg$parseIndexInLineSyntax() {
2431
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14;
2430
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15;
2432
2431
  s0 = peg$currPos;
2433
2432
  s1 = peg$parse_();
2434
2433
 
@@ -2492,27 +2491,32 @@ function peg$parse(input, options) {
2492
2491
  }
2493
2492
 
2494
2493
  if (s12 !== peg$FAILED) {
2495
- s13 = peg$parseIndexOption();
2494
+ s13 = peg$currPos;
2495
+ s14 = peg$parse_();
2496
+
2497
+ if (s14 !== peg$FAILED) {
2498
+ s15 = peg$parseIndexOption();
2499
+
2500
+ if (s15 !== peg$FAILED) {
2501
+ s14 = [s14, s15];
2502
+ s13 = s14;
2503
+ } else {
2504
+ peg$currPos = s13;
2505
+ s13 = peg$FAILED;
2506
+ }
2507
+ } else {
2508
+ peg$currPos = s13;
2509
+ s13 = peg$FAILED;
2510
+ }
2496
2511
 
2497
2512
  if (s13 === peg$FAILED) {
2498
2513
  s13 = null;
2499
2514
  }
2500
2515
 
2501
2516
  if (s13 !== peg$FAILED) {
2502
- s14 = peg$parseindex_type();
2503
-
2504
- if (s14 === peg$FAILED) {
2505
- s14 = null;
2506
- }
2507
-
2508
- if (s14 !== peg$FAILED) {
2509
- peg$savedPos = s0;
2510
- s1 = peg$c29(s2, s4, s6, s10, s14);
2511
- s0 = s1;
2512
- } else {
2513
- peg$currPos = s0;
2514
- s0 = peg$FAILED;
2515
- }
2517
+ peg$savedPos = s0;
2518
+ s1 = peg$c29(s2, s4, s6, s10, s13);
2519
+ s0 = s1;
2516
2520
  } else {
2517
2521
  peg$currPos = s0;
2518
2522
  s0 = peg$FAILED;
@@ -3689,6 +3693,73 @@ function peg$parse(input, options) {
3689
3693
  peg$currPos = s0;
3690
3694
  s0 = peg$FAILED;
3691
3695
  }
3696
+
3697
+ if (s0 === peg$FAILED) {
3698
+ s0 = peg$currPos;
3699
+ s1 = peg$parse_();
3700
+
3701
+ if (s1 !== peg$FAILED) {
3702
+ if (input.substr(peg$currPos, 2).toLowerCase() === peg$c17) {
3703
+ s2 = input.substr(peg$currPos, 2);
3704
+ peg$currPos += 2;
3705
+ } else {
3706
+ s2 = peg$FAILED;
3707
+
3708
+ if (peg$silentFails === 0) {
3709
+ peg$fail(peg$c18);
3710
+ }
3711
+ }
3712
+
3713
+ if (s2 !== peg$FAILED) {
3714
+ s3 = peg$parse_();
3715
+
3716
+ if (s3 !== peg$FAILED) {
3717
+ if (input.substr(peg$currPos, 6).toLowerCase() === peg$c19) {
3718
+ s4 = input.substr(peg$currPos, 6);
3719
+ peg$currPos += 6;
3720
+ } else {
3721
+ s4 = peg$FAILED;
3722
+
3723
+ if (peg$silentFails === 0) {
3724
+ peg$fail(peg$c20);
3725
+ }
3726
+ }
3727
+
3728
+ if (s4 !== peg$FAILED) {
3729
+ s5 = peg$parse_();
3730
+
3731
+ if (s5 !== peg$FAILED) {
3732
+ s6 = peg$parsetype();
3733
+
3734
+ if (s6 !== peg$FAILED) {
3735
+ peg$savedPos = s0;
3736
+ s1 = peg$c79();
3737
+ s0 = s1;
3738
+ } else {
3739
+ peg$currPos = s0;
3740
+ s0 = peg$FAILED;
3741
+ }
3742
+ } else {
3743
+ peg$currPos = s0;
3744
+ s0 = peg$FAILED;
3745
+ }
3746
+ } else {
3747
+ peg$currPos = s0;
3748
+ s0 = peg$FAILED;
3749
+ }
3750
+ } else {
3751
+ peg$currPos = s0;
3752
+ s0 = peg$FAILED;
3753
+ }
3754
+ } else {
3755
+ peg$currPos = s0;
3756
+ s0 = peg$FAILED;
3757
+ }
3758
+ } else {
3759
+ peg$currPos = s0;
3760
+ s0 = peg$FAILED;
3761
+ }
3762
+ }
3692
3763
  }
3693
3764
  }
3694
3765
  }