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,87 +1,60 @@
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.indexMap = void 0;
13
- var print_utils_1 = require("../print_utils");
14
- exports.indexMap = {
15
- create_index_stmt: function (print) {
16
- return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
17
- print.spaced([
18
- "createKw",
19
- "orReplaceKw",
20
- "indexTypeKw",
21
- "indexKw",
22
- "concurrentlyKw",
23
- "ifNotExistsKw",
24
- "name",
25
- "onKw",
26
- "table",
27
- "using",
28
- "columns",
29
- ])
30
- ], print("clauses"), true)));
31
- },
32
- index_specification: function (print) {
33
- return print.spaced(["expr", "opclass", "direction", "nullHandlingKw"]);
34
- },
35
- index_include_clause: function (print) { return print.spaced(["includeKw", "columns"]); },
36
- index_nulls_distinct_clause: function (print) { return print.spaced(["nullsDistinctKw"]); },
37
- index_nulls_not_distinct_clause: function (print) {
38
- return print.spaced(["nullsNotDistinctKw"]);
39
- },
40
- drop_index_stmt: function (print) {
41
- return (0, print_utils_1.group)(print.spaced([
42
- "dropKw",
1
+ import { group, join } from "../print_utils";
2
+ export const indexMap = {
3
+ create_index_stmt: (print) => group(join(print.dynamicLine(), [
4
+ print.spaced([
5
+ "createKw",
6
+ "orReplaceKw",
43
7
  "indexTypeKw",
44
8
  "indexKw",
45
9
  "concurrentlyKw",
46
- "ifExistsKw",
47
- "indexes",
10
+ "ifNotExistsKw",
11
+ "name",
48
12
  "onKw",
49
13
  "table",
50
- "behaviorKw",
51
- ]));
52
- },
53
- verbose_all_columns: function (print) { return print.spaced("allColumnsKw"); },
54
- alter_index_stmt: function (print) {
55
- return (0, print_utils_1.group)([
56
- print.spaced(["alterKw", "indexKw", "ifExistsKw", "index"]),
57
- print.dynamicLine(),
58
- print("action"),
59
- ]);
60
- },
61
- alter_index_all_in_tablespace_stmt: function (print) {
62
- return (0, print_utils_1.group)([
63
- print.spaced([
64
- "alterIndexKw",
65
- "allInTablespaceKw",
66
- "tablespace",
67
- "ownedBy",
68
- ]),
69
- print.dynamicLine(),
70
- print("action"),
71
- ]);
72
- },
73
- reindex_stmt: function (print) {
74
- return (0, print_utils_1.group)(print.spaced([
75
- "reindexKw",
76
- "options",
77
- "targetKw",
78
- "concurrentlyKw",
79
- "name",
80
- ]));
81
- },
82
- reindex_option_concurrently: function (print) {
83
- return print.spaced(["concurrentlyKw", "value"]);
84
- },
85
- reindex_option_tablespace: function (print) { return print.spaced(["tablespaceKw", "name"]); },
86
- reindex_option_verbose: function (print) { return print.spaced(["verboseKw", "value"]); },
14
+ "using",
15
+ "columns",
16
+ ]),
17
+ ...print("clauses"),
18
+ ])),
19
+ index_specification: (print) => print.spaced(["expr", "opclass", "direction", "nullHandlingKw"]),
20
+ index_include_clause: (print) => print.spaced(["includeKw", "columns"]),
21
+ index_nulls_distinct_clause: (print) => print.spaced(["nullsDistinctKw"]),
22
+ index_nulls_not_distinct_clause: (print) => print.spaced(["nullsNotDistinctKw"]),
23
+ drop_index_stmt: (print) => group(print.spaced([
24
+ "dropKw",
25
+ "indexTypeKw",
26
+ "indexKw",
27
+ "concurrentlyKw",
28
+ "ifExistsKw",
29
+ "indexes",
30
+ "onKw",
31
+ "table",
32
+ "behaviorKw",
33
+ ])),
34
+ verbose_all_columns: (print) => print.spaced("allColumnsKw"),
35
+ alter_index_stmt: (print) => group([
36
+ print.spaced(["alterKw", "indexKw", "ifExistsKw", "index"]),
37
+ print.dynamicLine(),
38
+ print("action"),
39
+ ]),
40
+ alter_index_all_in_tablespace_stmt: (print) => group([
41
+ print.spaced([
42
+ "alterIndexKw",
43
+ "allInTablespaceKw",
44
+ "tablespace",
45
+ "ownedBy",
46
+ ]),
47
+ print.dynamicLine(),
48
+ print("action"),
49
+ ]),
50
+ reindex_stmt: (print) => group(print.spaced([
51
+ "reindexKw",
52
+ "options",
53
+ "targetKw",
54
+ "concurrentlyKw",
55
+ "name",
56
+ ])),
57
+ reindex_option_concurrently: (print) => print.spaced(["concurrentlyKw", "value"]),
58
+ reindex_option_tablespace: (print) => print.spaced(["tablespaceKw", "name"]),
59
+ reindex_option_verbose: (print) => print.spaced(["verboseKw", "value"]),
87
60
  };
@@ -1,50 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.insertMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.insertMap = {
6
- insert_stmt: function (print) { return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), print("clauses"))); },
7
- insert_clause: function (print, node) {
8
- return (0, print_utils_1.group)([
9
- print.spaced(["insertKw", "modifiers", "orAction", "intoKw", "table"]),
10
- node.columns ? (0, print_utils_1.indent)([print.dynamicLine(), print("columns")]) : [],
11
- ]);
12
- },
13
- values_clause: function (print) {
14
- return (0, print_utils_1.group)([print("valuesKw"), (0, print_utils_1.indent)([print.dynamicLine(), print("values")])]);
15
- },
16
- or_alternate_action: function (print) { return print.spaced(["orKw", "actionKw"]); },
17
- default: function (print) { return print("defaultKw"); },
18
- default_values: function (print) { return print.spaced("defaultValuesKw"); },
19
- upsert_clause: function (print) {
20
- return print.spaced(["onConflictKw", "conflictTarget", "where", "doKw", "action"]);
21
- },
22
- conflict_target_on_constraint: function (print) {
23
- return print.spaced(["onConstraintKw", "constraint"]);
24
- },
25
- upsert_action_nothing: function (print) { return print("nothingKw"); },
26
- upsert_action_update: function (print) {
27
- return (0, print_utils_1.group)([
28
- print("updateKw"),
29
- (0, print_utils_1.indent)([
30
- print.dynamicLine(),
31
- (0, print_utils_1.join)(print.dynamicLine(), print(["set", "where"])),
32
- ]),
33
- ]);
34
- },
35
- row_alias_clause: function (print, node) {
36
- return (0, print_utils_1.group)([
37
- print.spaced(["asKw", "rowAlias"]),
38
- node.columnAliases
39
- ? (0, print_utils_1.indent)([print.dynamicLine(), print("columnAliases")])
40
- : [],
41
- ]);
42
- },
43
- on_duplicate_key_update_clause: function (print) {
44
- return (0, print_utils_1.group)([
45
- print.spaced("onDuplicateKeyUpdateKw"),
46
- (0, print_utils_1.indent)([print.dynamicLine(), print("assignments")]),
47
- ]);
48
- },
49
- overriding_clause: function (print) { return print.spaced("overridingKw"); },
1
+ import { join, group, indent } from "../print_utils";
2
+ export const insertMap = {
3
+ insert_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
4
+ insert_clause: (print, node) => group([
5
+ print.spaced(["insertKw", "modifiers", "orAction", "intoKw", "table"]),
6
+ node.columns ? indent([print.dynamicLine(), print("columns")]) : [],
7
+ ]),
8
+ values_clause: (print) => group([print("valuesKw"), indent([print.dynamicLine(), print("values")])]),
9
+ or_alternate_action: (print) => print.spaced(["orKw", "actionKw"]),
10
+ default: (print) => print("defaultKw"),
11
+ default_values: (print) => print.spaced("defaultValuesKw"),
12
+ upsert_clause: (print) => print.spaced(["onConflictKw", "conflictTarget", "where", "doKw", "action"]),
13
+ conflict_target_on_constraint: (print) => print.spaced(["onConstraintKw", "constraint"]),
14
+ upsert_action_nothing: (print) => print("nothingKw"),
15
+ upsert_action_update: (print) => group([
16
+ print("updateKw"),
17
+ indent([
18
+ print.dynamicLine(),
19
+ join(print.dynamicLine(), print(["set", "where"])),
20
+ ]),
21
+ ]),
22
+ row_alias_clause: (print, node) => group([
23
+ print.spaced(["asKw", "rowAlias"]),
24
+ node.columnAliases
25
+ ? indent([print.dynamicLine(), print("columnAliases")])
26
+ : [],
27
+ ]),
28
+ on_duplicate_key_update_clause: (print) => group([
29
+ print.spaced("onDuplicateKeyUpdateKw"),
30
+ indent([print.dynamicLine(), print("assignments")]),
31
+ ]),
32
+ overriding_clause: (print) => print.spaced("overridingKw"),
50
33
  };
@@ -1,35 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.mergeMap = {
6
- merge_stmt: function (print) { return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))); },
7
- merge_clause: function (print) {
8
- return (0, print_utils_1.join)(print_utils_1.line, [
9
- print.spaced(["mergeKw", "intoKw", "target"]),
10
- print.spaced(["usingKw", "source"]),
11
- (0, print_utils_1.group)([print("onKw"), (0, print_utils_1.indent)([print_utils_1.line, print("condition")])]),
12
- ]);
13
- },
14
- merge_when_clause: function (print, node) { return [
15
- (0, print_utils_1.group)([
1
+ import { group, hardline, indent, join, line } from "../print_utils";
2
+ export const mergeMap = {
3
+ merge_stmt: (print) => group(join(hardline, print("clauses"))),
4
+ merge_clause: (print) => join(line, [
5
+ print.spaced(["mergeKw", "intoKw", "target"]),
6
+ print.spaced(["usingKw", "source"]),
7
+ group([print("onKw"), indent([line, print("condition")])]),
8
+ ]),
9
+ merge_when_clause: (print, node) => [
10
+ group([
16
11
  print.spaced(["whenKw", "matchedKw", "byKw"]),
17
- node.condition ? (0, print_utils_1.indent)([print_utils_1.line, print("condition")]) : [],
18
- [print_utils_1.line, print("thenKw")],
12
+ node.condition ? indent([line, print("condition")]) : [],
13
+ [line, print("thenKw")],
19
14
  ]),
20
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.group)(print("action"))]),
21
- ]; },
22
- merge_when_condition: function (print) { return print.spaced(["andKw", "expr"]); },
23
- merge_action_delete: function (print) { return print("deleteKw"); },
24
- merge_action_insert: function (print, node) { return [
25
- (0, print_utils_1.group)([
15
+ indent([hardline, group(print("action"))]),
16
+ ],
17
+ merge_when_condition: (print) => print.spaced(["andKw", "expr"]),
18
+ merge_action_delete: (print) => print("deleteKw"),
19
+ merge_action_insert: (print, node) => [
20
+ group([
26
21
  print("insertKw"),
27
- node.columns ? (0, print_utils_1.indent)([print_utils_1.hardline, print("columns")]) : [],
22
+ node.columns ? indent([hardline, print("columns")]) : [],
28
23
  ]),
29
- print_utils_1.line,
30
- (0, print_utils_1.join)(print_utils_1.hardline, print("clauses")),
31
- ]; },
32
- merge_action_insert_row_clause: function (print) { return print("rowKw"); },
33
- merge_action_update: function (print) { return print.spaced(["updateKw", "set"]); },
34
- merge_action_do_nothing: function (print) { return print.spaced(["doNothingKw"]); },
24
+ line,
25
+ join(hardline, print("clauses")),
26
+ ],
27
+ merge_action_insert_row_clause: (print) => print("rowKw"),
28
+ merge_action_update: (print) => print.spaced(["updateKw", "set"]),
29
+ merge_action_do_nothing: (print) => print.spaced(["doNothingKw"]),
35
30
  };
@@ -1,18 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.otherClausesMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.otherClausesMap = {
1
+ import { line, indent, group } from "../print_utils";
2
+ export const otherClausesMap = {
6
3
  // CLUSTER BY clause
7
- cluster_by_clause: function (print) {
8
- return (0, print_utils_1.group)([print.spaced("clusterByKw"), (0, print_utils_1.indent)([print_utils_1.line, print("columns")])]);
9
- },
4
+ cluster_by_clause: (print) => group([print.spaced("clusterByKw"), indent([line, print("columns")])]),
10
5
  // RETURNING clause
11
- returning_clause: function (print) {
12
- return (0, print_utils_1.group)([print("returningKw"), (0, print_utils_1.indent)([print_utils_1.line, print("columns")])]);
13
- },
6
+ returning_clause: (print) => group([print("returningKw"), indent([line, print("columns")])]),
14
7
  // WHERE CURRENT OF clause
15
- where_current_of_clause: function (print) {
16
- return print.spaced(["whereCurrentOfKw", "cursor"]);
17
- },
8
+ where_current_of_clause: (print) => print.spaced(["whereCurrentOfKw", "cursor"]),
18
9
  };
@@ -1,31 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parameterMap = void 0;
4
- var expr_1 = require("./expr");
5
- var print_utils_1 = require("../print_utils");
6
- exports.parameterMap = {
1
+ import { printLiteral } from "./expr";
2
+ import { group } from "../print_utils";
3
+ export const parameterMap = {
7
4
  // SET
8
- set_parameter_stmt: function (print) {
9
- return (0, print_utils_1.group)(print.spaced(["setKw", "modifierKw", "name", "operator", "value"]));
10
- },
11
- set_time_zone_parameter_stmt: function (print) {
12
- return (0, print_utils_1.group)(print.spaced(["setKw", "modifierKw", "timeZoneKw", "value"]));
13
- },
14
- set_parameter_clause: function (print) {
15
- return print.spaced(["setKw", "name", "operator", "value"]);
16
- },
17
- local_parameter_value: function (print) { return print("localKw"); },
18
- set_parameter_from_current_clause: function (print) {
19
- return print.spaced(["setKw", "name", "fromCurrentKw"]);
20
- },
5
+ set_parameter_stmt: (print) => group(print.spaced(["setKw", "modifierKw", "name", "operator", "value"])),
6
+ set_time_zone_parameter_stmt: (print) => group(print.spaced(["setKw", "modifierKw", "timeZoneKw", "value"])),
7
+ set_parameter_clause: (print) => print.spaced(["setKw", "name", "operator", "value"]),
8
+ local_parameter_value: (print) => print("localKw"),
9
+ set_parameter_from_current_clause: (print) => print.spaced(["setKw", "name", "fromCurrentKw"]),
21
10
  // RESET
22
- reset_parameter_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["resetKw", "name"])); },
23
- reset_parameter_clause: function (print) { return print.spaced(["resetKw", "name"]); },
24
- all_parameters: function (print) { return print("allKw"); },
11
+ reset_parameter_stmt: (print) => group(print.spaced(["resetKw", "name"])),
12
+ reset_parameter_clause: (print) => print.spaced(["resetKw", "name"]),
13
+ all_parameters: (print) => print("allKw"),
25
14
  // SHOW
26
- show_parameter_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["showKw", "name"])); },
15
+ show_parameter_stmt: (print) => group(print.spaced(["showKw", "name"])),
27
16
  /** cst-ignore: value */
28
- boolean_on_off_literal: function (print, node, path, options) {
29
- return (0, expr_1.printLiteral)(node.valueKw, options);
30
- },
17
+ boolean_on_off_literal: (print, node, path, options) => printLiteral(node.valueKw, options),
31
18
  };
@@ -1,42 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.policyMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.policyMap = {
6
- create_policy_stmt: function (print, node) {
7
- return (0, print_utils_1.group)([
8
- print.spaced(["createPolicyKw", "name", "onKw", "table"]),
9
- node.clauses.length > 0 ? print.dynamicLine() : [],
10
- (0, print_utils_1.join)(print.dynamicLine(), print("clauses")),
11
- ]);
12
- },
13
- policy_permissive_clause: function (print) {
14
- return (0, print_utils_1.group)(print.spaced(["asKw", "permissiveKw"]));
15
- },
16
- policy_restrictive_clause: function (print) {
17
- return (0, print_utils_1.group)(print.spaced(["asKw", "restrictiveKw"]));
18
- },
19
- policy_command_clause: function (print) { return (0, print_utils_1.group)(print.spaced(["forKw", "commandKw"])); },
20
- policy_roles_clause: function (print) { return (0, print_utils_1.group)(print.spaced(["toKw", "roles"])); },
21
- policy_using_clause: function (print) { return (0, print_utils_1.group)(print.spaced(["usingKw", "expr"])); },
22
- policy_check_clause: function (print) {
23
- return (0, print_utils_1.group)(print.spaced(["withKw", "checkKw", "expr"]));
24
- },
25
- alter_policy_stmt: function (print) {
26
- return (0, print_utils_1.group)([
27
- print.spaced(["alterPolicyKw", "name", "onKw", "table"]),
28
- print.dynamicLine(),
29
- (0, print_utils_1.join)(print.dynamicLine(), print("actions")),
30
- ]);
31
- },
32
- drop_policy_stmt: function (print) {
33
- return (0, print_utils_1.group)(print.spaced([
34
- "dropPolicyKw",
35
- "ifExistsKw",
36
- "name",
37
- "onKw",
38
- "table",
39
- "behaviorKw",
40
- ]));
41
- },
1
+ import { group, join } from "../print_utils";
2
+ export const policyMap = {
3
+ create_policy_stmt: (print, node) => group([
4
+ print.spaced(["createPolicyKw", "name", "onKw", "table"]),
5
+ node.clauses.length > 0 ? print.dynamicLine() : [],
6
+ join(print.dynamicLine(), print("clauses")),
7
+ ]),
8
+ policy_permissive_clause: (print) => group(print.spaced(["asKw", "permissiveKw"])),
9
+ policy_restrictive_clause: (print) => group(print.spaced(["asKw", "restrictiveKw"])),
10
+ policy_command_clause: (print) => group(print.spaced(["forKw", "commandKw"])),
11
+ policy_roles_clause: (print) => group(print.spaced(["toKw", "roles"])),
12
+ policy_using_clause: (print) => group(print.spaced(["usingKw", "expr"])),
13
+ policy_check_clause: (print) => group(print.spaced(["withKw", "checkKw", "expr"])),
14
+ alter_policy_stmt: (print) => group([
15
+ print.spaced(["alterPolicyKw", "name", "onKw", "table"]),
16
+ print.dynamicLine(),
17
+ join(print.dynamicLine(), print("actions")),
18
+ ]),
19
+ drop_policy_stmt: (print) => group(print.spaced([
20
+ "dropPolicyKw",
21
+ "ifExistsKw",
22
+ "name",
23
+ "onKw",
24
+ "table",
25
+ "behaviorKw",
26
+ ])),
42
27
  };
@@ -1,51 +1,31 @@
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.preparedStatementsMap = void 0;
13
- var print_utils_1 = require("../print_utils");
14
- exports.preparedStatementsMap = {
1
+ import { group, hardline, indent, join, line } from "../print_utils";
2
+ export const preparedStatementsMap = {
15
3
  // EXECUTE
16
- execute_stmt: function (print, node) {
17
- var _a;
18
- if (((_a = node.args) === null || _a === void 0 ? void 0 : _a.type) === "execute_using_clause") {
19
- return (0, print_utils_1.group)(print.spaced(["executeKw", "name", "args"]));
4
+ execute_stmt: (print, node) => {
5
+ if (node.args?.type === "execute_using_clause") {
6
+ return group(print.spaced(["executeKw", "name", "args"]));
20
7
  }
21
8
  else {
22
- return (0, print_utils_1.group)([print.spaced(["executeKw", "name"]), print("args")]);
9
+ return group([print.spaced(["executeKw", "name"]), print("args")]);
23
10
  }
24
11
  },
25
- execute_immediate_stmt: function (print) {
26
- return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
27
- (0, print_utils_1.group)([
28
- print.spaced(["executeKw", "immediateKw"]),
29
- (0, print_utils_1.indent)([print_utils_1.line, print("expr")]),
30
- ])
31
- ], print(["into", "using"]).map(function (clause) { return (0, print_utils_1.group)(clause); }), true)));
32
- },
33
- execute_into_clause: function (print) { return print.spaced(["intoKw", "variables"]); },
34
- execute_using_clause: function (print) {
35
- return (0, print_utils_1.group)([print("usingKw"), (0, print_utils_1.indent)([print_utils_1.line, print("values")])]);
36
- },
12
+ execute_immediate_stmt: (print) => group(join(hardline, [
13
+ group([
14
+ print.spaced(["executeKw", "immediateKw"]),
15
+ indent([line, print("expr")]),
16
+ ]),
17
+ ...print(["into", "using"]).map((clause) => group(clause)),
18
+ ])),
19
+ execute_into_clause: (print) => print.spaced(["intoKw", "variables"]),
20
+ execute_using_clause: (print) => group([print("usingKw"), indent([line, print("values")])]),
37
21
  // PREPARE
38
- prepare_stmt: function (print) {
39
- return (0, print_utils_1.group)((0, print_utils_1.join)(" ", [
40
- print("prepareKw"),
41
- print(["name", "params"]),
42
- print("source"),
43
- ]));
44
- },
45
- prepare_from_clause: function (print) {
46
- return (0, print_utils_1.group)([print("fromKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
47
- },
22
+ prepare_stmt: (print) => group(join(" ", [
23
+ print("prepareKw"),
24
+ print(["name", "params"]),
25
+ print("source"),
26
+ ])),
27
+ prepare_from_clause: (print) => group([print("fromKw"), indent([line, print("expr")])]),
48
28
  // DEALLOCATE
49
- deallocate_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["deallocateKw", "name"])); },
50
- deallocate_all: function (print) { return print("allKw"); },
29
+ deallocate_stmt: (print) => group(print.spaced(["deallocateKw", "name"])),
30
+ deallocate_all: (print) => print("allKw"),
51
31
  };
@@ -1,19 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.procClauseMap = void 0;
4
- var node_utils_1 = require("../node_utils");
5
- var print_utils_1 = require("../print_utils");
6
- exports.procClauseMap = {
7
- returns_clause: function (print) { return print.spaced(["returnsKw", "dataType"]); },
8
- determinism_clause: function (print) { return print.spaced("deterministicKw"); },
9
- language_clause: function (print) { return print.spaced(["languageKw", "name"]); },
10
- as_clause: function (print, node) {
11
- if ((0, node_utils_1.isStringLiteral)(node.expr) || (0, node_utils_1.isDynamicallyLoadedFunction)(node.expr)) {
1
+ import { isDynamicallyLoadedFunction, isStringLiteral } from "../node_utils";
2
+ import { hardline, indent } from "../print_utils";
3
+ export const procClauseMap = {
4
+ returns_clause: (print) => print.spaced(["returnsKw", "dataType"]),
5
+ determinism_clause: (print) => print.spaced("deterministicKw"),
6
+ language_clause: (print) => print.spaced(["languageKw", "name"]),
7
+ as_clause: (print, node) => {
8
+ if (isStringLiteral(node.expr) || isDynamicallyLoadedFunction(node.expr)) {
12
9
  return print.spaced(["asKw", "expr"]);
13
10
  }
14
- return [print("asKw"), (0, print_utils_1.indent)([print_utils_1.hardline, print("expr")])];
15
- },
16
- with_connection_clause: function (print) {
17
- return print.spaced(["withConnectionKw", "connection"]);
11
+ return [print("asKw"), indent([hardline, print("expr")])];
18
12
  },
13
+ with_connection_clause: (print) => print.spaced(["withConnectionKw", "connection"]),
19
14
  };