prettier-plugin-sql-cst 0.18.0 → 0.19.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.
Files changed (76) hide show
  1. package/dist/CstToDocMap.d.ts +2 -2
  2. package/dist/CstToDocMap.js +1 -2
  3. package/dist/PrintFn.js +1 -2
  4. package/dist/embed.js +5 -13
  5. package/dist/embedJs.js +28 -84
  6. package/dist/embedJson.js +29 -85
  7. package/dist/embedSql.js +26 -76
  8. package/dist/index.js +28 -34
  9. package/dist/node_utils.d.ts +1 -0
  10. package/dist/node_utils.js +44 -54
  11. package/dist/options.js +1 -4
  12. package/dist/printComment.js +2 -6
  13. package/dist/printSql.js +29 -39
  14. package/dist/print_utils.js +19 -38
  15. package/dist/syntax/alias.js +2 -5
  16. package/dist/syntax/alter_action.js +115 -208
  17. package/dist/syntax/alter_table.js +18 -27
  18. package/dist/syntax/analyze.js +3 -8
  19. package/dist/syntax/base.js +6 -9
  20. package/dist/syntax/cast.js +3 -6
  21. package/dist/syntax/comment.js +53 -122
  22. package/dist/syntax/constraint.d.ts +1 -1
  23. package/dist/syntax/constraint.js +54 -90
  24. package/dist/syntax/create_table.js +49 -87
  25. package/dist/syntax/data_type.js +25 -44
  26. package/dist/syntax/dcl.js +78 -136
  27. package/dist/syntax/delete.js +4 -9
  28. package/dist/syntax/dialects/bigquery.js +70 -116
  29. package/dist/syntax/dialects/mysql.js +2 -5
  30. package/dist/syntax/dialects/postgresql.js +8 -13
  31. package/dist/syntax/dialects/sqlite.js +8 -17
  32. package/dist/syntax/do.js +3 -6
  33. package/dist/syntax/domain.js +10 -19
  34. package/dist/syntax/drop_table.js +10 -15
  35. package/dist/syntax/explain.js +6 -11
  36. package/dist/syntax/expr.js +124 -173
  37. package/dist/syntax/extension.js +12 -21
  38. package/dist/syntax/frame.js +11 -16
  39. package/dist/syntax/function.js +53 -63
  40. package/dist/syntax/index.js +54 -81
  41. package/dist/syntax/insert.js +32 -49
  42. package/dist/syntax/merge.js +25 -30
  43. package/dist/syntax/other_clauses.js +5 -14
  44. package/dist/syntax/parameter.js +13 -26
  45. package/dist/syntax/policy.js +26 -41
  46. package/dist/syntax/prepared_statements.js +23 -43
  47. package/dist/syntax/proc_clause.js +10 -15
  48. package/dist/syntax/procedural_language.js +80 -111
  49. package/dist/syntax/procedure.js +36 -40
  50. package/dist/syntax/program.js +15 -22
  51. package/dist/syntax/publication.js +26 -47
  52. package/dist/syntax/rename_table.js +7 -12
  53. package/dist/syntax/role.js +30 -55
  54. package/dist/syntax/schema.js +17 -35
  55. package/dist/syntax/select.js +157 -226
  56. package/dist/syntax/sequence.js +35 -52
  57. package/dist/syntax/subscription.js +9 -24
  58. package/dist/syntax/transaction.js +18 -33
  59. package/dist/syntax/transformMap.js +99 -63
  60. package/dist/syntax/trigger.js +48 -72
  61. package/dist/syntax/truncate.js +9 -14
  62. package/dist/syntax/type.js +11 -22
  63. package/dist/syntax/unsupported_grammar.js +3 -6
  64. package/dist/syntax/update.js +7 -14
  65. package/dist/syntax/view.js +32 -43
  66. package/dist/transform/addFinalSemicolon.js +5 -9
  67. package/dist/transform/aliasAs.js +4 -8
  68. package/dist/transform/canonicKeywords.js +16 -20
  69. package/dist/transform/canonicOperators.js +8 -12
  70. package/dist/transform/comments.js +10 -31
  71. package/dist/transform/stripTrailingCommas.js +7 -11
  72. package/dist/transform/transformCst.js +13 -17
  73. package/dist/transform/transformUtils.js +2 -6
  74. package/dist/utils.js +9 -30
  75. package/dist/visitAllNodes.js +8 -13
  76. package/package.json +9 -8
@@ -1,293 +1,224 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.selectMap = void 0;
4
- var utils_1 = require("../utils");
5
- var print_utils_1 = require("../print_utils");
6
- exports.selectMap = {
7
- compound_select_stmt: function (print) {
8
- return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, [print("left"), print.spaced("operator"), print("right")]));
9
- },
10
- select_stmt: function (print) { return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), print("clauses"))); },
1
+ import { isDefined } from "../utils";
2
+ import { join, line, hardline, indent, group, containsNewline, breakParent, } from "../print_utils";
3
+ export const selectMap = {
4
+ compound_select_stmt: (print) => group(join(hardline, [print("left"), print.spaced("operator"), print("right")])),
5
+ select_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
11
6
  // WITH clause
12
- with_clause: function (print) {
13
- return (0, print_utils_1.group)([
14
- print.spaced(["withKw", "recursiveKw"]),
15
- (0, print_utils_1.indent)([print_utils_1.line, print("tables")]),
16
- ]);
17
- },
18
- common_table_expr: function (print, node) { return [
7
+ with_clause: (print) => group([
8
+ print.spaced(["withKw", "recursiveKw"]),
9
+ indent([line, print("tables")]),
10
+ ]),
11
+ common_table_expr: (print, node) => [
19
12
  print(["table", "columns"]),
20
13
  " ",
21
14
  print.spaced(["asKw", "materializedKw", "expr"]),
22
- (0, print_utils_1.group)([
15
+ group([
23
16
  node.search || node.cycle
24
- ? (0, print_utils_1.indent)([print_utils_1.line, print.separated(print_utils_1.line, ["search", "cycle"])])
17
+ ? indent([line, print.separated(line, ["search", "cycle"])])
25
18
  : [],
26
19
  ]),
27
- ]; },
28
- cte_search_clause: function (print) {
29
- return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, [
30
- [print.spaced("searchKw"), (0, print_utils_1.group)((0, print_utils_1.indent)([print_utils_1.line, print("columns")]))],
31
- print.spaced(["setKw", "resultColumn"]),
32
- ]));
33
- },
34
- cte_cycle_clause: function (print, node) {
35
- return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, [
36
- [print("cycleKw"), (0, print_utils_1.group)((0, print_utils_1.indent)([print_utils_1.line, print("columns")]))],
37
- print.spaced(["setKw", "resultColumn"]),
38
- node.values ? print("values") : undefined,
39
- print.spaced(["usingKw", "pathColumn"]),
40
- ].filter(utils_1.isDefined)));
41
- },
42
- cte_cycle_clause_values: function (print) {
43
- return (0, print_utils_1.join)(print_utils_1.line, [
44
- print.spaced(["toKw", "markValue"]),
45
- print.spaced(["defaultKw", "defaultValue"]),
46
- ]);
47
- },
20
+ ],
21
+ cte_search_clause: (print) => group(join(line, [
22
+ [print.spaced("searchKw"), group(indent([line, print("columns")]))],
23
+ print.spaced(["setKw", "resultColumn"]),
24
+ ])),
25
+ cte_cycle_clause: (print, node) => group(join(line, [
26
+ [print("cycleKw"), group(indent([line, print("columns")]))],
27
+ print.spaced(["setKw", "resultColumn"]),
28
+ node.values ? print("values") : undefined,
29
+ print.spaced(["usingKw", "pathColumn"]),
30
+ ].filter(isDefined))),
31
+ cte_cycle_clause_values: (print) => join(line, [
32
+ print.spaced(["toKw", "markValue"]),
33
+ print.spaced(["defaultKw", "defaultValue"]),
34
+ ]),
48
35
  // SELECT clause
49
- select_clause: function (print, node, path, opts) {
50
- return (0, print_utils_1.group)([
51
- print.spaced(["selectKw", "modifiers"]),
52
- node.columns ? (0, print_utils_1.indent)([print_utils_1.line, print("columns")]) : [],
53
- (0, print_utils_1.containsNewline)(node, opts) ? print_utils_1.breakParent : [],
54
- ]);
55
- },
56
- select_all: function (print) { return print.spaced(["allKw"]); },
57
- select_distinct: function (print) { return print.spaced(["distinctKw"]); },
58
- select_distinct_on: function (print) {
59
- return (0, print_utils_1.group)([print.spaced(["distinctOnKw", "columns"])]);
60
- },
61
- select_as_struct: function (print) { return print.spaced(["asStructKw"]); },
62
- select_as_value: function (print) { return print.spaced(["asValueKw"]); },
63
- except_columns: function (print) { return print.spaced(["expr", "exceptKw", "columns"]); },
64
- replace_columns: function (print) { return print.spaced(["expr", "replaceKw", "columns"]); },
36
+ select_clause: (print, node, path, opts) => group([
37
+ print.spaced(["selectKw", "modifiers"]),
38
+ node.columns ? indent([line, print("columns")]) : [],
39
+ containsNewline(node, opts) ? breakParent : [],
40
+ ]),
41
+ select_all: (print) => print.spaced(["allKw"]),
42
+ select_distinct: (print) => print.spaced(["distinctKw"]),
43
+ select_distinct_on: (print) => group([print.spaced(["distinctOnKw", "columns"])]),
44
+ select_as_struct: (print) => print.spaced(["asStructKw"]),
45
+ select_as_value: (print) => print.spaced(["asValueKw"]),
46
+ except_columns: (print) => print.spaced(["expr", "exceptKw", "columns"]),
47
+ replace_columns: (print) => print.spaced(["expr", "replaceKw", "columns"]),
65
48
  // FROM clause
66
- from_clause: function (print) {
67
- return (0, print_utils_1.group)([print("fromKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
68
- },
69
- join_expr: function (print, node) {
49
+ from_clause: (print) => group([print("fromKw"), indent([line, print("expr")])]),
50
+ join_expr: (print, node) => {
70
51
  if (node.operator === ",") {
71
- return (0, print_utils_1.join)([",", print_utils_1.hardline], print(["left", "right"]));
52
+ return join([",", hardline], print(["left", "right"]));
72
53
  }
73
54
  else {
74
55
  return [
75
56
  print("left"),
76
- print_utils_1.hardline,
77
- (0, print_utils_1.group)((0, print_utils_1.join)(" ", [
57
+ hardline,
58
+ group(join(" ", [
78
59
  print.spaced("operator"),
79
60
  [
80
61
  print("right"),
81
62
  node.specification
82
- ? (0, print_utils_1.indent)([print_utils_1.line, print(["specification"])])
63
+ ? indent([line, print(["specification"])])
83
64
  : [],
84
65
  ],
85
66
  ])),
86
67
  ];
87
68
  }
88
69
  },
89
- join_on_specification: function (print) { return (0, print_utils_1.group)(print.spaced(["onKw", "expr"])); },
90
- join_using_specification: function (print) { return (0, print_utils_1.group)(print.spaced(["usingKw", "expr"])); },
91
- table_with_inheritance: function (print) { return [print("table"), " ", "*"]; },
92
- table_without_inheritance: function (print) { return print.spaced(["onlyKw", "table"]); },
93
- indexed_table: function (print) { return print.spaced(["table", "indexedByKw", "index"]); },
94
- not_indexed_table: function (print) { return print.spaced(["table", "notIndexedKw"]); },
95
- unnest_expr: function (print) { return print(["unnestKw", "expr"]); },
96
- unnest_with_offset_expr: function (print) { return print.spaced(["unnest", "withOffsetKw"]); },
97
- pivot_expr: function (print) { return [print("left"), print_utils_1.hardline, print(["pivotKw", "args"])]; },
98
- pivot_for_in: function (print) {
99
- return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, [
100
- (0, print_utils_1.group)(print("aggregations")),
101
- print.spaced(["forKw", "inputColumn"]),
102
- print.spaced(["inKw", "pivotColumns"]),
103
- ]));
104
- },
105
- unpivot_expr: function (print, node) { return [
70
+ join_on_specification: (print) => group(print.spaced(["onKw", "expr"])),
71
+ join_using_specification: (print) => group(print.spaced(["usingKw", "expr"])),
72
+ table_with_inheritance: (print) => [print("table"), " ", "*"],
73
+ table_without_inheritance: (print) => print.spaced(["onlyKw", "table"]),
74
+ indexed_table: (print) => print.spaced(["table", "indexedByKw", "index"]),
75
+ not_indexed_table: (print) => print.spaced(["table", "notIndexedKw"]),
76
+ unnest_expr: (print) => print(["unnestKw", "expr"]),
77
+ unnest_with_offset_expr: (print) => print.spaced(["unnest", "withOffsetKw"]),
78
+ pivot_expr: (print) => [print("left"), hardline, print(["pivotKw", "args"])],
79
+ pivot_for_in: (print) => group(join(line, [
80
+ group(print("aggregations")),
81
+ print.spaced(["forKw", "inputColumn"]),
82
+ print.spaced(["inKw", "pivotColumns"]),
83
+ ])),
84
+ unpivot_expr: (print, node) => [
106
85
  print("left"),
107
- print_utils_1.hardline,
86
+ hardline,
108
87
  (node.nullHandlingKw ? print.spaced : print)([
109
88
  "unpivotKw",
110
89
  "nullHandlingKw",
111
90
  "args",
112
91
  ]),
113
- ]; },
114
- unpivot_for_in: function (print) {
115
- return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, [
116
- print("valuesColumn"),
117
- print.spaced(["forKw", "nameColumn"]),
118
- print.spaced(["inKw", "unpivotColumns"]),
119
- ]));
120
- },
121
- tablesample_expr: function (print) {
122
- return (0, print_utils_1.group)([
123
- print("left"),
124
- print_utils_1.line,
125
- print.spaced(["tablesampleKw", "method", "args", "repeatable"]),
126
- ]);
127
- },
128
- tablesample_method: function (print) { return print.spaced(["methodKw"]); },
129
- tablesample_percent: function (print) { return print.spaced(["percent", "percentKw"]); },
130
- tablesample_repeatable: function (print) { return print.spaced(["repeatableKw", "seed"]); },
131
- for_system_time_as_of_expr: function (print) {
132
- return (0, print_utils_1.group)([print("left"), print_utils_1.line, print.spaced(["forSystemTimeAsOfKw", "expr"])]);
133
- },
134
- partitioned_table: function (print) {
135
- return print.spaced(["table", "partitionKw", "partitions"]);
136
- },
137
- dual_table: function (print) { return print("dualKw"); },
138
- lateral_derived_table: function (print) { return print.spaced(["lateralKw", "expr"]); },
139
- rows_from_expr: function (print) { return print.spaced(["rowsFromKw", "expr"]); },
140
- with_ordinality_expr: function (print) { return print.spaced(["expr", "withOrdinalityKw"]); },
141
- func_call_with_column_definitions: function (print) {
142
- return print.spaced(["funcCall", "asKw", "columns"]);
143
- },
92
+ ],
93
+ unpivot_for_in: (print) => group(join(line, [
94
+ print("valuesColumn"),
95
+ print.spaced(["forKw", "nameColumn"]),
96
+ print.spaced(["inKw", "unpivotColumns"]),
97
+ ])),
98
+ tablesample_expr: (print) => group([
99
+ print("left"),
100
+ line,
101
+ print.spaced(["tablesampleKw", "method", "args", "repeatable"]),
102
+ ]),
103
+ tablesample_method: (print) => print.spaced(["methodKw"]),
104
+ tablesample_percent: (print) => print.spaced(["percent", "percentKw"]),
105
+ tablesample_repeatable: (print) => print.spaced(["repeatableKw", "seed"]),
106
+ for_system_time_as_of_expr: (print) => group([print("left"), line, print.spaced(["forSystemTimeAsOfKw", "expr"])]),
107
+ partitioned_table: (print) => print.spaced(["table", "partitionKw", "partitions"]),
108
+ dual_table: (print) => print("dualKw"),
109
+ lateral_derived_table: (print) => print.spaced(["lateralKw", "expr"]),
110
+ rows_from_expr: (print) => print.spaced(["rowsFromKw", "expr"]),
111
+ with_ordinality_expr: (print) => print.spaced(["expr", "withOrdinalityKw"]),
112
+ func_call_with_column_definitions: (print) => print.spaced(["funcCall", "asKw", "columns"]),
144
113
  // WHERE clause
145
- where_clause: function (print) {
146
- return (0, print_utils_1.group)([print("whereKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
147
- },
114
+ where_clause: (print) => group([print("whereKw"), indent([line, print("expr")])]),
148
115
  // ORDER BY clause
149
- order_by_clause: function (print, node) {
150
- return (0, print_utils_1.group)([
151
- print.spaced("orderByKw"),
152
- (0, print_utils_1.indent)([print_utils_1.line, print.separated(print_utils_1.line, ["specifications", "withRollupKw"])]),
153
- ]);
154
- },
155
- sort_specification: function (print) {
156
- return print.spaced(["expr", "direction", "nullHandlingKw"]);
157
- },
158
- sort_direction_asc: function (print) { return print("ascKw"); },
159
- sort_direction_desc: function (print) { return print("descKw"); },
160
- sort_direction_using_operator: function (print) {
161
- return print.spaced(["usingKw", "operator"]);
162
- },
116
+ order_by_clause: (print, node) => group([
117
+ print.spaced("orderByKw"),
118
+ indent([line, print.separated(line, ["specifications", "withRollupKw"])]),
119
+ ]),
120
+ sort_specification: (print) => print.spaced(["expr", "direction", "nullHandlingKw"]),
121
+ sort_direction_asc: (print) => print("ascKw"),
122
+ sort_direction_desc: (print) => print("descKw"),
123
+ sort_direction_using_operator: (print) => print.spaced(["usingKw", "operator"]),
163
124
  // GROUP BY clause
164
- group_by_clause: function (print, node) {
165
- return (0, print_utils_1.group)([
166
- print.spaced(["groupByKw", "distinctKw"]),
167
- (0, print_utils_1.indent)([print_utils_1.line, print.separated(print_utils_1.line, ["columns", "withRollupKw"])]),
168
- ]);
169
- },
170
- group_by_rollup: function (print) { return print(["rollupKw", "columns"]); },
171
- group_by_cube: function (print) { return print(["cubeKw", "columns"]); },
172
- group_by_grouping_sets: function (print) {
173
- return print.spaced(["groupingSetsKw", "columns"]);
174
- },
175
- group_by_all: function (print) { return print(["allKw"]); },
125
+ group_by_clause: (print, node) => group([
126
+ print.spaced(["groupByKw", "distinctKw"]),
127
+ indent([line, print.separated(line, ["columns", "withRollupKw"])]),
128
+ ]),
129
+ group_by_rollup: (print) => print(["rollupKw", "columns"]),
130
+ group_by_cube: (print) => print(["cubeKw", "columns"]),
131
+ group_by_grouping_sets: (print) => print.spaced(["groupingSetsKw", "columns"]),
132
+ group_by_all: (print) => print(["allKw"]),
176
133
  // PARTITION BY clause
177
- partition_by_clause: function (print) {
178
- return (0, print_utils_1.group)([
179
- print.spaced("partitionByKw"),
180
- (0, print_utils_1.indent)([print_utils_1.line, print("specifications")]),
181
- ]);
182
- },
134
+ partition_by_clause: (print) => group([
135
+ print.spaced("partitionByKw"),
136
+ indent([line, print("specifications")]),
137
+ ]),
183
138
  // HAVING clause
184
- having_clause: function (print) {
185
- return (0, print_utils_1.group)([print("havingKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
186
- },
139
+ having_clause: (print) => group([print("havingKw"), indent([line, print("expr")])]),
187
140
  // QUALIFY clause
188
- qualify_clause: function (print) {
189
- return (0, print_utils_1.group)([print("qualifyKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
190
- },
141
+ qualify_clause: (print) => group([print("qualifyKw"), indent([line, print("expr")])]),
191
142
  // LIMIT clause
192
143
  /** cst-ignore: count, offsetKw, offset */
193
- limit_clause: function (print, node) {
194
- return (0, print_utils_1.group)([
195
- print("limitKw"),
196
- (0, print_utils_1.indent)([
197
- print_utils_1.line,
198
- printLimitValues(print, node),
199
- node.rowsExamined ? [print_utils_1.line, print("rowsExamined")] : [],
200
- ]),
201
- ]);
202
- },
203
- limit_all: function (print) { return print("allKw"); },
204
- limit_rows_examined: function (print) { return print.spaced(["rowsExaminedKw", "count"]); },
144
+ limit_clause: (print, node) => group([
145
+ print("limitKw"),
146
+ indent([
147
+ line,
148
+ printLimitValues(print, node),
149
+ node.rowsExamined ? [line, print("rowsExamined")] : [],
150
+ ]),
151
+ ]),
152
+ limit_all: (print) => print("allKw"),
153
+ limit_rows_examined: (print) => print.spaced(["rowsExaminedKw", "count"]),
205
154
  // OFFSET clause
206
- offset_clause: function (print) {
207
- return (0, print_utils_1.group)([
208
- print("offsetKw"),
209
- (0, print_utils_1.indent)([print_utils_1.line, print.spaced(["offset", "rowsKw"])]),
210
- ]);
211
- },
155
+ offset_clause: (print) => group([
156
+ print("offsetKw"),
157
+ indent([line, print.spaced(["offset", "rowsKw"])]),
158
+ ]),
212
159
  // FETCH clause
213
- fetch_clause: function (print) {
214
- return print.spaced(["fetchKw", "count", "rowsKw", "withTiesKw"]);
215
- },
160
+ fetch_clause: (print) => print.spaced(["fetchKw", "count", "rowsKw", "withTiesKw"]),
216
161
  // WINDOW clause
217
- window_clause: function (print, node) {
218
- var lineType = node.namedWindows.items.length > 1 ? print_utils_1.hardline : print_utils_1.line;
219
- return (0, print_utils_1.group)([
162
+ window_clause: (print, node) => {
163
+ const lineType = node.namedWindows.items.length > 1 ? hardline : line;
164
+ return group([
220
165
  print("windowKw"),
221
- (0, print_utils_1.indent)([lineType, print("namedWindows")]),
166
+ indent([lineType, print("namedWindows")]),
222
167
  ]);
223
168
  },
224
- named_window: function (print) { return print.spaced(["name", "asKw", "window"]); },
225
- window_definition: function (print, node) {
226
- var itemCount = [
169
+ named_window: (print) => print.spaced(["name", "asKw", "window"]),
170
+ window_definition: (print, node) => {
171
+ const itemCount = [
227
172
  node.baseWindowName,
228
173
  node.partitionBy,
229
174
  node.orderBy,
230
175
  node.frame,
231
- ].filter(utils_1.isDefined).length;
232
- var lineType = itemCount > 1 ? print_utils_1.hardline : print_utils_1.line;
233
- return (0, print_utils_1.group)((0, print_utils_1.join)(lineType, print(["baseWindowName", "partitionBy", "orderBy", "frame"])));
176
+ ].filter(isDefined).length;
177
+ const lineType = itemCount > 1 ? hardline : line;
178
+ return group(join(lineType, print(["baseWindowName", "partitionBy", "orderBy", "frame"])));
234
179
  },
235
180
  // INTO clause
236
- into_table_clause: function (print) {
237
- return print.spaced(["intoKw", "kind", "tableKw", "name"]);
238
- },
239
- into_variables_clause: function (print) {
240
- return (0, print_utils_1.group)([print("intoKw"), (0, print_utils_1.indent)([print_utils_1.line, print("variables")])]);
241
- },
242
- into_dumpfile_clause: function (print) { return print.spaced(["intoDumpfileKw", "filename"]); },
243
- into_outfile_clause: function (print, node) {
244
- var hasOptions = node.charset || node.fields || node.lines;
245
- return (0, print_utils_1.group)([
181
+ into_table_clause: (print) => print.spaced(["intoKw", "kind", "tableKw", "name"]),
182
+ into_variables_clause: (print) => group([print("intoKw"), indent([line, print("variables")])]),
183
+ into_dumpfile_clause: (print) => print.spaced(["intoDumpfileKw", "filename"]),
184
+ into_outfile_clause: (print, node) => {
185
+ const hasOptions = node.charset || node.fields || node.lines;
186
+ return group([
246
187
  print.spaced(["intoOutfileKw", "filename"]),
247
188
  hasOptions
248
- ? (0, print_utils_1.indent)([
249
- print_utils_1.hardline,
250
- (0, print_utils_1.join)(print_utils_1.hardline, print(["charset", "fields", "lines"])),
189
+ ? indent([
190
+ hardline,
191
+ join(hardline, print(["charset", "fields", "lines"])),
251
192
  ])
252
193
  : [],
253
194
  ]);
254
195
  },
255
- outfile_fields: function (print) { return print.spaced(["fieldsKw", "options"]); },
256
- outfile_lines: function (print) { return print.spaced(["linesKw", "options"]); },
257
- outfile_option_character_set: function (print) {
258
- return print.spaced(["characterSetKw", "value"]);
259
- },
260
- outfile_option_starting_by: function (print) {
261
- return print.spaced(["startingByKw", "value"]);
262
- },
263
- outfile_option_terminated_by: function (print) {
264
- return print.spaced(["terminatedByKw", "value"]);
265
- },
266
- outfile_option_enclosed_by: function (print) {
267
- return print.spaced(["optionallyKw", "enclosedByKw", "value"]);
268
- },
269
- outfile_option_escaped_by: function (print) { return print.spaced(["escapedByKw", "value"]); },
196
+ outfile_fields: (print) => print.spaced(["fieldsKw", "options"]),
197
+ outfile_lines: (print) => print.spaced(["linesKw", "options"]),
198
+ outfile_option_character_set: (print) => print.spaced(["characterSetKw", "value"]),
199
+ outfile_option_starting_by: (print) => print.spaced(["startingByKw", "value"]),
200
+ outfile_option_terminated_by: (print) => print.spaced(["terminatedByKw", "value"]),
201
+ outfile_option_enclosed_by: (print) => print.spaced(["optionallyKw", "enclosedByKw", "value"]),
202
+ outfile_option_escaped_by: (print) => print.spaced(["escapedByKw", "value"]),
270
203
  // FOR clause (locking)
271
- for_clause: function (print, node) {
272
- return (0, print_utils_1.group)([
273
- print.spaced(["forKw", "lockStrengthKw", "tables"]),
274
- node.waitingKw ? (0, print_utils_1.indent)([print_utils_1.line, print.spaced("waitingKw")]) : [],
275
- ]);
276
- },
277
- for_clause_tables: function (print) { return [
204
+ for_clause: (print, node) => group([
205
+ print.spaced(["forKw", "lockStrengthKw", "tables"]),
206
+ node.waitingKw ? indent([line, print.spaced("waitingKw")]) : [],
207
+ ]),
208
+ for_clause_tables: (print) => [
278
209
  print("ofKw"),
279
- (0, print_utils_1.indent)([print_utils_1.line, print("tables")]),
280
- ]; },
281
- lock_in_share_mode_clause: function (print) { return print.spaced("lockInShareModeKw"); },
210
+ indent([line, print("tables")]),
211
+ ],
212
+ lock_in_share_mode_clause: (print) => print.spaced("lockInShareModeKw"),
282
213
  // TABLE clause
283
- table_clause: function (print) { return print.spaced(["tableKw", "table"]); },
214
+ table_clause: (print) => print.spaced(["tableKw", "table"]),
284
215
  };
285
- var printLimitValues = function (print, node) {
216
+ const printLimitValues = (print, node) => {
286
217
  if (node.offsetKw) {
287
218
  return print.spaced(["count", "offsetKw", "offset"]);
288
219
  }
289
220
  else if (node.offset) {
290
- return (0, print_utils_1.join)([",", " "], print(["offset", "count"]));
221
+ return join([",", " "], print(["offset", "count"]));
291
222
  }
292
223
  else {
293
224
  return print("count");
@@ -1,53 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sequenceMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.sequenceMap = {
6
- create_sequence_stmt: function (print, node) {
7
- return (0, print_utils_1.group)([
8
- print.spaced(["createKw", "kind", "sequenceKw", "ifNotExistsKw", "name"]),
9
- node.options.length > 0
10
- ? (0, print_utils_1.indent)([print.dynamicLine(), (0, print_utils_1.join)(print_utils_1.line, print("options"))])
11
- : [],
12
- ]);
13
- },
14
- alter_sequence_stmt: function (print) {
15
- return (0, print_utils_1.group)([
16
- print.spaced(["alterKw", "sequenceKw", "ifExistsKw", "sequence"]),
17
- (0, print_utils_1.indent)([print.dynamicLine(), (0, print_utils_1.join)(print_utils_1.line, print("actions"))]),
18
- ]);
19
- },
20
- drop_sequence_stmt: function (print) {
21
- return (0, print_utils_1.group)(print.spaced([
22
- "dropKw",
23
- "sequenceKw",
24
- "ifExistsKw",
25
- "sequences",
26
- "behaviorKw",
27
- ]));
28
- },
29
- sequence_option_sequence_name: function (print) {
30
- return print.spaced(["sequenceNameKw", "name"]);
31
- },
32
- sequence_option_logged: function (print) { return print.spaced("loggedKw"); },
33
- sequence_option_unlogged: function (print) { return print.spaced("unloggedKw"); },
34
- sequence_option_as_type: function (print) { return print.spaced(["asKw", "dataType"]); },
35
- sequence_option_increment: function (print) {
36
- return print.spaced(["incrementKw", "byKw", "value"]);
37
- },
38
- sequence_option_minvalue: function (print) { return print.spaced(["minvalueKw", "value"]); },
39
- sequence_option_maxvalue: function (print) { return print.spaced(["maxvalueKw", "value"]); },
40
- sequence_option_no_minvalue: function (print) { return print.spaced("noMinvalueKw"); },
41
- sequence_option_no_maxvalue: function (print) { return print.spaced("noMaxvalueKw"); },
42
- sequence_option_start: function (print) {
43
- return print.spaced(["startKw", "withKw", "value"]);
44
- },
45
- sequence_option_restart: function (print) {
46
- return print.spaced(["restartKw", "withKw", "value"]);
47
- },
48
- sequence_option_cache: function (print) { return print.spaced(["cacheKw", "value"]); },
49
- sequence_option_cycle: function (print) { return print.spaced("cycleKw"); },
50
- sequence_option_no_cycle: function (print) { return print.spaced("noCycleKw"); },
51
- sequence_option_owned_by: function (print) { return print.spaced(["ownedByKw", "owner"]); },
52
- sequence_option_list: function (print) { return (0, print_utils_1.join)(print_utils_1.line, print("options")); },
1
+ import { group, indent, join, line } from "../print_utils";
2
+ export const sequenceMap = {
3
+ create_sequence_stmt: (print, node) => group([
4
+ print.spaced(["createKw", "kind", "sequenceKw", "ifNotExistsKw", "name"]),
5
+ node.options.length > 0
6
+ ? indent([print.dynamicLine(), join(line, print("options"))])
7
+ : [],
8
+ ]),
9
+ alter_sequence_stmt: (print) => group([
10
+ print.spaced(["alterKw", "sequenceKw", "ifExistsKw", "sequence"]),
11
+ indent([print.dynamicLine(), join(line, print("actions"))]),
12
+ ]),
13
+ drop_sequence_stmt: (print) => group(print.spaced([
14
+ "dropKw",
15
+ "sequenceKw",
16
+ "ifExistsKw",
17
+ "sequences",
18
+ "behaviorKw",
19
+ ])),
20
+ sequence_option_sequence_name: (print) => print.spaced(["sequenceNameKw", "name"]),
21
+ sequence_option_logged: (print) => print.spaced("loggedKw"),
22
+ sequence_option_unlogged: (print) => print.spaced("unloggedKw"),
23
+ sequence_option_as_type: (print) => print.spaced(["asKw", "dataType"]),
24
+ sequence_option_increment: (print) => print.spaced(["incrementKw", "byKw", "value"]),
25
+ sequence_option_minvalue: (print) => print.spaced(["minvalueKw", "value"]),
26
+ sequence_option_maxvalue: (print) => print.spaced(["maxvalueKw", "value"]),
27
+ sequence_option_no_minvalue: (print) => print.spaced("noMinvalueKw"),
28
+ sequence_option_no_maxvalue: (print) => print.spaced("noMaxvalueKw"),
29
+ sequence_option_start: (print) => print.spaced(["startKw", "withKw", "value"]),
30
+ sequence_option_restart: (print) => print.spaced(["restartKw", "withKw", "value"]),
31
+ sequence_option_cache: (print) => print.spaced(["cacheKw", "value"]),
32
+ sequence_option_cycle: (print) => print.spaced("cycleKw"),
33
+ sequence_option_no_cycle: (print) => print.spaced("noCycleKw"),
34
+ sequence_option_owned_by: (print) => print.spaced(["ownedByKw", "owner"]),
35
+ sequence_option_list: (print) => join(line, print("options")),
53
36
  };
@@ -1,25 +1,10 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.subscriptionMap = void 0;
13
- var print_utils_1 = require("../print_utils");
14
- exports.subscriptionMap = {
15
- create_subscription_stmt: function (print, node) {
16
- return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, __spreadArray([
17
- print.spaced(["createSubscriptionKw", "name"]),
18
- print.spaced(["connectionKw", "connectionInfo"]),
19
- print.spaced(["publicationKw", "publications"])
20
- ], (node.with ? [print.spaced(["with"])] : []), true)));
21
- },
22
- drop_subscription_stmt: function (print) {
23
- return (0, print_utils_1.group)(print.spaced(["dropSubscriptionKw", "ifExistsKw", "name", "behaviorKw"]));
24
- },
1
+ import { group, line, join } from "../print_utils";
2
+ export const subscriptionMap = {
3
+ create_subscription_stmt: (print, node) => group(join(line, [
4
+ print.spaced(["createSubscriptionKw", "name"]),
5
+ print.spaced(["connectionKw", "connectionInfo"]),
6
+ print.spaced(["publicationKw", "publications"]),
7
+ ...(node.with ? [print.spaced(["with"])] : []),
8
+ ])),
9
+ drop_subscription_stmt: (print) => group(print.spaced(["dropSubscriptionKw", "ifExistsKw", "name", "behaviorKw"])),
25
10
  };