prettier-plugin-sql-cst 0.15.0 → 0.17.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.
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dropTableMap = void 0;
4
+ var print_utils_1 = require("../print_utils");
4
5
  exports.dropTableMap = {
5
6
  drop_table_stmt: function (print) {
6
- return print.spaced([
7
+ return (0, print_utils_1.group)(print.spaced([
7
8
  "dropKw",
8
9
  "kind",
9
10
  "tableKw",
10
11
  "ifExistsKw",
11
12
  "tables",
12
13
  "behaviorKw",
13
- ]);
14
+ ]));
14
15
  },
15
16
  };
@@ -1,5 +1,5 @@
1
1
  import { AllExprNodes, Keyword } from "sql-parser-cst";
2
2
  import { CstToDocMap } from "../CstToDocMap";
3
- import { AllPrettierOptions } from "src/options";
3
+ import { AllPrettierOptions } from "../options";
4
4
  export declare const exprMap: CstToDocMap<AllExprNodes>;
5
5
  export declare const printLiteral: <T>(node: Keyword, options: AllPrettierOptions<T>) => string;
@@ -182,10 +182,26 @@ exports.exprMap = {
182
182
  json_literal: function (print) { return print.spaced(["jsonKw", "string"]); },
183
183
  jsonb_literal: function (print) { return print.spaced(["jsonbKw", "string"]); },
184
184
  /** cst-ignore: name */
185
- identifier: function (print) { return print("text"); },
185
+ identifier: function (print, node, path, options) {
186
+ if (isQuotedIdentifier(node) || isInsideBigqueryQuotedMemberExpr(path)) {
187
+ return print("text");
188
+ }
189
+ else {
190
+ if (isFunctionName(node, path)) {
191
+ return printFunctionName(node, options);
192
+ }
193
+ else {
194
+ return printIdentifier(node, options);
195
+ }
196
+ }
197
+ },
186
198
  /** cst-ignore: name */
187
- variable: function (print) { return print("text"); },
188
- parameter: function (print) { return print("text"); },
199
+ variable: function (print, node, path, options) {
200
+ return isQuotedVariable(node) ? print("text") : printIdentifier(node, options);
201
+ },
202
+ parameter: function (print, node, path, options) {
203
+ return isQuotedParameter(node) ? print("text") : printIdentifier(node, options);
204
+ },
189
205
  };
190
206
  var printLiteral = function (node, options) {
191
207
  switch (options.sqlLiteralCase) {
@@ -198,6 +214,59 @@ var printLiteral = function (node, options) {
198
214
  }
199
215
  };
200
216
  exports.printLiteral = printLiteral;
217
+ var printIdentifier = function (node, options) {
218
+ switch (options.sqlIdentifierCase) {
219
+ case "preserve":
220
+ return node.text;
221
+ case "upper":
222
+ return node.text.toUpperCase();
223
+ case "lower":
224
+ return node.text.toLowerCase();
225
+ }
226
+ };
227
+ var printFunctionName = function (node, options) {
228
+ switch (options.sqlFunctionCase) {
229
+ case "preserve":
230
+ return node.text;
231
+ case "upper":
232
+ return node.text.toUpperCase();
233
+ case "lower":
234
+ return node.text.toLowerCase();
235
+ }
236
+ };
237
+ var isQuotedIdentifier = function (node) {
238
+ return node.name !== node.text;
239
+ };
240
+ var isQuotedVariable = function (node) {
241
+ return !(node.text === "@" + node.name || node.text === "@@" + node.name);
242
+ };
243
+ var isQuotedParameter = function (node) { return /`$/.test(node.text); };
244
+ var isInsideBigqueryQuotedMemberExpr = function (path) {
245
+ return path.ancestors.some(node_utils_1.isBigqueryQuotedMemberExpr);
246
+ };
247
+ var isFunctionName = function (node, path) {
248
+ var parent = path.parent;
249
+ if (isFunctionContext(parent, path.grandparent)) {
250
+ return true;
251
+ }
252
+ if ((0, node_utils_1.isMemberExpr)(parent) && parent.property === node) {
253
+ var _a = path.ancestors, _ = _a[0], gp = _a[1], ggp = _a[2];
254
+ return isFunctionContext(gp, ggp);
255
+ }
256
+ return false;
257
+ };
258
+ var isFunctionContext = function (node, parent) {
259
+ return ((0, node_utils_1.isFuncCall)(node) ||
260
+ (0, node_utils_1.isCreateFunctionStmt)(node) ||
261
+ (0, node_utils_1.isCreateProcedureStmt)(node) ||
262
+ (0, node_utils_1.isAlterFunctionStmt)(node) ||
263
+ (0, node_utils_1.isAlterProcedureStmt)(node) ||
264
+ ((0, node_utils_1.isAlterActionRename)(node) &&
265
+ ((0, node_utils_1.isAlterFunctionStmt)(parent) || (0, node_utils_1.isAlterProcedureStmt)(parent))) ||
266
+ (0, node_utils_1.isDropFunctionStmt)(node) ||
267
+ (0, node_utils_1.isDropProcedureStmt)(node) ||
268
+ ((0, node_utils_1.isExecuteClause)(node) && (0, node_utils_1.isCreateTriggerStmt)(parent)));
269
+ };
201
270
  var isBooleanOp = function (_a) {
202
271
  var name = _a.name;
203
272
  return name === "AND" || name === "OR";
@@ -1,3 +1,4 @@
1
- import { AllFunctionNodes } from "sql-parser-cst";
1
+ import { AllFunctionNodes, CreateFunctionStmt, CreateProcedureStmt } from "sql-parser-cst";
2
2
  import { CstToDocMap } from "../CstToDocMap";
3
3
  export declare const functionMap: CstToDocMap<AllFunctionNodes>;
4
+ export declare const hasOnlyAsClause: (node: CreateFunctionStmt | CreateProcedureStmt) => boolean;
@@ -1,27 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.functionMap = void 0;
3
+ exports.hasOnlyAsClause = exports.functionMap = void 0;
4
4
  var print_utils_1 = require("../print_utils");
5
5
  var node_utils_1 = require("../node_utils");
6
6
  exports.functionMap = {
7
- create_function_stmt: function (print, node) { return [
8
- print.spaced([
9
- "createKw",
10
- "orReplaceKw",
11
- "temporaryKw",
12
- "tableKw",
13
- "functionKw",
14
- "ifNotExistsKw",
15
- "name",
16
- ]),
17
- print("params"),
18
- hasOnlyAsClause(node)
19
- ? [" ", (0, print_utils_1.group)(print("clauses"))]
20
- : [
21
- print_utils_1.hardline,
22
- (0, print_utils_1.join)(print_utils_1.hardline, print("clauses").map(function (cls) { return (0, print_utils_1.group)(cls); })),
23
- ],
24
- ]; },
7
+ create_function_stmt: function (print, node) {
8
+ return (0, print_utils_1.group)([
9
+ print.spaced([
10
+ "createKw",
11
+ "orReplaceKw",
12
+ "temporaryKw",
13
+ "tableKw",
14
+ "functionKw",
15
+ "ifNotExistsKw",
16
+ "name",
17
+ ]),
18
+ print("params"),
19
+ (0, exports.hasOnlyAsClause)(node)
20
+ ? [" ", (0, print_utils_1.group)(print("clauses"))]
21
+ : [
22
+ print_utils_1.hardline,
23
+ (0, print_utils_1.join)(print_utils_1.hardline, print("clauses").map(function (cls) { return (0, print_utils_1.group)(cls); })),
24
+ ],
25
+ ]);
26
+ },
25
27
  function_signature: function (print) { return print(["name", "params"]); },
26
28
  function_param: function (print) {
27
29
  return print.spaced(["mode", "name", "dataType", "default"]);
@@ -59,6 +61,5 @@ exports.functionMap = {
59
61
  ]);
60
62
  },
61
63
  };
62
- var hasOnlyAsClause = function (node) {
63
- return node.clauses.length === 1 && (0, node_utils_1.isAsClause)(node.clauses[0]);
64
- };
64
+ var hasOnlyAsClause = function (node) { return node.clauses.length === 1 && (0, node_utils_1.isAsClause)(node.clauses[0]); };
65
+ exports.hasOnlyAsClause = hasOnlyAsClause;
@@ -71,13 +71,13 @@ exports.indexMap = {
71
71
  ]);
72
72
  },
73
73
  reindex_stmt: function (print) {
74
- return print.spaced([
74
+ return (0, print_utils_1.group)(print.spaced([
75
75
  "reindexKw",
76
76
  "options",
77
77
  "targetKw",
78
78
  "concurrentlyKw",
79
79
  "name",
80
- ]);
80
+ ]));
81
81
  },
82
82
  reindex_option_concurrently: function (print) {
83
83
  return print.spaced(["concurrentlyKw", "value"]);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeMap = void 0;
4
4
  var print_utils_1 = require("../print_utils");
5
5
  exports.mergeMap = {
6
- merge_stmt: function (print) { return (0, print_utils_1.join)(print_utils_1.line, print("clauses")); },
6
+ merge_stmt: function (print) { return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))); },
7
7
  merge_clause: function (print) {
8
8
  return (0, print_utils_1.join)(print_utils_1.line, [
9
9
  print.spaced(["mergeKw", "intoKw", "target"]),
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parameterMap = void 0;
4
4
  var expr_1 = require("./expr");
5
+ var print_utils_1 = require("../print_utils");
5
6
  exports.parameterMap = {
6
7
  // SET
7
8
  set_parameter_stmt: function (print) {
8
- return print.spaced(["setKw", "modifierKw", "name", "operator", "value"]);
9
+ return (0, print_utils_1.group)(print.spaced(["setKw", "modifierKw", "name", "operator", "value"]));
9
10
  },
10
11
  set_time_zone_parameter_stmt: function (print) {
11
- return print.spaced(["setKw", "modifierKw", "timeZoneKw", "value"]);
12
+ return (0, print_utils_1.group)(print.spaced(["setKw", "modifierKw", "timeZoneKw", "value"]));
12
13
  },
13
14
  set_parameter_clause: function (print) {
14
15
  return print.spaced(["setKw", "name", "operator", "value"]);
@@ -18,11 +19,11 @@ exports.parameterMap = {
18
19
  return print.spaced(["setKw", "name", "fromCurrentKw"]);
19
20
  },
20
21
  // RESET
21
- reset_parameter_stmt: function (print) { return print.spaced(["resetKw", "name"]); },
22
+ reset_parameter_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["resetKw", "name"])); },
22
23
  reset_parameter_clause: function (print) { return print.spaced(["resetKw", "name"]); },
23
24
  all_parameters: function (print) { return print("allKw"); },
24
25
  // SHOW
25
- show_parameter_stmt: function (print) { return print.spaced(["showKw", "name"]); },
26
+ show_parameter_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["showKw", "name"])); },
26
27
  /** cst-ignore: value */
27
28
  boolean_on_off_literal: function (print, node, path, options) {
28
29
  return (0, expr_1.printLiteral)(node.valueKw, options);
@@ -23,12 +23,12 @@ exports.preparedStatementsMap = {
23
23
  }
24
24
  },
25
25
  execute_immediate_stmt: function (print) {
26
- return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
26
+ return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
27
27
  (0, print_utils_1.group)([
28
28
  print.spaced(["executeKw", "immediateKw"]),
29
29
  (0, print_utils_1.indent)([print_utils_1.line, print("expr")]),
30
30
  ])
31
- ], print(["into", "using"]).map(function (clause) { return (0, print_utils_1.group)(clause); }), true));
31
+ ], print(["into", "using"]).map(function (clause) { return (0, print_utils_1.group)(clause); }), true)));
32
32
  },
33
33
  execute_into_clause: function (print) { return print.spaced(["intoKw", "variables"]); },
34
34
  execute_using_clause: function (print) {
@@ -46,6 +46,6 @@ exports.preparedStatementsMap = {
46
46
  return (0, print_utils_1.group)([print("fromKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
47
47
  },
48
48
  // DEALLOCATE
49
- deallocate_stmt: function (print) { return print.spaced(["deallocateKw", "name"]); },
49
+ deallocate_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["deallocateKw", "name"])); },
50
50
  deallocate_all: function (print) { return print("allKw"); },
51
51
  };
@@ -13,31 +13,35 @@ exports.proceduralLanguageMap = void 0;
13
13
  var print_utils_1 = require("../print_utils");
14
14
  exports.proceduralLanguageMap = {
15
15
  // BEGIN .. END
16
- block_stmt: function (print, node) { return [
17
- print.spaced(["beginKw", "atomicKw"]),
18
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
19
- node.exception ? [print_utils_1.hardline, print("exception")] : [],
20
- print_utils_1.hardline,
21
- print("endKw"),
22
- ]; },
23
- exception_clause: function (print) { return [
24
- print.spaced(["exceptionKw", "whenKw", "condition", "thenKw"]),
25
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
26
- ]; },
16
+ block_stmt: function (print, node) {
17
+ return (0, print_utils_1.group)([
18
+ print.spaced(["beginKw", "atomicKw"]),
19
+ (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
20
+ node.exception ? [print_utils_1.hardline, print("exception")] : [],
21
+ print_utils_1.hardline,
22
+ print("endKw"),
23
+ ]);
24
+ },
25
+ exception_clause: function (print) {
26
+ return (0, print_utils_1.group)([
27
+ print.spaced(["exceptionKw", "whenKw", "condition", "thenKw"]),
28
+ (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
29
+ ]);
30
+ },
27
31
  error_category: function (print) { return print("errorKw"); },
28
32
  // DECLARE
29
33
  declare_stmt: function (print) {
30
- return (0, print_utils_1.join)(" ", __spreadArray([
34
+ return (0, print_utils_1.group)((0, print_utils_1.join)(" ", __spreadArray([
31
35
  print("declareKw"),
32
36
  (0, print_utils_1.group)(print("names"))
33
- ], print.spaced(["dataType", "default"]), true));
37
+ ], print.spaced(["dataType", "default"]), true)));
34
38
  },
35
39
  declare_default: function (print) { return print.spaced(["defaultKw", "expr"]); },
36
40
  // SET
37
- set_stmt: function (print) { return print.spaced(["setKw", "assignments"]); },
41
+ set_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["setKw", "assignments"])); },
38
42
  // IF
39
43
  if_stmt: function (print) {
40
- return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray(__spreadArray([], print("clauses"), true), [print.spaced("endIfKw")], false));
44
+ return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, __spreadArray(__spreadArray([], print("clauses"), true), [print.spaced("endIfKw")], false)));
41
45
  },
42
46
  if_clause: function (print) { return [
43
47
  (0, print_utils_1.group)([
@@ -62,55 +66,67 @@ exports.proceduralLanguageMap = {
62
66
  (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("consequent"))]),
63
67
  ]; },
64
68
  // CASE
65
- case_stmt: function (print) { return [
66
- print.spaced(["caseKw", "expr"]),
67
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))]),
68
- print_utils_1.hardline,
69
- print.spaced("endCaseKw"),
70
- ]; },
69
+ case_stmt: function (print) {
70
+ return (0, print_utils_1.group)([
71
+ print.spaced(["caseKw", "expr"]),
72
+ (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))]),
73
+ print_utils_1.hardline,
74
+ print.spaced("endCaseKw"),
75
+ ]);
76
+ },
71
77
  // LOOP
72
- loop_stmt: function (print) { return [
73
- print("loopKw"),
74
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
75
- print_utils_1.hardline,
76
- print.spaced("endLoopKw"),
77
- ]; },
78
+ loop_stmt: function (print) {
79
+ return (0, print_utils_1.group)([
80
+ print("loopKw"),
81
+ (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
82
+ print_utils_1.hardline,
83
+ print.spaced("endLoopKw"),
84
+ ]);
85
+ },
78
86
  // REPEAT
79
- repeat_stmt: function (print) { return [
80
- print("repeatKw"),
81
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
82
- print_utils_1.hardline,
83
- print.spaced(["untilKw", "condition", "endRepeatKw"]),
84
- ]; },
87
+ repeat_stmt: function (print) {
88
+ return (0, print_utils_1.group)([
89
+ print("repeatKw"),
90
+ (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
91
+ print_utils_1.hardline,
92
+ print.spaced(["untilKw", "condition", "endRepeatKw"]),
93
+ ]);
94
+ },
85
95
  // WHILE
86
- while_stmt: function (print) { return [
87
- print.spaced(["whileKw", "condition", "doKw"]),
88
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
89
- print_utils_1.hardline,
90
- print.spaced("endWhileKw"),
91
- ]; },
96
+ while_stmt: function (print) {
97
+ return (0, print_utils_1.group)([
98
+ print.spaced(["whileKw", "condition", "doKw"]),
99
+ (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
100
+ print_utils_1.hardline,
101
+ print.spaced("endWhileKw"),
102
+ ]);
103
+ },
92
104
  // FOR .. IN
93
- for_stmt: function (print) { return [
94
- print.spaced(["forKw", "left", "inKw", "right", "doKw"]),
95
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
96
- print_utils_1.hardline,
97
- print.spaced("endForKw"),
98
- ]; },
105
+ for_stmt: function (print) {
106
+ return (0, print_utils_1.group)([
107
+ print.spaced(["forKw", "left", "inKw", "right", "doKw"]),
108
+ (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
109
+ print_utils_1.hardline,
110
+ print.spaced("endForKw"),
111
+ ]);
112
+ },
99
113
  // BREAK/CONTINUE
100
- break_stmt: function (print) { return print.spaced(["breakKw", "label"]); },
101
- continue_stmt: function (print) { return print.spaced(["continueKw", "label"]); },
102
- labeled_stmt: function (print, node) { return [
103
- print("beginLabel"),
104
- ": ",
105
- print("statement"),
106
- node.endLabel ? [" ", print(["endLabel"])] : [],
107
- ]; },
114
+ break_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["breakKw", "label"])); },
115
+ continue_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["continueKw", "label"])); },
116
+ labeled_stmt: function (print, node) {
117
+ return (0, print_utils_1.group)([
118
+ print("beginLabel"),
119
+ ": ",
120
+ print("statement"),
121
+ node.endLabel ? [" ", print(["endLabel"])] : [],
122
+ ]);
123
+ },
108
124
  // CALL
109
- call_stmt: function (print) { return print.spaced(["callKw", "func"]); },
125
+ call_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["callKw", "func"])); },
110
126
  // RETURN
111
- return_stmt: function (print) { return print.spaced(["returnKw", "expr"]); },
127
+ return_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["returnKw", "expr"])); },
112
128
  // RAISE
113
- raise_stmt: function (print) { return print.spaced(["raiseKw", "message"]); },
129
+ raise_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["raiseKw", "message"])); },
114
130
  raise_message: function (print) { return [
115
131
  print.spaced("usingMessageKw"),
116
132
  " = ",
@@ -2,19 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.procedureMap = void 0;
4
4
  var print_utils_1 = require("../print_utils");
5
+ var function_1 = require("./function");
5
6
  exports.procedureMap = {
6
- create_procedure_stmt: function (print, node) { return [
7
- print.spaced([
8
- "createKw",
9
- "orReplaceKw",
10
- "procedureKw",
11
- "ifNotExistsKw",
12
- "name",
13
- ]),
14
- print("params"),
15
- print_utils_1.hardline,
16
- (0, print_utils_1.join)(print_utils_1.hardline, print("clauses").map(function (clause) { return (0, print_utils_1.group)(clause); })),
17
- ]; },
7
+ create_procedure_stmt: function (print, node) {
8
+ return (0, print_utils_1.group)([
9
+ print.spaced([
10
+ "createKw",
11
+ "orReplaceKw",
12
+ "procedureKw",
13
+ "ifNotExistsKw",
14
+ "name",
15
+ ]),
16
+ print("params"),
17
+ (0, function_1.hasOnlyAsClause)(node)
18
+ ? [" ", (0, print_utils_1.group)(print("clauses"))]
19
+ : [
20
+ print_utils_1.hardline,
21
+ (0, print_utils_1.join)(print_utils_1.hardline, print("clauses").map(function (clause) { return (0, print_utils_1.group)(clause); })),
22
+ ],
23
+ ]);
24
+ },
18
25
  drop_procedure_stmt: function (print) {
19
26
  return (0, print_utils_1.group)([
20
27
  print.spaced(["dropKw", "procedureKw", "ifExistsKw", "name"]),
@@ -26,7 +26,7 @@ exports.schemaMap = {
26
26
  return print.spaced(["authorizationKw", "role"]);
27
27
  },
28
28
  drop_schema_stmt: function (print) {
29
- return print.spaced(["dropSchemaKw", "ifExistsKw", "schemas", "behaviorKw"]);
29
+ return (0, print_utils_1.group)(print.spaced(["dropSchemaKw", "ifExistsKw", "schemas", "behaviorKw"]));
30
30
  },
31
31
  alter_schema_stmt: function (print) {
32
32
  return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
@@ -5,7 +5,7 @@ var utils_1 = require("../utils");
5
5
  var print_utils_1 = require("../print_utils");
6
6
  exports.selectMap = {
7
7
  compound_select_stmt: function (print) {
8
- return (0, print_utils_1.join)(print_utils_1.hardline, [print("left"), print.spaced("operator"), print("right")]);
8
+ return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, [print("left"), print.spaced("operator"), print("right")]));
9
9
  },
10
10
  select_stmt: function (print) { return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), print("clauses"))); },
11
11
  // WITH clause
@@ -10,17 +10,17 @@ exports.transactionMap = {
10
10
  ]);
11
11
  },
12
12
  commit_transaction_stmt: function (print) {
13
- return print.spaced(["commitKw", "transactionKw", "chain"]);
13
+ return (0, print_utils_1.group)(print.spaced(["commitKw", "transactionKw", "chain"]));
14
14
  },
15
15
  rollback_transaction_stmt: function (print) {
16
- return print.spaced(["rollbackKw", "transactionKw", "savepoint", "chain"]);
16
+ return (0, print_utils_1.group)(print.spaced(["rollbackKw", "transactionKw", "savepoint", "chain"]));
17
17
  },
18
18
  rollback_to_savepoint: function (print) {
19
19
  return print.spaced(["toKw", "savepointKw", "savepoint"]);
20
20
  },
21
- savepoint_stmt: function (print) { return print.spaced(["savepointKw", "savepoint"]); },
21
+ savepoint_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["savepointKw", "savepoint"])); },
22
22
  release_savepoint_stmt: function (print) {
23
- return print.spaced(["releaseKw", "savepointKw", "savepoint"]);
23
+ return (0, print_utils_1.group)(print.spaced(["releaseKw", "savepointKw", "savepoint"]));
24
24
  },
25
25
  transaction_chain_clause: function (print) { return print.spaced("andChainKw"); },
26
26
  transaction_no_chain_clause: function (print) { return print.spaced("andNoChainKw"); },
@@ -13,7 +13,7 @@ exports.triggerMap = void 0;
13
13
  var print_utils_1 = require("../print_utils");
14
14
  exports.triggerMap = {
15
15
  create_trigger_stmt: function (print, node) {
16
- return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray(__spreadArray([
16
+ return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, __spreadArray(__spreadArray([
17
17
  print.spaced([
18
18
  "createKw",
19
19
  "orReplaceKw",
@@ -30,7 +30,7 @@ exports.triggerMap = {
30
30
  ])
31
31
  ], print("clauses"), true), [
32
32
  print("body"),
33
- ], false));
33
+ ], false)));
34
34
  },
35
35
  trigger_event: function (print, node) {
36
36
  return (0, print_utils_1.group)([
@@ -65,12 +65,12 @@ exports.triggerMap = {
65
65
  ]));
66
66
  },
67
67
  drop_trigger_stmt: function (print) {
68
- return print.spaced([
68
+ return (0, print_utils_1.group)(print.spaced([
69
69
  "dropTriggerKw",
70
70
  "ifExistsKw",
71
71
  "trigger",
72
72
  "target",
73
73
  "behaviorKw",
74
- ]);
74
+ ]));
75
75
  },
76
76
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.unsupportedGrammarMap = void 0;
4
+ var print_utils_1 = require("../print_utils");
4
5
  exports.unsupportedGrammarMap = {
5
- unsupported_grammar_stmt: function (print) { return print("text"); },
6
+ unsupported_grammar_stmt: function (print) { return (0, print_utils_1.group)(print("text")); },
6
7
  };
@@ -6,7 +6,7 @@ exports.viewMap = {
6
6
  create_view_stmt: function (print, node) {
7
7
  var hasOnlyAsClause = node.clauses.length === 1;
8
8
  var hasManyClauses = node.clauses.length > 1;
9
- return [
9
+ return (0, print_utils_1.group)([
10
10
  print.spaced([
11
11
  "createKw",
12
12
  "orReplaceKw",
@@ -18,7 +18,7 @@ exports.viewMap = {
18
18
  ]),
19
19
  hasOnlyAsClause ? [" ", print("clauses")] : [],
20
20
  hasManyClauses ? [print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))] : [],
21
- ];
21
+ ]);
22
22
  },
23
23
  with_check_option_clause: function (print) {
24
24
  return print.spaced(["withKw", "levelKw", "checkOptionKw"]);
@@ -34,18 +34,20 @@ exports.viewMap = {
34
34
  "behaviorKw",
35
35
  ]));
36
36
  },
37
- alter_view_stmt: function (print) { return [
38
- print.spaced([
39
- "alterKw",
40
- "kind",
41
- "viewKw",
42
- "ifExistsKw",
43
- "name",
44
- "columns",
45
- ]),
46
- print_utils_1.hardline,
47
- print("actions"),
48
- ]; },
37
+ alter_view_stmt: function (print) {
38
+ return (0, print_utils_1.group)([
39
+ print.spaced([
40
+ "alterKw",
41
+ "kind",
42
+ "viewKw",
43
+ "ifExistsKw",
44
+ "name",
45
+ "columns",
46
+ ]),
47
+ print_utils_1.hardline,
48
+ print("actions"),
49
+ ]);
50
+ },
49
51
  refresh_materialized_view_stmt: function (print, node) {
50
52
  return (0, print_utils_1.group)([
51
53
  print.spaced(["refreshMaterializedViewKw", "concurrentlyKw", "name"]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-sql-cst",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Prettier plugin for SQL",
5
5
  "contributors": [
6
6
  "Barna Magyarkuti <bmagyarkuti@gmail.com>",
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "prettier": "^3.0.3",
40
- "sql-parser-cst": "^0.36.0"
40
+ "sql-parser-cst": "^0.37.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/jest": "^29.2.5",