prettier-plugin-sql-cst 0.13.0 → 0.14.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.
- package/README.md +3 -1
- package/dist/options.d.ts +1 -0
- package/dist/options.js +23 -0
- package/dist/syntax/cast.d.ts +3 -0
- package/dist/syntax/cast.js +7 -0
- package/dist/syntax/comment.d.ts +3 -0
- package/dist/syntax/comment.js +123 -0
- package/dist/syntax/dcl.js +34 -0
- package/dist/syntax/dialects/postgresql.js +4 -1
- package/dist/syntax/do.d.ts +3 -0
- package/dist/syntax/do.js +6 -0
- package/dist/syntax/expr.d.ts +3 -1
- package/dist/syntax/expr.js +18 -3
- package/dist/syntax/extension.d.ts +3 -0
- package/dist/syntax/extension.js +22 -0
- package/dist/syntax/function.js +0 -8
- package/dist/syntax/parameter.d.ts +3 -0
- package/dist/syntax/parameter.js +30 -0
- package/dist/syntax/prepared_statements.js +28 -2
- package/dist/syntax/publication.d.ts +3 -0
- package/dist/syntax/publication.js +48 -0
- package/dist/syntax/sequence.js +5 -0
- package/dist/syntax/subscription.d.ts +3 -0
- package/dist/syntax/subscription.js +25 -0
- package/dist/syntax/transformMap.js +8 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -121,9 +121,11 @@ There are also some SQL-specific options:
|
|
|
121
121
|
|
|
122
122
|
| API Option | Default | Description |
|
|
123
123
|
| ----------------------------- | :-----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
124
|
-
| `sqlKeywordCase` | `upper` |
|
|
124
|
+
| `sqlKeywordCase` | `upper` | Convert 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). |
|
|
125
|
+
| `sqlLiteralCase` | `upper` | Convert SQL literals TRUE, FALSE and NULL to `upper` or `lower` case, or `preserve` existing. Also applies to `on` & `off` literals in PostgreSQL SET statements. |
|
|
125
126
|
| `sqlParamTypes` | `[]` | Array of bound parameter types: `?`, `?nr`, `$nr`, `:name`, `@name`, `$name`. |
|
|
126
127
|
| `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) |
|
|
128
|
+
| `sqlFinalSemicolon` | `true` | When enabled, enforces a semicolon at the end of last statement. When disabled leaves it up to the author whether to add a final semicolon or not. (Since 0.13.0) |
|
|
127
129
|
| `sqlAcceptUnsupportedGrammar` | `false` | Normally when the plugin encounters SQL syntax it doesn't support it will throw an error and won't format anything at all. With this option enabled, it will skip over SQL statements it doesn't recognize, leaving them as-is. |
|
|
128
130
|
|
|
129
131
|
## Usage inside VSCode
|
package/dist/options.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ParserOptions, SupportOptions } from "prettier";
|
|
|
2
2
|
import { Node, ParserOptions as CstParserOptions } from "sql-parser-cst";
|
|
3
3
|
export interface SqlPluginOptions {
|
|
4
4
|
sqlKeywordCase: "preserve" | "upper" | "lower";
|
|
5
|
+
sqlLiteralCase: "preserve" | "upper" | "lower";
|
|
5
6
|
sqlParamTypes: NonNullable<CstParserOptions["paramTypes"]>;
|
|
6
7
|
sqlCanonicalSyntax: boolean;
|
|
7
8
|
sqlFinalSemicolon: boolean;
|
package/dist/options.js
CHANGED
|
@@ -25,6 +25,29 @@ exports.options = {
|
|
|
25
25
|
},
|
|
26
26
|
],
|
|
27
27
|
},
|
|
28
|
+
sqlLiteralCase: {
|
|
29
|
+
type: "choice",
|
|
30
|
+
category: "SQL",
|
|
31
|
+
default: "upper",
|
|
32
|
+
description: "Enforces upper/lower case for SQL literals (TRUE, FALSE, NULL)",
|
|
33
|
+
choices: [
|
|
34
|
+
{
|
|
35
|
+
value: "preserve",
|
|
36
|
+
description: "preserves the existing case",
|
|
37
|
+
since: "0.14.0",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: "upper",
|
|
41
|
+
description: "forces all keywords to uppercase",
|
|
42
|
+
since: "0.14.0",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
value: "lower",
|
|
46
|
+
description: "forces all keywords to lowercase",
|
|
47
|
+
since: "0.14.0",
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
28
51
|
sqlParamTypes: {
|
|
29
52
|
type: "string",
|
|
30
53
|
array: true,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.castMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.castMap = {
|
|
6
|
+
cast_definition: function (print) { return (0, print_utils_1.group)(print.spaced(["from", "asKw", "to"])); },
|
|
7
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commentMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.commentMap = {
|
|
6
|
+
comment_stmt: function (print) {
|
|
7
|
+
return (0, print_utils_1.group)([
|
|
8
|
+
print.spaced(["commentKw", "onKw", "target", "isKw"]),
|
|
9
|
+
(0, print_utils_1.indent)([print_utils_1.line, print("message")]),
|
|
10
|
+
]);
|
|
11
|
+
},
|
|
12
|
+
comment_target_aggregate: function (print) {
|
|
13
|
+
return (0, print_utils_1.group)([print.spaced(["aggregateKw", "name"]), print(["params"])]);
|
|
14
|
+
},
|
|
15
|
+
comment_target_function: function (print) {
|
|
16
|
+
return (0, print_utils_1.group)([print.spaced(["functionKw", "name"]), print(["params"])]);
|
|
17
|
+
},
|
|
18
|
+
comment_target_procedure: function (print) {
|
|
19
|
+
return (0, print_utils_1.group)([print.spaced(["procedureKw", "name"]), print(["params"])]);
|
|
20
|
+
},
|
|
21
|
+
comment_target_routine: function (print) {
|
|
22
|
+
return (0, print_utils_1.group)([print.spaced(["routineKw", "name"]), print(["params"])]);
|
|
23
|
+
},
|
|
24
|
+
comment_target_access_method: function (print) {
|
|
25
|
+
return (0, print_utils_1.group)(print.spaced(["accessMethodKw", "name"]));
|
|
26
|
+
},
|
|
27
|
+
comment_target_cast: function (print) { return (0, print_utils_1.group)(print.spaced(["castKw", "args"])); },
|
|
28
|
+
comment_target_collation: function (print) {
|
|
29
|
+
return (0, print_utils_1.group)(print.spaced(["collationKw", "name"]));
|
|
30
|
+
},
|
|
31
|
+
comment_target_column: function (print) { return (0, print_utils_1.group)(print.spaced(["columnKw", "name"])); },
|
|
32
|
+
comment_target_table_constraint: function (print) {
|
|
33
|
+
return (0, print_utils_1.group)(print.spaced(["constraintKw", "name", "onKw", "tableName"]));
|
|
34
|
+
},
|
|
35
|
+
comment_target_domain_constraint: function (print) {
|
|
36
|
+
return (0, print_utils_1.group)(print.spaced(["constraintKw", "name", "onKw", "domainKw", "domainName"]));
|
|
37
|
+
},
|
|
38
|
+
comment_target_conversion: function (print) {
|
|
39
|
+
return (0, print_utils_1.group)(print.spaced(["conversionKw", "name"]));
|
|
40
|
+
},
|
|
41
|
+
comment_target_database: function (print) {
|
|
42
|
+
return (0, print_utils_1.group)(print.spaced(["databaseKw", "name"]));
|
|
43
|
+
},
|
|
44
|
+
comment_target_domain: function (print) { return (0, print_utils_1.group)(print.spaced(["domainKw", "name"])); },
|
|
45
|
+
comment_target_extension: function (print) {
|
|
46
|
+
return (0, print_utils_1.group)(print.spaced(["extensionKw", "name"]));
|
|
47
|
+
},
|
|
48
|
+
comment_target_event_trigger: function (print) {
|
|
49
|
+
return (0, print_utils_1.group)(print.spaced(["eventTriggerKw", "name"]));
|
|
50
|
+
},
|
|
51
|
+
comment_target_foreign_data_wrapper: function (print) {
|
|
52
|
+
return (0, print_utils_1.group)(print.spaced(["foreignDataWrapperKw", "name"]));
|
|
53
|
+
},
|
|
54
|
+
comment_target_foreign_table: function (print) {
|
|
55
|
+
return (0, print_utils_1.group)(print.spaced(["foreignTableKw", "name"]));
|
|
56
|
+
},
|
|
57
|
+
comment_target_index: function (print) { return (0, print_utils_1.group)(print.spaced(["indexKw", "name"])); },
|
|
58
|
+
comment_target_language: function (print) {
|
|
59
|
+
return (0, print_utils_1.group)(print.spaced(["languageKw", "name"]));
|
|
60
|
+
},
|
|
61
|
+
comment_target_large_object: function (print) {
|
|
62
|
+
return (0, print_utils_1.group)(print.spaced(["largeObjectKw", "oid"]));
|
|
63
|
+
},
|
|
64
|
+
comment_target_materialized_view: function (print) {
|
|
65
|
+
return (0, print_utils_1.group)(print.spaced(["materializedViewKw", "name"]));
|
|
66
|
+
},
|
|
67
|
+
comment_target_operator_class: function (print) {
|
|
68
|
+
return (0, print_utils_1.group)(print.spaced(["operatorClassKw", "name", "usingKw", "methodName"]));
|
|
69
|
+
},
|
|
70
|
+
comment_target_operator_family: function (print) {
|
|
71
|
+
return (0, print_utils_1.group)(print.spaced(["operatorFamilyKw", "name", "usingKw", "methodName"]));
|
|
72
|
+
},
|
|
73
|
+
comment_target_policy: function (print) {
|
|
74
|
+
return (0, print_utils_1.group)(print.spaced(["policyKw", "name", "onKw", "tableName"]));
|
|
75
|
+
},
|
|
76
|
+
comment_target_publication: function (print) {
|
|
77
|
+
return (0, print_utils_1.group)(print.spaced(["publicationKw", "name"]));
|
|
78
|
+
},
|
|
79
|
+
comment_target_role: function (print) { return (0, print_utils_1.group)(print.spaced(["roleKw", "name"])); },
|
|
80
|
+
comment_target_rule: function (print) {
|
|
81
|
+
return (0, print_utils_1.group)(print.spaced(["ruleKw", "name", "onKw", "tableName"]));
|
|
82
|
+
},
|
|
83
|
+
comment_target_schema: function (print) { return (0, print_utils_1.group)(print.spaced(["schemaKw", "name"])); },
|
|
84
|
+
comment_target_sequence: function (print) {
|
|
85
|
+
return (0, print_utils_1.group)(print.spaced(["sequenceKw", "name"]));
|
|
86
|
+
},
|
|
87
|
+
comment_target_server: function (print) { return (0, print_utils_1.group)(print.spaced(["serverKw", "name"])); },
|
|
88
|
+
comment_target_statistics: function (print) {
|
|
89
|
+
return (0, print_utils_1.group)(print.spaced(["statisticsKw", "name"]));
|
|
90
|
+
},
|
|
91
|
+
comment_target_subscription: function (print) {
|
|
92
|
+
return (0, print_utils_1.group)(print.spaced(["subscriptionKw", "name"]));
|
|
93
|
+
},
|
|
94
|
+
comment_target_table: function (print) { return (0, print_utils_1.group)(print.spaced(["tableKw", "name"])); },
|
|
95
|
+
comment_target_tablespace: function (print) {
|
|
96
|
+
return (0, print_utils_1.group)(print.spaced(["tablespaceKw", "name"]));
|
|
97
|
+
},
|
|
98
|
+
comment_target_text_search_configuration: function (print) {
|
|
99
|
+
return (0, print_utils_1.group)(print.spaced(["textSearchConfigurationKw", "name"]));
|
|
100
|
+
},
|
|
101
|
+
comment_target_text_search_dictionary: function (print) {
|
|
102
|
+
return (0, print_utils_1.group)(print.spaced(["textSearchDictionaryKw", "name"]));
|
|
103
|
+
},
|
|
104
|
+
comment_target_text_search_parser: function (print) {
|
|
105
|
+
return (0, print_utils_1.group)(print.spaced(["textSearchParserKw", "name"]));
|
|
106
|
+
},
|
|
107
|
+
comment_target_text_search_template: function (print) {
|
|
108
|
+
return (0, print_utils_1.group)(print.spaced(["textSearchTemplateKw", "name"]));
|
|
109
|
+
},
|
|
110
|
+
comment_target_transform: function (print) {
|
|
111
|
+
return (0, print_utils_1.group)(print.spaced([
|
|
112
|
+
"transformForKw",
|
|
113
|
+
"typeName",
|
|
114
|
+
"languageKw",
|
|
115
|
+
"languageName",
|
|
116
|
+
]));
|
|
117
|
+
},
|
|
118
|
+
comment_target_trigger: function (print) {
|
|
119
|
+
return (0, print_utils_1.group)(print.spaced(["triggerKw", "name", "onKw", "tableName"]));
|
|
120
|
+
},
|
|
121
|
+
comment_target_type: function (print) { return (0, print_utils_1.group)(print.spaced(["typeKw", "name"])); },
|
|
122
|
+
comment_target_view: function (print) { return (0, print_utils_1.group)(print.spaced(["viewKw", "name"])); },
|
|
123
|
+
};
|
package/dist/syntax/dcl.js
CHANGED
|
@@ -104,4 +104,38 @@ exports.dclMap = {
|
|
|
104
104
|
granted_by_clause: function (print) { return (0, print_utils_1.group)(print.spaced(["grantedByKw", "role"])); },
|
|
105
105
|
grantee_public: function (print) { return print("publicKw"); },
|
|
106
106
|
grantee_group: function (print) { return (0, print_utils_1.group)(print.spaced(["groupKw", "name"])); },
|
|
107
|
+
alter_default_privileges_stmt: function (print) {
|
|
108
|
+
return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray(__spreadArray([
|
|
109
|
+
print.spaced("alterDefaultPrivilegesKw")
|
|
110
|
+
], print("clauses"), true), [
|
|
111
|
+
print("action"),
|
|
112
|
+
], false)));
|
|
113
|
+
},
|
|
114
|
+
default_acl_for_role_clause: function (print) {
|
|
115
|
+
return (0, print_utils_1.group)(print.spaced(["forKw", "roleKw", "roles"]));
|
|
116
|
+
},
|
|
117
|
+
default_acl_in_schema_clause: function (print) {
|
|
118
|
+
return (0, print_utils_1.group)(print.spaced(["inKw", "schemaKw", "schemas"]));
|
|
119
|
+
},
|
|
120
|
+
grant_default_privileges_action: function (print) {
|
|
121
|
+
return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, [
|
|
122
|
+
(0, print_utils_1.group)(print.spaced(["grantKw", "privileges", "onKw", "resourcesKw"])),
|
|
123
|
+
(0, print_utils_1.group)(print.spaced(["toKw", "roles", "withGrantOption"])),
|
|
124
|
+
]));
|
|
125
|
+
},
|
|
126
|
+
revoke_default_privileges_action: function (print) {
|
|
127
|
+
return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, [
|
|
128
|
+
(0, print_utils_1.group)([
|
|
129
|
+
print.spaced(["revokeKw", "grantOptionFor"]),
|
|
130
|
+
(0, print_utils_1.indent)([
|
|
131
|
+
print_utils_1.line,
|
|
132
|
+
(0, print_utils_1.join)(print_utils_1.line, [
|
|
133
|
+
(0, print_utils_1.group)(print("privileges")),
|
|
134
|
+
print.spaced(["onKw", "resourcesKw"]),
|
|
135
|
+
]),
|
|
136
|
+
]),
|
|
137
|
+
]),
|
|
138
|
+
(0, print_utils_1.group)(print.spaced(["fromKw", "roles", "behaviorKw"])),
|
|
139
|
+
]));
|
|
140
|
+
},
|
|
107
141
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.postgresqlMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../../print_utils");
|
|
4
5
|
exports.postgresqlMap = {
|
|
5
6
|
postgresql_operator_expr: function (print) { return print(["operatorKw", "expr"]); },
|
|
6
7
|
postgresql_operator: function (print) { return print("operator"); },
|
|
7
8
|
postgresql_operator_class: function (print) { return print.spaced(["name", "options"]); },
|
|
8
|
-
postgresql_with_options: function (print) {
|
|
9
|
+
postgresql_with_options: function (print) {
|
|
10
|
+
return (0, print_utils_1.group)(print.spaced(["withKw", "options"]));
|
|
11
|
+
},
|
|
9
12
|
postgresql_options: function (print) { return print.spaced(["optionsKw", "options"]); },
|
|
10
13
|
postgresql_option_element: function (print) { return print.spaced(["name", "value"]); },
|
|
11
14
|
};
|
package/dist/syntax/expr.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { AllExprNodes } from "sql-parser-cst";
|
|
1
|
+
import { AllExprNodes, Keyword } from "sql-parser-cst";
|
|
2
2
|
import { CstToDocMap } from "../CstToDocMap";
|
|
3
|
+
import { AllPrettierOptions } from "src/options";
|
|
3
4
|
export declare const exprMap: CstToDocMap<AllExprNodes>;
|
|
5
|
+
export declare const printLiteral: <T>(node: Keyword, options: AllPrettierOptions<T>) => string;
|
package/dist/syntax/expr.js
CHANGED
|
@@ -9,7 +9,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
9
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.exprMap = void 0;
|
|
12
|
+
exports.printLiteral = exports.exprMap = void 0;
|
|
13
13
|
var print_utils_1 = require("../print_utils");
|
|
14
14
|
var node_utils_1 = require("../node_utils");
|
|
15
15
|
var utils_1 = require("../utils");
|
|
@@ -162,13 +162,17 @@ exports.exprMap = {
|
|
|
162
162
|
/** cst-ignore: value */
|
|
163
163
|
number_literal: function (print) { return print("text"); },
|
|
164
164
|
/** cst-ignore: value */
|
|
165
|
-
boolean_literal: function (print
|
|
165
|
+
boolean_literal: function (print, node, path, options) {
|
|
166
|
+
return (0, exports.printLiteral)(node.valueKw, options);
|
|
167
|
+
},
|
|
166
168
|
/** cst-ignore: value */
|
|
167
169
|
string_literal: function (print) { return print("text"); },
|
|
168
170
|
/** cst-ignore: value */
|
|
169
171
|
blob_literal: function (print) { return print("text"); },
|
|
170
172
|
/** cst-ignore: value */
|
|
171
|
-
null_literal: function (print
|
|
173
|
+
null_literal: function (print, node, path, options) {
|
|
174
|
+
return (0, exports.printLiteral)(node.nullKw, options);
|
|
175
|
+
},
|
|
172
176
|
numeric_literal: function (print) { return print.spaced(["numericKw", "string"]); },
|
|
173
177
|
bignumeric_literal: function (print) { return print.spaced(["bignumericKw", "string"]); },
|
|
174
178
|
date_literal: function (print) { return print.spaced(["dateKw", "string"]); },
|
|
@@ -183,6 +187,17 @@ exports.exprMap = {
|
|
|
183
187
|
variable: function (print) { return print("text"); },
|
|
184
188
|
parameter: function (print) { return print("text"); },
|
|
185
189
|
};
|
|
190
|
+
var printLiteral = function (node, options) {
|
|
191
|
+
switch (options.sqlLiteralCase) {
|
|
192
|
+
case "preserve":
|
|
193
|
+
return node.text;
|
|
194
|
+
case "upper":
|
|
195
|
+
return node.text.toUpperCase();
|
|
196
|
+
case "lower":
|
|
197
|
+
return node.text.toLowerCase();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
exports.printLiteral = printLiteral;
|
|
186
201
|
var isBooleanOp = function (_a) {
|
|
187
202
|
var name = _a.name;
|
|
188
203
|
return name === "AND" || name === "OR";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extensionMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.extensionMap = {
|
|
6
|
+
create_extension_stmt: function (print, node) {
|
|
7
|
+
return (0, print_utils_1.group)([
|
|
8
|
+
print.spaced(["createExtensionKw", "ifNotExistsKw", "name"]),
|
|
9
|
+
node.clauses.length > 0
|
|
10
|
+
? (0, print_utils_1.indent)([print_utils_1.line, print.spaced(["withKw", "clauses"])])
|
|
11
|
+
: [],
|
|
12
|
+
]);
|
|
13
|
+
},
|
|
14
|
+
extension_cascade_clause: function (print) { return (0, print_utils_1.group)(print.spaced(["cascadeKw"])); },
|
|
15
|
+
extension_schema_clause: function (print) { return (0, print_utils_1.group)(print.spaced(["schemaKw", "name"])); },
|
|
16
|
+
extension_version_clause: function (print) {
|
|
17
|
+
return (0, print_utils_1.group)(print.spaced(["versionKw", "name"]));
|
|
18
|
+
},
|
|
19
|
+
drop_extension_stmt: function (print) {
|
|
20
|
+
return (0, print_utils_1.group)(print.spaced(["dropExtensionKw", "ifExistsKw", "names", "behaviorKw"]));
|
|
21
|
+
},
|
|
22
|
+
};
|
package/dist/syntax/function.js
CHANGED
|
@@ -38,12 +38,6 @@ exports.functionMap = {
|
|
|
38
38
|
function_window_clause: function (print) { return print.spaced("windowKw"); },
|
|
39
39
|
function_transform_clause: function (print) { return print.spaced(["transformKw", "types"]); },
|
|
40
40
|
transform_type: function (print) { return print.spaced(["forTypeKw", "dataType"]); },
|
|
41
|
-
set_parameter_clause: function (print) {
|
|
42
|
-
return print.spaced(["setKw", "name", "operator", "value"]);
|
|
43
|
-
},
|
|
44
|
-
set_parameter_from_current_clause: function (print) {
|
|
45
|
-
return print.spaced(["setKw", "name", "fromCurrentKw"]);
|
|
46
|
-
},
|
|
47
41
|
dynamically_loaded_function: function (print) {
|
|
48
42
|
return (0, print_utils_1.join)(", ", print(["objectFile", "symbol"]));
|
|
49
43
|
},
|
|
@@ -64,8 +58,6 @@ exports.functionMap = {
|
|
|
64
58
|
node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : [],
|
|
65
59
|
]);
|
|
66
60
|
},
|
|
67
|
-
reset_parameter_clause: function (print) { return print.spaced(["resetKw", "name"]); },
|
|
68
|
-
reset_all_parameters_clause: function (print) { return print.spaced("resetAllKw"); },
|
|
69
61
|
};
|
|
70
62
|
var hasOnlyAsClause = function (node) {
|
|
71
63
|
return node.clauses.length === 1 && (0, node_utils_1.isAsClause)(node.clauses[0]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parameterMap = void 0;
|
|
4
|
+
var expr_1 = require("./expr");
|
|
5
|
+
exports.parameterMap = {
|
|
6
|
+
// SET
|
|
7
|
+
set_parameter_stmt: function (print) {
|
|
8
|
+
return print.spaced(["setKw", "modifierKw", "name", "operator", "value"]);
|
|
9
|
+
},
|
|
10
|
+
set_time_zone_parameter_stmt: function (print) {
|
|
11
|
+
return print.spaced(["setKw", "modifierKw", "timeZoneKw", "value"]);
|
|
12
|
+
},
|
|
13
|
+
set_parameter_clause: function (print) {
|
|
14
|
+
return print.spaced(["setKw", "name", "operator", "value"]);
|
|
15
|
+
},
|
|
16
|
+
local_parameter_value: function (print) { return print("localKw"); },
|
|
17
|
+
set_parameter_from_current_clause: function (print) {
|
|
18
|
+
return print.spaced(["setKw", "name", "fromCurrentKw"]);
|
|
19
|
+
},
|
|
20
|
+
// RESET
|
|
21
|
+
reset_parameter_stmt: function (print) { return print.spaced(["resetKw", "name"]); },
|
|
22
|
+
reset_parameter_clause: function (print) { return print.spaced(["resetKw", "name"]); },
|
|
23
|
+
all_parameters: function (print) { return print("allKw"); },
|
|
24
|
+
// SHOW
|
|
25
|
+
show_parameter_stmt: function (print) { return print.spaced(["showKw", "name"]); },
|
|
26
|
+
/** cst-ignore: value */
|
|
27
|
+
boolean_on_off_literal: function (print, node, path, options) {
|
|
28
|
+
return (0, expr_1.printLiteral)(node.valueKw, options);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -12,7 +12,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.preparedStatementsMap = void 0;
|
|
13
13
|
var print_utils_1 = require("../print_utils");
|
|
14
14
|
exports.preparedStatementsMap = {
|
|
15
|
-
|
|
15
|
+
// 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"]));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return (0, print_utils_1.group)([print.spaced(["executeKw", "name"]), print("args")]);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
execute_immediate_stmt: function (print) {
|
|
16
26
|
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
|
|
17
27
|
(0, print_utils_1.group)([
|
|
18
28
|
print.spaced(["executeKw", "immediateKw"]),
|
|
@@ -21,5 +31,21 @@ exports.preparedStatementsMap = {
|
|
|
21
31
|
], print(["into", "using"]).map(function (clause) { return (0, print_utils_1.group)(clause); }), true));
|
|
22
32
|
},
|
|
23
33
|
execute_into_clause: function (print) { return print.spaced(["intoKw", "variables"]); },
|
|
24
|
-
execute_using_clause: function (print) {
|
|
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
|
+
},
|
|
37
|
+
// 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
|
+
},
|
|
48
|
+
// DEALLOCATE
|
|
49
|
+
deallocate_stmt: function (print) { return print.spaced(["deallocateKw", "name"]); },
|
|
50
|
+
deallocate_all: function (print) { return print("allKw"); },
|
|
25
51
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publicationMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.publicationMap = {
|
|
6
|
+
create_publication_stmt: function (print, node) {
|
|
7
|
+
return (0, print_utils_1.group)([
|
|
8
|
+
print.spaced(["createPublicationKw", "name"]),
|
|
9
|
+
print("clauses").map(function (printedClause, i) {
|
|
10
|
+
if (node.clauses[i].type === "for_publication_objects_clause") {
|
|
11
|
+
return [" ", printedClause];
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return [print_utils_1.line, printedClause];
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
17
|
+
]);
|
|
18
|
+
},
|
|
19
|
+
for_publication_objects_clause: function (print) {
|
|
20
|
+
return (0, print_utils_1.group)([print("forKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
|
|
21
|
+
},
|
|
22
|
+
all_publication_object: function (print) { return (0, print_utils_1.group)(print.spaced(["allKw", "typesKw"])); },
|
|
23
|
+
publication_object_table: function (print) {
|
|
24
|
+
return (0, print_utils_1.group)(print.spaced(["tableKw", "table", "columns", "where"]));
|
|
25
|
+
},
|
|
26
|
+
publication_object_tables_in_schema: function (print) {
|
|
27
|
+
return (0, print_utils_1.group)(print.spaced(["tablesInSchemaKw", "schema"]));
|
|
28
|
+
},
|
|
29
|
+
alter_publication_stmt: function (print) {
|
|
30
|
+
return (0, print_utils_1.group)([
|
|
31
|
+
print.spaced(["alterPublicationKw", "name"]),
|
|
32
|
+
print.dynamicLine(),
|
|
33
|
+
print("action"),
|
|
34
|
+
]);
|
|
35
|
+
},
|
|
36
|
+
alter_action_add_publication_objects: function (print) {
|
|
37
|
+
return (0, print_utils_1.group)([print("addKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
|
|
38
|
+
},
|
|
39
|
+
alter_action_set_publication_objects: function (print) {
|
|
40
|
+
return (0, print_utils_1.group)([print("setKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
|
|
41
|
+
},
|
|
42
|
+
alter_action_drop_publication_objects: function (print) {
|
|
43
|
+
return (0, print_utils_1.group)([print("dropKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
|
|
44
|
+
},
|
|
45
|
+
drop_publication_stmt: function (print) {
|
|
46
|
+
return (0, print_utils_1.group)(print.spaced(["dropPublicationKw", "ifExistsKw", "names", "behaviorKw"]));
|
|
47
|
+
},
|
|
48
|
+
};
|
package/dist/syntax/sequence.js
CHANGED
|
@@ -26,6 +26,11 @@ exports.sequenceMap = {
|
|
|
26
26
|
"behaviorKw",
|
|
27
27
|
]));
|
|
28
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"); },
|
|
29
34
|
sequence_option_as_type: function (print) { return print.spaced(["asKw", "dataType"]); },
|
|
30
35
|
sequence_option_increment: function (print) {
|
|
31
36
|
return print.spaced(["incrementKw", "byKw", "value"]);
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
},
|
|
25
|
+
};
|
|
@@ -17,15 +17,19 @@ var alter_action_1 = require("./alter_action");
|
|
|
17
17
|
var alter_table_1 = require("./alter_table");
|
|
18
18
|
var analyze_1 = require("./analyze");
|
|
19
19
|
var base_1 = require("./base");
|
|
20
|
+
var cast_1 = require("./cast");
|
|
21
|
+
var comment_1 = require("./comment");
|
|
20
22
|
var constraint_1 = require("./constraint");
|
|
21
23
|
var create_table_1 = require("./create_table");
|
|
22
24
|
var data_type_1 = require("./data_type");
|
|
23
25
|
var dcl_1 = require("./dcl");
|
|
24
26
|
var delete_1 = require("./delete");
|
|
27
|
+
var do_1 = require("./do");
|
|
25
28
|
var domain_1 = require("./domain");
|
|
26
29
|
var drop_table_1 = require("./drop_table");
|
|
27
30
|
var explain_1 = require("./explain");
|
|
28
31
|
var expr_1 = require("./expr");
|
|
32
|
+
var extension_1 = require("./extension");
|
|
29
33
|
var frame_1 = require("./frame");
|
|
30
34
|
var function_1 = require("./function");
|
|
31
35
|
var index_1 = require("./index");
|
|
@@ -34,15 +38,18 @@ var merge_1 = require("./merge");
|
|
|
34
38
|
var other_clauses_1 = require("./other_clauses");
|
|
35
39
|
var rename_table_1 = require("./rename_table");
|
|
36
40
|
var role_1 = require("./role");
|
|
41
|
+
var parameter_1 = require("./parameter");
|
|
37
42
|
var policy_1 = require("./policy");
|
|
38
43
|
var prepared_statements_1 = require("./prepared_statements");
|
|
39
44
|
var procedural_language_1 = require("./procedural_language");
|
|
40
45
|
var procedure_1 = require("./procedure");
|
|
41
46
|
var proc_clause_1 = require("./proc_clause");
|
|
42
47
|
var program_1 = require("./program");
|
|
48
|
+
var publication_1 = require("./publication");
|
|
43
49
|
var schema_1 = require("./schema");
|
|
44
50
|
var select_1 = require("./select");
|
|
45
51
|
var sequence_1 = require("./sequence");
|
|
52
|
+
var subscription_1 = require("./subscription");
|
|
46
53
|
var transaction_1 = require("./transaction");
|
|
47
54
|
var trigger_1 = require("./trigger");
|
|
48
55
|
var truncate_1 = require("./truncate");
|
|
@@ -54,4 +61,4 @@ var bigquery_1 = require("./dialects/bigquery");
|
|
|
54
61
|
var mysql_1 = require("./dialects/mysql");
|
|
55
62
|
var sqlite_1 = require("./dialects/sqlite");
|
|
56
63
|
var postgresql_1 = require("./dialects/postgresql");
|
|
57
|
-
exports.transformMap = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, alias_1.aliasMap), alter_action_1.alterActionMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), dcl_1.dclMap), delete_1.deleteMap), domain_1.domainMap), drop_table_1.dropTableMap), explain_1.explainMap), expr_1.exprMap), frame_1.frameMap), function_1.functionMap), index_1.indexMap), insert_1.insertMap), merge_1.mergeMap), other_clauses_1.otherClausesMap), policy_1.policyMap), prepared_statements_1.preparedStatementsMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), procedure_1.procedureMap), program_1.programMap), rename_table_1.renameTableMap), role_1.roleMap), schema_1.schemaMap), select_1.selectMap), sequence_1.sequenceMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), type_1.typeMap), unsupported_grammar_1.unsupportedGrammarMap), update_1.updateMap), view_1.viewMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), sqlite_1.sqliteMap);
|
|
64
|
+
exports.transformMap = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, alias_1.aliasMap), alter_action_1.alterActionMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), cast_1.castMap), comment_1.commentMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), dcl_1.dclMap), delete_1.deleteMap), do_1.doMap), domain_1.domainMap), drop_table_1.dropTableMap), explain_1.explainMap), expr_1.exprMap), extension_1.extensionMap), frame_1.frameMap), function_1.functionMap), index_1.indexMap), insert_1.insertMap), merge_1.mergeMap), other_clauses_1.otherClausesMap), parameter_1.parameterMap), policy_1.policyMap), prepared_statements_1.preparedStatementsMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), procedure_1.procedureMap), program_1.programMap), publication_1.publicationMap), rename_table_1.renameTableMap), role_1.roleMap), schema_1.schemaMap), select_1.selectMap), sequence_1.sequenceMap), subscription_1.subscriptionMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), type_1.typeMap), unsupported_grammar_1.unsupportedGrammarMap), update_1.updateMap), view_1.viewMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), sqlite_1.sqliteMap);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sql-cst",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
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.
|
|
40
|
+
"sql-parser-cst": "^0.35.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/jest": "^29.2.5",
|