prettier-plugin-sql-cst 0.11.3 → 0.11.5

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.
package/README.md CHANGED
@@ -101,7 +101,7 @@ There are also some SQL-specific options:
101
101
  | API Option | Default | Description |
102
102
  | -------------------- | :-----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
103
  | `sqlKeywordCase` | `upper` | Converts SQL keywords to `upper` or `lower` case, or `preserve` existing. Note that for now `preserve` is somewhat incompatible with `sqlCanonicalSyntax: true` (e.g. the added `AS` keywords will always be in uppercase). |
104
- | `sqlParamTypes` | `[]` | Array of bound parameter types: `?`, `?nr`, `:name`, `@name`, `$name`. |
104
+ | `sqlParamTypes` | `[]` | Array of bound parameter types: `?`, `?nr`, `$nr`, `:name`, `@name`, `$name`. |
105
105
  | `sqlCanonicalSyntax` | `true` | When enabled, performs some opinionated changes of keywords and operators, like enforcing the use of `AS` in aliases and replacing `<>` comparisons with `!=`. See [STYLE_GUIDE][] for more details. (Since 0.11.0) |
106
106
 
107
107
  ## FAQ
package/dist/options.js CHANGED
@@ -32,7 +32,7 @@ exports.options = {
32
32
  default: [{ value: [] }],
33
33
  description: "Syntax for bound parameters",
34
34
  // Since 0.7.0
35
- // Possible values in array: "?" | "?nr" | ":name" | "$name" | "@name"
35
+ // Possible values in array: "?" | "?nr" | "$nr" | ":name" | "$name" | "@name"
36
36
  },
37
37
  sqlCanonicalSyntax: {
38
38
  type: "boolean",
@@ -145,6 +145,7 @@ exports.exprMap = {
145
145
  },
146
146
  typed_expr: function (print) { return print(["dataType", "expr"]); },
147
147
  row_constructor: function (print) { return print(["rowKw", "row"]); },
148
+ array_constructor: function (print) { return print(["arrayKw", "expr"]); },
148
149
  quantifier_expr: function (print) { return print.spaced(["quantifierKw", "expr"]); },
149
150
  full_text_match_expr: function (print) {
150
151
  return print.spaced(["matchKw", "columns", "againstKw", "args"]);
@@ -4,6 +4,7 @@ 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
+ /** cst-ignore: behaviorKw */
7
8
  create_function_stmt: function (print, node) { return [
8
9
  print.spaced([
9
10
  "createKw",
@@ -52,6 +53,20 @@ exports.functionMap = {
52
53
  print.spaced(["params", "behaviorKw"]),
53
54
  ]);
54
55
  },
56
+ // almost exact copy of alter_procedure_stmt
57
+ alter_function_stmt: function (print, node) {
58
+ return (0, print_utils_1.group)([
59
+ print.spaced(["alterKw", "functionKw"]),
60
+ " ",
61
+ print(["name", "params"]),
62
+ print.dynamicLine(),
63
+ (0, print_utils_1.join)(print.dynamicLine(), print("actions")),
64
+ node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : [],
65
+ ]);
66
+ },
67
+ reset_parameter_clause: function (print) { return print.spaced(["resetKw", "name"]); },
68
+ /** cst-ignore: name */
69
+ reset_all_parameters_clause: function (print) { return print.spaced("resetAllKw"); },
55
70
  };
56
71
  var hasOnlyAsClause = function (node) {
57
72
  return node.clauses.length === 1 && (0, node_utils_1.isAsClause)(node.clauses[0]);
@@ -21,4 +21,15 @@ exports.procedureMap = {
21
21
  print.spaced(["params", "behaviorKw"]),
22
22
  ]);
23
23
  },
24
+ // almost exact copy of alter_function_stmt
25
+ alter_procedure_stmt: function (print, node) {
26
+ return (0, print_utils_1.group)([
27
+ print.spaced(["alterKw", "procedureKw"]),
28
+ " ",
29
+ print(["name", "params"]),
30
+ print.dynamicLine(),
31
+ (0, print_utils_1.join)(print.dynamicLine(), print("actions")),
32
+ node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : [],
33
+ ]);
34
+ },
24
35
  };
@@ -13,31 +13,51 @@ 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(__spreadArray([
16
+ return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray(__spreadArray([
17
17
  print.spaced([
18
18
  "createKw",
19
- "temporaryKw",
19
+ "orReplaceKw",
20
+ "kind",
20
21
  "triggerKw",
21
22
  "ifNotExistsKw",
22
23
  "name",
23
24
  ]),
24
- print("event")
25
- ], print.spaced(["forEachRowKw"]), true), print(["condition"]), true), [
25
+ (0, print_utils_1.group)([
26
+ node.timeKw ? [print.spaced("timeKw"), " "] : [],
27
+ print("event"),
28
+ print_utils_1.line,
29
+ print("target"),
30
+ ])
31
+ ], print("clauses"), true), [
26
32
  print("body"),
27
33
  ], false));
28
34
  },
29
- trigger_event: function (print) {
35
+ trigger_event: function (print, node) {
30
36
  return (0, print_utils_1.group)([
31
- print.spaced(["timeKw", "eventKw", "ofKw"]),
32
- (0, print_utils_1.indent)([
33
- print_utils_1.line,
34
- (0, print_utils_1.join)(print_utils_1.line, __spreadArray(__spreadArray([], print(["columns"]), true), [print.spaced(["onKw", "table"])], false)),
35
- ]),
37
+ print.spaced(["eventKw", "ofKw"]),
38
+ node.columns ? (0, print_utils_1.indent)([print_utils_1.line, print("columns")]) : [],
36
39
  ]);
37
40
  },
38
- trigger_condition: function (print) {
41
+ trigger_target: function (print) { return print.spaced(["onKw", "table"]); },
42
+ when_clause: function (print) {
39
43
  return (0, print_utils_1.group)([print("whenKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
40
44
  },
45
+ for_each_clause: function (print) { return print.spaced(["forEachKw", "itemKw"]); },
46
+ execute_clause: function (print) { return [
47
+ print.spaced(["executeKw", "functionKw", "name"]),
48
+ print("args"),
49
+ ]; },
50
+ from_referenced_table_clause: function (print) { return print.spaced(["fromKw", "table"]); },
51
+ trigger_timing_clause: function (print) { return print.spaced(["timingKw"]); },
52
+ trigger_referencing_clause: function (print) {
53
+ return (0, print_utils_1.group)([
54
+ print.spaced(["referencingKw"]),
55
+ (0, print_utils_1.indent)([print_utils_1.line, print("transitions")]),
56
+ ]);
57
+ },
58
+ trigger_transition: function (print) { return [
59
+ print.spaced(["oldOrNewKw", "rowOrTableKw", "asKw", "name"]),
60
+ ]; },
41
61
  drop_trigger_stmt: function (print) {
42
62
  return print.spaced(["dropTriggerKw", "ifExistsKw", "trigger"]);
43
63
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-sql-cst",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "description": "Prettier plugin for SQL",
5
5
  "author": "Rene Saarsoo <nene@triin.net>",
6
6
  "license": "GPL-3.0-or-later",
@@ -33,11 +33,11 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "prettier": "^3.0.3",
36
- "sql-parser-cst": "^0.27.0"
36
+ "sql-parser-cst": "^0.28.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/jest": "^29.2.5",
40
- "chalk": "^4.3.0",
40
+ "chalk": "^4.1.2",
41
41
  "dedent-js": "^1.0.1",
42
42
  "jest": "^29.7.0",
43
43
  "ts-jest": "^29.1.1",