prettier-plugin-sql-cst 0.19.2 → 0.19.3
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/dist/index.d.ts +21 -7
- package/dist/index.js +2637 -55
- package/package.json +3 -2
- package/dist/CstToDocMap.d.ts +0 -11
- package/dist/CstToDocMap.js +0 -1
- package/dist/PrintFn.d.ts +0 -17
- package/dist/PrintFn.js +0 -1
- package/dist/embed.d.ts +0 -3
- package/dist/embed.js +0 -6
- package/dist/embedJs.d.ts +0 -3
- package/dist/embedJs.js +0 -43
- package/dist/embedJson.d.ts +0 -3
- package/dist/embedJson.js +0 -34
- package/dist/embedSql.d.ts +0 -3
- package/dist/embedSql.js +0 -39
- package/dist/node_utils.d.ts +0 -38
- package/dist/node_utils.js +0 -44
- package/dist/options.d.ts +0 -15
- package/dist/options.js +0 -147
- package/dist/printComment.d.ts +0 -3
- package/dist/printComment.js +0 -12
- package/dist/printSql.d.ts +0 -5
- package/dist/printSql.js +0 -61
- package/dist/print_utils.d.ts +0 -13
- package/dist/print_utils.js +0 -49
- package/dist/syntax/alias.d.ts +0 -3
- package/dist/syntax/alias.js +0 -3
- package/dist/syntax/alter_action.d.ts +0 -3
- package/dist/syntax/alter_action.js +0 -120
- package/dist/syntax/alter_table.d.ts +0 -3
- package/dist/syntax/alter_table.js +0 -19
- package/dist/syntax/analyze.d.ts +0 -3
- package/dist/syntax/analyze.js +0 -4
- package/dist/syntax/base.d.ts +0 -3
- package/dist/syntax/base.js +0 -19
- package/dist/syntax/cast.d.ts +0 -3
- package/dist/syntax/cast.js +0 -4
- package/dist/syntax/comment.d.ts +0 -3
- package/dist/syntax/comment.js +0 -54
- package/dist/syntax/constraint.d.ts +0 -6
- package/dist/syntax/constraint.js +0 -80
- package/dist/syntax/create_table.d.ts +0 -3
- package/dist/syntax/create_table.js +0 -69
- package/dist/syntax/data_type.d.ts +0 -3
- package/dist/syntax/data_type.js +0 -29
- package/dist/syntax/dcl.d.ts +0 -3
- package/dist/syntax/dcl.js +0 -83
- package/dist/syntax/delete.d.ts +0 -3
- package/dist/syntax/delete.js +0 -5
- package/dist/syntax/dialects/bigquery.d.ts +0 -3
- package/dist/syntax/dialects/bigquery.js +0 -84
- package/dist/syntax/dialects/mysql.d.ts +0 -3
- package/dist/syntax/dialects/mysql.js +0 -3
- package/dist/syntax/dialects/postgresql.d.ts +0 -3
- package/dist/syntax/dialects/postgresql.js +0 -9
- package/dist/syntax/dialects/sqlite.d.ts +0 -3
- package/dist/syntax/dialects/sqlite.js +0 -9
- package/dist/syntax/do.d.ts +0 -3
- package/dist/syntax/do.js +0 -4
- package/dist/syntax/domain.d.ts +0 -3
- package/dist/syntax/domain.js +0 -11
- package/dist/syntax/drop_table.d.ts +0 -3
- package/dist/syntax/drop_table.js +0 -11
- package/dist/syntax/explain.d.ts +0 -3
- package/dist/syntax/explain.js +0 -7
- package/dist/syntax/expr.d.ts +0 -5
- package/dist/syntax/expr.js +0 -224
- package/dist/syntax/extension.d.ts +0 -3
- package/dist/syntax/extension.js +0 -13
- package/dist/syntax/frame.d.ts +0 -3
- package/dist/syntax/frame.js +0 -13
- package/dist/syntax/function.d.ts +0 -4
- package/dist/syntax/function.js +0 -55
- package/dist/syntax/index.d.ts +0 -3
- package/dist/syntax/index.js +0 -60
- package/dist/syntax/insert.d.ts +0 -3
- package/dist/syntax/insert.js +0 -33
- package/dist/syntax/merge.d.ts +0 -3
- package/dist/syntax/merge.js +0 -30
- package/dist/syntax/other_clauses.d.ts +0 -3
- package/dist/syntax/other_clauses.js +0 -9
- package/dist/syntax/parameter.d.ts +0 -3
- package/dist/syntax/parameter.js +0 -18
- package/dist/syntax/policy.d.ts +0 -3
- package/dist/syntax/policy.js +0 -27
- package/dist/syntax/prepared_statements.d.ts +0 -3
- package/dist/syntax/prepared_statements.js +0 -31
- package/dist/syntax/proc_clause.d.ts +0 -3
- package/dist/syntax/proc_clause.js +0 -14
- package/dist/syntax/procedural_language.d.ts +0 -3
- package/dist/syntax/procedural_language.js +0 -104
- package/dist/syntax/procedure.d.ts +0 -3
- package/dist/syntax/procedure.js +0 -38
- package/dist/syntax/program.d.ts +0 -3
- package/dist/syntax/program.js +0 -39
- package/dist/syntax/publication.d.ts +0 -3
- package/dist/syntax/publication.js +0 -27
- package/dist/syntax/rename_table.d.ts +0 -3
- package/dist/syntax/rename_table.js +0 -8
- package/dist/syntax/role.d.ts +0 -3
- package/dist/syntax/role.js +0 -31
- package/dist/syntax/schema.d.ts +0 -3
- package/dist/syntax/schema.js +0 -18
- package/dist/syntax/select.d.ts +0 -3
- package/dist/syntax/select.js +0 -226
- package/dist/syntax/sequence.d.ts +0 -3
- package/dist/syntax/sequence.js +0 -36
- package/dist/syntax/subscription.d.ts +0 -3
- package/dist/syntax/subscription.js +0 -10
- package/dist/syntax/transaction.d.ts +0 -3
- package/dist/syntax/transaction.js +0 -19
- package/dist/syntax/transformMap.d.ts +0 -3
- package/dist/syntax/transformMap.js +0 -100
- package/dist/syntax/trigger.d.ts +0 -3
- package/dist/syntax/trigger.js +0 -52
- package/dist/syntax/truncate.d.ts +0 -3
- package/dist/syntax/truncate.js +0 -10
- package/dist/syntax/type.d.ts +0 -3
- package/dist/syntax/type.js +0 -12
- package/dist/syntax/unsupported_grammar.d.ts +0 -3
- package/dist/syntax/unsupported_grammar.js +0 -4
- package/dist/syntax/update.d.ts +0 -3
- package/dist/syntax/update.js +0 -14
- package/dist/syntax/view.d.ts +0 -3
- package/dist/syntax/view.js +0 -48
- package/dist/transform/addFinalSemicolon.d.ts +0 -2
- package/dist/transform/addFinalSemicolon.js +0 -9
- package/dist/transform/aliasAs.d.ts +0 -2
- package/dist/transform/aliasAs.js +0 -10
- package/dist/transform/canonicKeywords.d.ts +0 -2
- package/dist/transform/canonicKeywords.js +0 -62
- package/dist/transform/canonicOperators.d.ts +0 -3
- package/dist/transform/canonicOperators.js +0 -28
- package/dist/transform/comments.d.ts +0 -12
- package/dist/transform/comments.js +0 -22
- package/dist/transform/stripTrailingCommas.d.ts +0 -2
- package/dist/transform/stripTrailingCommas.js +0 -15
- package/dist/transform/transformCst.d.ts +0 -5
- package/dist/transform/transformCst.js +0 -21
- package/dist/transform/transformUtils.d.ts +0 -2
- package/dist/transform/transformUtils.js +0 -3
- package/dist/utils.d.ts +0 -9
- package/dist/utils.js +0 -9
- package/dist/visitAllNodes.d.ts +0 -2
- package/dist/visitAllNodes.js +0 -16
package/dist/index.js
CHANGED
|
@@ -1,64 +1,2646 @@
|
|
|
1
|
+
// src/index.ts
|
|
1
2
|
import { parse } from "sql-parser-cst";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
|
|
4
|
+
// src/utils.ts
|
|
5
|
+
var isDefined = (value) => value !== void 0;
|
|
6
|
+
var isString = (value) => typeof value === "string";
|
|
7
|
+
var isObject = (x) => typeof x === "object" && x !== null && !(x instanceof Array);
|
|
8
|
+
var isArray = (x) => Array.isArray(x);
|
|
9
|
+
var isEmptyArray = (x) => isArray(x) && x.length === 0;
|
|
10
|
+
var isNode = (value) => isObject(value) && isString(value.type) && !isCommentType(value.type);
|
|
11
|
+
var isCommentType = (type) => type === "block_comment" || type === "line_comment";
|
|
12
|
+
var arrayWrap = (x) => isArray(x) ? x : [x];
|
|
13
|
+
var last = (arr) => arr[arr.length - 1];
|
|
14
|
+
|
|
15
|
+
// src/syntax/alias.ts
|
|
16
|
+
var aliasMap = {
|
|
17
|
+
alias: (print) => print.spaced(["expr", "asKw", "alias", "columnAliases"])
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/print_utils.ts
|
|
21
|
+
import { doc, util } from "prettier";
|
|
22
|
+
var {
|
|
23
|
+
line,
|
|
24
|
+
hardline,
|
|
25
|
+
softline,
|
|
26
|
+
indent,
|
|
27
|
+
group,
|
|
28
|
+
lineSuffix,
|
|
29
|
+
ifBreak,
|
|
30
|
+
breakParent
|
|
31
|
+
} = doc.builders;
|
|
32
|
+
var { join: origJoin } = doc.builders;
|
|
33
|
+
var { stripTrailingHardline } = doc.utils;
|
|
34
|
+
var join = (sep, docs) => isArray(docs) ? origJoin(sep, docs) : docs;
|
|
35
|
+
var containsNewline = (node, opts) => {
|
|
36
|
+
if (!node.range) {
|
|
37
|
+
throw new Error("containsNewline() expected a Node with range info");
|
|
38
|
+
}
|
|
39
|
+
return util.hasNewlineInRange(
|
|
40
|
+
opts.originalText,
|
|
41
|
+
node.range[0],
|
|
42
|
+
node.range[1]
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
var hasEmptyLineBetweenNodes = (node1, node2, opts) => {
|
|
46
|
+
if (!node1.range || !node2.range) {
|
|
47
|
+
throw new Error("emptyLineBetweenNodes() expects Nodes with range info");
|
|
48
|
+
}
|
|
49
|
+
const start = node1.range[1];
|
|
50
|
+
const end = node2.range[0];
|
|
51
|
+
const indexes = emptyLineIndexes(opts.originalText.slice(start, end)).map(
|
|
52
|
+
(i) => start + i
|
|
53
|
+
);
|
|
54
|
+
if (indexes.length === 0) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const comments = [...node1.trailing ?? [], ...node2.leading ?? []];
|
|
58
|
+
return indexes.filter((index) => !isIndexInsideOrBetweenComments(index, comments)).length > 0;
|
|
59
|
+
};
|
|
60
|
+
function emptyLineIndexes(text) {
|
|
61
|
+
const indexes = [];
|
|
62
|
+
const re = /\n[ \t]*\r?\n/g;
|
|
63
|
+
let match;
|
|
64
|
+
while (match = re.exec(text)) {
|
|
65
|
+
indexes.push(match.index);
|
|
66
|
+
}
|
|
67
|
+
return indexes;
|
|
68
|
+
}
|
|
69
|
+
function isIndexInsideOrBetweenComments(index, comments) {
|
|
70
|
+
if (comments.length === 0) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const start = comments[0].range[0];
|
|
74
|
+
const end = comments[comments.length - 1].range[1];
|
|
75
|
+
return start <= index && index <= end;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/syntax/constraint.ts
|
|
79
|
+
var constraintMap = {
|
|
80
|
+
/** cst-ignore: constraint, modifiers */
|
|
81
|
+
constraint: (print, node) => {
|
|
82
|
+
if (node.name) {
|
|
83
|
+
return group([
|
|
84
|
+
print("name"),
|
|
85
|
+
indent([line, printUnnamedConstraint(print, node)])
|
|
86
|
+
]);
|
|
87
|
+
} else {
|
|
88
|
+
return printUnnamedConstraint(print, node);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
constraint_name: (print) => print.spaced(["constraintKw", "name"]),
|
|
92
|
+
constraint_modifier: (print) => print.spaced("kw"),
|
|
93
|
+
constraint_null: (print) => print("nullKw"),
|
|
94
|
+
constraint_not_null: (print) => group(print.spaced(["notNullKw", "clauses"])),
|
|
95
|
+
constraint_default: (print) => group(print.spaced(["defaultKw", "expr"])),
|
|
96
|
+
constraint_primary_key: (print) => group(print.spaced(["primaryKeyKw", "direction", "columns", "clauses"])),
|
|
97
|
+
constraint_unique: (print) => group(print.spaced(["uniqueKw", "columns", "nullsKw", "clauses"])),
|
|
98
|
+
existing_index: (print) => print.spaced(["usingIndexKw", "index"]),
|
|
99
|
+
constraint_check: (print) => group(print.spaced(["checkKw", "expr", "clauses"])),
|
|
100
|
+
constraint_collate: (print) => group(print.spaced(["collateKw", "collation"])),
|
|
101
|
+
constraint_foreign_key: (print) => group(print.spaced(["foreignKeyKw", "indexName", "columns", "references"])),
|
|
102
|
+
references_specification: (print, node) => {
|
|
103
|
+
const baseDoc = print.spaced(["referencesKw", "table", "columns"]);
|
|
104
|
+
if (node.options.length > 0) {
|
|
105
|
+
return group([
|
|
106
|
+
baseDoc,
|
|
107
|
+
indent([hardline, join(hardline, print("options"))])
|
|
108
|
+
]);
|
|
109
|
+
} else {
|
|
110
|
+
return baseDoc;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
referential_action: (print) => print.spaced(["onKw", "eventKw", "actionKw", "columns"]),
|
|
114
|
+
referential_match: (print) => print.spaced(["matchKw", "typeKw"]),
|
|
115
|
+
constraint_generated: (print) => print.spaced([
|
|
116
|
+
"generatedKw",
|
|
117
|
+
"asKw",
|
|
118
|
+
"expr",
|
|
119
|
+
"storageKw",
|
|
120
|
+
"sequenceOptions"
|
|
121
|
+
]),
|
|
122
|
+
identity_column: (print) => print("identityKw"),
|
|
123
|
+
constraint_auto_increment: (print) => print("autoIncrementKw"),
|
|
124
|
+
on_conflict_clause: (print) => print.spaced(["onConflictKw", "resolutionKw"]),
|
|
125
|
+
constraint_comment: (print) => print.spaced(["commentKw", "value"]),
|
|
126
|
+
constraint_index: (print) => print.spaced(["indexTypeKw", "indexKw", "columns"]),
|
|
127
|
+
constraint_visible: (print) => print.spaced(["visibleKw"]),
|
|
128
|
+
constraint_column_format: (print) => print.spaced(["columnFormatKw", "formatKw"]),
|
|
129
|
+
constraint_storage: (print) => print.spaced(["storageKw", "typeKw"]),
|
|
130
|
+
constraint_engine_attribute: (print, node) => join(node.hasEq ? " = " : " ", print(["engineAttributeKw", "value"])),
|
|
131
|
+
constraint_compression: (print) => print.spaced(["compressionKw", "method"]),
|
|
132
|
+
constraint_exclude: (print, node) => group([
|
|
133
|
+
print("excludeKw"),
|
|
134
|
+
indent([
|
|
135
|
+
line,
|
|
136
|
+
join(line, [
|
|
137
|
+
print.separated(line, ["using", "params"]),
|
|
138
|
+
...print("clauses")
|
|
139
|
+
])
|
|
140
|
+
])
|
|
141
|
+
]),
|
|
142
|
+
exclusion_param: (print) => print.spaced(["index", "withKw", "operator"]),
|
|
143
|
+
index_tablespace_clause: (print) => print.spaced(["usingIndexTablespaceKw", "name"])
|
|
144
|
+
};
|
|
145
|
+
var printUnnamedConstraint = (print, node) => {
|
|
146
|
+
if (node.modifiers.length > 0) {
|
|
147
|
+
return group([
|
|
148
|
+
print("constraint"),
|
|
149
|
+
indent([line, print.spaced("modifiers")])
|
|
150
|
+
]);
|
|
151
|
+
} else {
|
|
152
|
+
return print("constraint");
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// src/syntax/alter_action.ts
|
|
157
|
+
var alterActionMap = {
|
|
158
|
+
alter_action_rename: (print) => print.spaced(["renameKw", "newName"]),
|
|
159
|
+
alter_action_rename_column: (print) => print.spaced(["renameKw", "ifExistsKw", "oldName", "toKw", "newName"]),
|
|
160
|
+
alter_action_add_column: (print) => print.spaced(["addKw", "ifNotExistsKw", "column"]),
|
|
161
|
+
alter_action_drop_column: (print) => print.spaced(["dropKw", "ifExistsKw", "column", "behaviorKw"]),
|
|
162
|
+
alter_action_set_bigquery_options: (print) => print.spaced(["setKw", "options"]),
|
|
163
|
+
alter_action_set_default_collate: (print) => print.spaced(["setDefaultCollateKw", "collation"]),
|
|
164
|
+
/** cst-ignore: constraint, modifiers */
|
|
165
|
+
alter_action_add_constraint: (print, node) => group([
|
|
166
|
+
print.spaced(["addKw", "name"]),
|
|
167
|
+
indent([line, printUnnamedConstraint(print, node)])
|
|
168
|
+
]),
|
|
169
|
+
alter_action_add_constraint_constraint_name: (print) => print.spaced(["constraintKw", "ifNotExistsKw", "name"]),
|
|
170
|
+
alter_action_drop_constraint: (print) => print.spaced([
|
|
171
|
+
"dropConstraintKw",
|
|
172
|
+
"ifExistsKw",
|
|
173
|
+
"constraint",
|
|
174
|
+
"behaviorKw"
|
|
175
|
+
]),
|
|
176
|
+
alter_action_drop_primary_key: (print) => print.spaced(["dropPrimaryKeyKw", "ifExistsKw"]),
|
|
177
|
+
alter_action_alter_constraint: (print) => print.spaced(["alterConstraintKw", "constraint", "modifiers"]),
|
|
178
|
+
alter_action_rename_constraint: (print) => print.spaced(["renameConstraintKw", "oldName", "toKw", "newName"]),
|
|
179
|
+
alter_action_validate_constraint: (print) => print.spaced(["validateConstraintKw", "constraint"]),
|
|
180
|
+
alter_action_set_visible: (print) => print.spaced("setVisibleKw"),
|
|
181
|
+
alter_action_set_invisible: (print) => print.spaced("setInvisibleKw"),
|
|
182
|
+
alter_action_set_tablespace: (print) => print.spaced(["setTablespaceKw", "tablespace", "nowaitKw"]),
|
|
183
|
+
alter_action_set_schema: (print) => print.spaced(["setSchemaKw", "schema"]),
|
|
184
|
+
alter_action_enable: (print) => print.spaced(["enableKw", "modeKw", "item"]),
|
|
185
|
+
alter_action_disable: (print) => print.spaced(["disableKw", "item"]),
|
|
186
|
+
alter_action_force: (print) => print.spaced(["forceKw", "item"]),
|
|
187
|
+
alter_action_no_force: (print) => print.spaced(["noForceKw", "item"]),
|
|
188
|
+
alter_action_cluster_on: (print) => print.spaced(["clusterOnKw", "index"]),
|
|
189
|
+
alter_action_set_without_cluster: (print) => print.spaced("setWithoutClusterKw"),
|
|
190
|
+
alter_action_set_without_oids: (print) => print.spaced("setWithoutOidsKw"),
|
|
191
|
+
alter_action_set_access_method: (print) => print.spaced(["setAccessMethodKw", "method"]),
|
|
192
|
+
alter_action_set_logged: (print) => print.spaced("setLoggedKw"),
|
|
193
|
+
alter_action_set_unlogged: (print) => print.spaced("setUnloggedKw"),
|
|
194
|
+
alter_action_inherit: (print) => print.spaced(["inheritKw", "table"]),
|
|
195
|
+
alter_action_no_inherit: (print) => print.spaced(["noInheritKw", "table"]),
|
|
196
|
+
alter_action_of_type: (print) => print.spaced(["ofKw", "typeName"]),
|
|
197
|
+
alter_action_not_of_type: (print) => print.spaced("notOfKw"),
|
|
198
|
+
alter_action_owner_to: (print) => print.spaced(["ownerToKw", "owner"]),
|
|
199
|
+
alter_action_replica_identity: (print) => print.spaced(["replicaIdentityKw", "identity"]),
|
|
200
|
+
replica_identity_using_index: (print) => print.spaced(["usingIndexKw", "index"]),
|
|
201
|
+
alter_action_set_postgresql_options: (print) => print.spaced(["setKw", "options"]),
|
|
202
|
+
alter_action_reset_postgresql_options: (print) => print.spaced(["resetKw", "options"]),
|
|
203
|
+
alter_action_depends_on_extension: (print) => print.spaced(["dependsOnExtensionKw", "extension"]),
|
|
204
|
+
alter_action_no_depends_on_extension: (print) => print.spaced(["noDependsOnExtensionKw", "extension"]),
|
|
205
|
+
alter_action_attach_partition: (print) => print.spaced(["attachPartitionKw", "index"]),
|
|
206
|
+
alter_action_add_enum_value: (print) => print.spaced(["addValueKw", "ifNotExistsKw", "value", "position"]),
|
|
207
|
+
alter_action_add_enum_value_position: (print) => print.spaced(["positionKw", "value"]),
|
|
208
|
+
alter_action_rename_enum_value: (print) => print.spaced(["renameValueKw", "oldValue", "toKw", "newValue"]),
|
|
209
|
+
alter_action_add_attribute: (print) => print.spaced([
|
|
210
|
+
"addAttributeKw",
|
|
211
|
+
"name",
|
|
212
|
+
"dataType",
|
|
213
|
+
"constraint",
|
|
214
|
+
"behaviorKw"
|
|
215
|
+
]),
|
|
216
|
+
alter_action_drop_attribute: (print) => print.spaced(["dropAttributeKw", "ifExistsKw", "name", "behaviorKw"]),
|
|
217
|
+
alter_action_alter_attribute: (print) => print.spaced([
|
|
218
|
+
"alterAttributeKw",
|
|
219
|
+
"name",
|
|
220
|
+
"setDataTypeKw",
|
|
221
|
+
"dataType",
|
|
222
|
+
"constraint",
|
|
223
|
+
"behaviorKw"
|
|
224
|
+
]),
|
|
225
|
+
alter_action_rename_attribute: (print) => print.spaced([
|
|
226
|
+
"renameAttributeKw",
|
|
227
|
+
"oldName",
|
|
228
|
+
"toKw",
|
|
229
|
+
"newName",
|
|
230
|
+
"behaviorKw"
|
|
231
|
+
]),
|
|
232
|
+
// ALTER COLUMN
|
|
233
|
+
alter_action_alter_column: (print) => group([
|
|
234
|
+
print.spaced(["alterKw", "ifExistsKw", "column"]),
|
|
235
|
+
print.dynamicLine(),
|
|
236
|
+
print("action")
|
|
237
|
+
]),
|
|
238
|
+
alter_action_set_default: (print) => print.spaced(["setDefaultKw", "expr"]),
|
|
239
|
+
alter_action_drop_default: (print) => print.spaced("dropDefaultKw"),
|
|
240
|
+
alter_action_set_not_null: (print) => print.spaced("setNotNullKw"),
|
|
241
|
+
alter_action_drop_not_null: (print) => print.spaced("dropNotNullKw"),
|
|
242
|
+
alter_action_set_data_type: (print) => print.spaced(["setDataTypeKw", "dataType", "clauses"]),
|
|
243
|
+
alter_action_set_statistics: (print) => print.spaced(["setStatisticsKw", "value"]),
|
|
244
|
+
alter_action_set_compression: (print) => print.spaced(["setCompressionKw", "method"]),
|
|
245
|
+
alter_action_set_storage: (print) => print.spaced(["setStorageKw", "typeKw"]),
|
|
246
|
+
alter_action_drop_expression: (print) => print.spaced(["dropExpressionKw", "ifExistsKw"]),
|
|
247
|
+
alter_action_drop_identity: (print) => print.spaced(["dropIdentityKw", "ifExistsKw"]),
|
|
248
|
+
alter_action_add_identity: (print) => print.spaced([
|
|
249
|
+
"addGeneratedKw",
|
|
250
|
+
"whenKw",
|
|
251
|
+
"asIdentityKw",
|
|
252
|
+
"sequenceOptions"
|
|
253
|
+
]),
|
|
254
|
+
alter_action_alter_identity: (print) => group(join(line, print("actions"))),
|
|
255
|
+
alter_action_set_generated: (print) => print.spaced(["setGeneratedKw", "whenKw"]),
|
|
256
|
+
alter_action_restart: (print) => print.spaced(["restartKw", "withKw", "value"]),
|
|
257
|
+
alter_action_set_sequence_option: (print) => print.spaced(["setKw", "option"]),
|
|
258
|
+
alter_action_with_role_options: (print, node) => node.withKw ? group([print("withKw"), indent([line, join(line, print("options"))])]) : (
|
|
259
|
+
// This works in tandem with the logic inside alter_role_stmt
|
|
260
|
+
group(join(line, print("options")))
|
|
261
|
+
),
|
|
262
|
+
alter_action_set_postgresql_option: (print) => print.spaced(["setKw", "name", "operator", "value"]),
|
|
263
|
+
alter_action_set_postgresql_option_from_current: (print) => print.spaced(["setKw", "name", "fromCurrentKw"]),
|
|
264
|
+
alter_action_reset_postgresql_option: (print) => print.spaced(["resetKw", "name"]),
|
|
265
|
+
alter_action_add_user: (print) => group(print.spaced(["addUserKw", "users"])),
|
|
266
|
+
alter_action_drop_user: (print) => group(print.spaced(["dropUserKw", "users"])),
|
|
267
|
+
// ENABLE/DISABLE ..
|
|
268
|
+
toggle_trigger: (print) => print.spaced(["triggerKw", "name"]),
|
|
269
|
+
toggle_rule: (print) => print.spaced(["ruleKw", "name"]),
|
|
270
|
+
toggle_row_level_security: (print) => print.spaced("rowLevelSecurityKw"),
|
|
271
|
+
// SET DATA TYPE ...
|
|
272
|
+
set_data_type_collate_clause: (print) => print.spaced(["collateKw", "collation"]),
|
|
273
|
+
set_data_type_using_clause: (print) => print.spaced(["usingKw", "expr"])
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// src/syntax/alter_table.ts
|
|
277
|
+
var alterTableMap = {
|
|
278
|
+
alter_table_stmt: (print) => group([
|
|
279
|
+
print.spaced(["alterTableKw", "ifExistsKw", "table"]),
|
|
280
|
+
print.dynamicLine(),
|
|
281
|
+
print("actions")
|
|
282
|
+
]),
|
|
283
|
+
alter_table_all_in_tablespace_stmt: (print) => group([
|
|
284
|
+
print.spaced([
|
|
285
|
+
"alterTableKw",
|
|
286
|
+
"allInTablespaceKw",
|
|
287
|
+
"tablespace",
|
|
288
|
+
"ownedBy"
|
|
289
|
+
]),
|
|
290
|
+
print.dynamicLine(),
|
|
291
|
+
print("action")
|
|
292
|
+
]),
|
|
293
|
+
owned_by_clause: (print) => group([print.spaced("ownedByKw"), indent([line, print("owners")])])
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// src/syntax/analyze.ts
|
|
297
|
+
var analyzeMap = {
|
|
298
|
+
analyze_stmt: (print) => group(print.spaced(["analyzeKw", "tableKw", "tables"]))
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
// src/node_utils.ts
|
|
302
|
+
var is = (type) => (node) => isObject(node) && node.type === type;
|
|
303
|
+
var isProgram = is("program");
|
|
304
|
+
var isValuesClause = is("values_clause");
|
|
305
|
+
var isFuncCall = is("func_call");
|
|
306
|
+
var isFuncArgs = is("func_args");
|
|
307
|
+
var isCreateTableStmt = is("create_table_stmt");
|
|
308
|
+
var isKeyword = is("keyword");
|
|
309
|
+
var isEmpty = is("empty");
|
|
310
|
+
var isJsonLiteral = is("json_literal");
|
|
311
|
+
var isJsonbLiteral = is("jsonb_literal");
|
|
312
|
+
var isStringLiteral = is("string_literal");
|
|
313
|
+
var isArraySubscript = is("array_subscript");
|
|
314
|
+
var isAsClause = is("as_clause");
|
|
315
|
+
var isParenExpr = is("paren_expr");
|
|
316
|
+
var isMemberExpr = is("member_expr");
|
|
317
|
+
var isSelectStmt = is("select_stmt");
|
|
318
|
+
var isCompoundSelectStmt = is("compound_select_stmt");
|
|
319
|
+
var isListExpr = is("list_expr");
|
|
320
|
+
var isCreateFunctionStmt = is("create_function_stmt");
|
|
321
|
+
var isAlterFunctionStmt = is("alter_function_stmt");
|
|
322
|
+
var isDropFunctionStmt = is("drop_function_stmt");
|
|
323
|
+
var isCreateProcedureStmt = is("create_procedure_stmt");
|
|
324
|
+
var isAlterProcedureStmt = is("alter_procedure_stmt");
|
|
325
|
+
var isDropProcedureStmt = is("drop_procedure_stmt");
|
|
326
|
+
var isAlterActionRename = is("alter_action_rename");
|
|
327
|
+
var isLanguageClause = is("language_clause");
|
|
328
|
+
var isDynamicallyLoadedFunction = is("dynamically_loaded_function");
|
|
329
|
+
var isBigqueryQuotedMemberExpr = is("bigquery_quoted_member_expr");
|
|
330
|
+
var isCreateTriggerStmt = is("create_trigger_stmt");
|
|
331
|
+
var isExecuteClause = is("execute_clause");
|
|
332
|
+
var isFunctionSignature = is("function_signature");
|
|
333
|
+
var isDataTypeName = is("data_type_name");
|
|
334
|
+
var isIntervalDataType = is("interval_data_type");
|
|
335
|
+
var isIntervalUnit = is("interval_unit");
|
|
336
|
+
var isIntervalUnitRange = is("interval_unit_range");
|
|
337
|
+
var isTimeDataType = is("time_data_type");
|
|
338
|
+
var isParametricDataType = is("parametric_data_type");
|
|
339
|
+
var isDataType = ([node, ...ancestors]) => isDataTypeName(node) || isIntervalDataType(node) || isIntervalUnit(node) && isDataType(ancestors) || isIntervalUnitRange(node) && isDataType(ancestors) || isTimeDataType(node) || isParametricDataType(node);
|
|
340
|
+
|
|
341
|
+
// src/syntax/base.ts
|
|
342
|
+
var baseMap = {
|
|
343
|
+
/** cst-ignore: name */
|
|
344
|
+
keyword: (print, node, path, options2) => {
|
|
345
|
+
const keywordCase = isDataType(path.ancestors) ? options2.sqlTypeCase : options2.sqlKeywordCase;
|
|
346
|
+
switch (keywordCase) {
|
|
347
|
+
case "preserve":
|
|
348
|
+
return path.node.text;
|
|
349
|
+
case "upper":
|
|
350
|
+
return path.node.text.toUpperCase();
|
|
351
|
+
case "lower":
|
|
352
|
+
return path.node.text.toLowerCase();
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
all_columns: () => "*",
|
|
356
|
+
empty: () => []
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// src/syntax/cast.ts
|
|
360
|
+
var castMap = {
|
|
361
|
+
cast_definition: (print) => group(print.spaced(["from", "asKw", "to"]))
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// src/syntax/comment.ts
|
|
365
|
+
var commentMap = {
|
|
366
|
+
comment_stmt: (print) => group([
|
|
367
|
+
print.spaced(["commentKw", "onKw", "target", "isKw"]),
|
|
368
|
+
indent([line, print("message")])
|
|
369
|
+
]),
|
|
370
|
+
comment_target_aggregate: (print) => group([print.spaced(["aggregateKw", "name"]), print(["params"])]),
|
|
371
|
+
comment_target_function: (print) => group([print.spaced(["functionKw", "name"]), print(["params"])]),
|
|
372
|
+
comment_target_procedure: (print) => group([print.spaced(["procedureKw", "name"]), print(["params"])]),
|
|
373
|
+
comment_target_routine: (print) => group([print.spaced(["routineKw", "name"]), print(["params"])]),
|
|
374
|
+
comment_target_access_method: (print) => group(print.spaced(["accessMethodKw", "name"])),
|
|
375
|
+
comment_target_cast: (print) => group(print.spaced(["castKw", "args"])),
|
|
376
|
+
comment_target_collation: (print) => group(print.spaced(["collationKw", "name"])),
|
|
377
|
+
comment_target_column: (print) => group(print.spaced(["columnKw", "name"])),
|
|
378
|
+
comment_target_table_constraint: (print) => group(print.spaced(["constraintKw", "name", "onKw", "tableName"])),
|
|
379
|
+
comment_target_domain_constraint: (print) => group(
|
|
380
|
+
print.spaced(["constraintKw", "name", "onKw", "domainKw", "domainName"])
|
|
381
|
+
),
|
|
382
|
+
comment_target_conversion: (print) => group(print.spaced(["conversionKw", "name"])),
|
|
383
|
+
comment_target_database: (print) => group(print.spaced(["databaseKw", "name"])),
|
|
384
|
+
comment_target_domain: (print) => group(print.spaced(["domainKw", "name"])),
|
|
385
|
+
comment_target_extension: (print) => group(print.spaced(["extensionKw", "name"])),
|
|
386
|
+
comment_target_event_trigger: (print) => group(print.spaced(["eventTriggerKw", "name"])),
|
|
387
|
+
comment_target_foreign_data_wrapper: (print) => group(print.spaced(["foreignDataWrapperKw", "name"])),
|
|
388
|
+
comment_target_foreign_table: (print) => group(print.spaced(["foreignTableKw", "name"])),
|
|
389
|
+
comment_target_index: (print) => group(print.spaced(["indexKw", "name"])),
|
|
390
|
+
comment_target_language: (print) => group(print.spaced(["languageKw", "name"])),
|
|
391
|
+
comment_target_large_object: (print) => group(print.spaced(["largeObjectKw", "oid"])),
|
|
392
|
+
comment_target_materialized_view: (print) => group(print.spaced(["materializedViewKw", "name"])),
|
|
393
|
+
comment_target_operator_class: (print) => group(print.spaced(["operatorClassKw", "name", "usingKw", "methodName"])),
|
|
394
|
+
comment_target_operator_family: (print) => group(print.spaced(["operatorFamilyKw", "name", "usingKw", "methodName"])),
|
|
395
|
+
comment_target_policy: (print) => group(print.spaced(["policyKw", "name", "onKw", "tableName"])),
|
|
396
|
+
comment_target_publication: (print) => group(print.spaced(["publicationKw", "name"])),
|
|
397
|
+
comment_target_role: (print) => group(print.spaced(["roleKw", "name"])),
|
|
398
|
+
comment_target_rule: (print) => group(print.spaced(["ruleKw", "name", "onKw", "tableName"])),
|
|
399
|
+
comment_target_schema: (print) => group(print.spaced(["schemaKw", "name"])),
|
|
400
|
+
comment_target_sequence: (print) => group(print.spaced(["sequenceKw", "name"])),
|
|
401
|
+
comment_target_server: (print) => group(print.spaced(["serverKw", "name"])),
|
|
402
|
+
comment_target_statistics: (print) => group(print.spaced(["statisticsKw", "name"])),
|
|
403
|
+
comment_target_subscription: (print) => group(print.spaced(["subscriptionKw", "name"])),
|
|
404
|
+
comment_target_table: (print) => group(print.spaced(["tableKw", "name"])),
|
|
405
|
+
comment_target_tablespace: (print) => group(print.spaced(["tablespaceKw", "name"])),
|
|
406
|
+
comment_target_text_search_configuration: (print) => group(print.spaced(["textSearchConfigurationKw", "name"])),
|
|
407
|
+
comment_target_text_search_dictionary: (print) => group(print.spaced(["textSearchDictionaryKw", "name"])),
|
|
408
|
+
comment_target_text_search_parser: (print) => group(print.spaced(["textSearchParserKw", "name"])),
|
|
409
|
+
comment_target_text_search_template: (print) => group(print.spaced(["textSearchTemplateKw", "name"])),
|
|
410
|
+
comment_target_transform: (print) => group(
|
|
411
|
+
print.spaced([
|
|
412
|
+
"transformForKw",
|
|
413
|
+
"typeName",
|
|
414
|
+
"languageKw",
|
|
415
|
+
"languageName"
|
|
416
|
+
])
|
|
417
|
+
),
|
|
418
|
+
comment_target_trigger: (print) => group(print.spaced(["triggerKw", "name", "onKw", "tableName"])),
|
|
419
|
+
comment_target_type: (print) => group(print.spaced(["typeKw", "name"])),
|
|
420
|
+
comment_target_view: (print) => group(print.spaced(["viewKw", "name"]))
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// src/syntax/create_table.ts
|
|
424
|
+
var createTableMap = {
|
|
425
|
+
/** cst-ignore: clauses */
|
|
426
|
+
create_table_stmt: (print, node, ...rest) => group([
|
|
427
|
+
print.spaced([
|
|
428
|
+
"createKw",
|
|
429
|
+
"orReplaceKw",
|
|
430
|
+
"kind",
|
|
431
|
+
"tableKw",
|
|
432
|
+
"ifNotExistsKw",
|
|
433
|
+
"name",
|
|
434
|
+
"partitionOf",
|
|
435
|
+
"ofType",
|
|
436
|
+
"columns"
|
|
437
|
+
]),
|
|
438
|
+
printClauses(print, node, ...rest),
|
|
439
|
+
node.options ? [line, group(print("options"))] : []
|
|
440
|
+
]),
|
|
441
|
+
relation_kind: (print) => print.spaced("kindKw"),
|
|
442
|
+
column_definition: (print) => print.spaced(["name", "dataType", "withOptionsKw", "constraints"]),
|
|
443
|
+
table_option: (print, node) => {
|
|
444
|
+
if (node.value && node.hasEq) {
|
|
445
|
+
return [print.spaced("name"), " = ", print.spaced("value")];
|
|
446
|
+
} else if (node.value) {
|
|
447
|
+
return [print.spaced("name"), " ", print.spaced("value")];
|
|
448
|
+
} else {
|
|
449
|
+
return print.spaced("name");
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
create_table_like_clause: (print) => print.spaced(["likeKw", "name", "options"]),
|
|
453
|
+
table_like_option: (print) => print.spaced(["includingOrExcludingKw", "optionKw"]),
|
|
454
|
+
create_table_copy_clause: (print) => print.spaced(["copyKw", "name"]),
|
|
455
|
+
create_table_clone_clause: (print) => print.spaced(["cloneKw", "table"]),
|
|
456
|
+
with_partition_columns_clause: (print) => print.spaced(["withPartitionColumnsKw", "columns"]),
|
|
457
|
+
create_table_using_clause: (print) => print.spaced(["usingKw", "module"]),
|
|
458
|
+
create_table_inherits_clause: (print) => print.spaced(["inheritsKw", "tables"]),
|
|
459
|
+
create_table_partition_by_clause: (print) => print.spaced(["partitionByKw", "strategyKw", "columns"]),
|
|
460
|
+
create_table_partition_of_clause: (print) => print.spaced(["partitionOfKw", "table"]),
|
|
461
|
+
create_table_partition_bound_clause: (print) => print.spaced(["forValuesKw", "bound"]),
|
|
462
|
+
partition_bound_in: (print) => print.spaced(["inKw", "values"]),
|
|
463
|
+
partition_bound_from_to: (print) => print.spaced(["fromKw", "from", "toKw", "to"]),
|
|
464
|
+
partition_bound_minvalue: (print) => print.spaced("minvalueKw"),
|
|
465
|
+
partition_bound_maxvalue: (print) => print.spaced("maxvalueKw"),
|
|
466
|
+
partition_bound_with: (print) => print.spaced(["withKw", "values"]),
|
|
467
|
+
partition_bound_modulus: (print) => print.spaced(["modulusKw", "value"]),
|
|
468
|
+
partition_bound_remainder: (print) => print.spaced(["remainderKw", "value"]),
|
|
469
|
+
create_table_default_partition_clause: (print) => print.spaced("defaultKw"),
|
|
470
|
+
create_table_of_type_clause: (print) => print.spaced(["ofKw", "typeName"]),
|
|
471
|
+
using_access_method_clause: (print) => print.spaced(["usingKw", "method"]),
|
|
472
|
+
tablespace_clause: (print) => print.spaced(["tablespaceKw", "name"]),
|
|
473
|
+
create_table_without_oids_clause: (print) => print.spaced("withoutOidsKw"),
|
|
474
|
+
create_table_on_commit_clause: (print) => print.spaced(["onCommitKw", "actionKw"]),
|
|
475
|
+
with_data_clause: (print) => print.spaced("withDataKw"),
|
|
476
|
+
create_table_server_clause: (print) => print.spaced(["serverKw", "name"])
|
|
477
|
+
};
|
|
478
|
+
var printClauses = (print, node) => {
|
|
479
|
+
if (node.clauses.length === 1 && isAsClause(node.clauses[0])) {
|
|
480
|
+
return [" ", print("clauses")];
|
|
481
|
+
} else if (node.clauses.length > 0) {
|
|
482
|
+
return [line, join(line, print("clauses"))];
|
|
483
|
+
} else {
|
|
484
|
+
return [];
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
// src/syntax/data_type.ts
|
|
489
|
+
var dataTypeMap = {
|
|
490
|
+
data_type_name: (print) => print.spaced("name"),
|
|
491
|
+
// print single-word types as `TYPE(10)` and multi-word types as `MY TYPE (10)`
|
|
492
|
+
modified_data_type: (print, node) => (isMultiWordTypeName(node.dataType) ? print.spaced : print)([
|
|
493
|
+
"dataType",
|
|
494
|
+
"modifiers"
|
|
495
|
+
]),
|
|
496
|
+
setof_data_type: (print) => print.spaced(["setofKw", "dataType"]),
|
|
497
|
+
array_data_type: (print) => print(["dataType", "bounds"]),
|
|
498
|
+
array_bounds: (print) => ["[", print("bounds"), "]"],
|
|
499
|
+
time_data_type: (print, node) => group(
|
|
500
|
+
join(" ", [
|
|
501
|
+
print(["timeKw", "precision"]),
|
|
502
|
+
...node.timeZoneKw ? [print.spaced("timeZoneKw")] : []
|
|
503
|
+
])
|
|
504
|
+
),
|
|
505
|
+
interval_data_type: (print) => print.spaced(["intervalKw", "unit"]),
|
|
506
|
+
interval_unit_range: (print) => print.spaced(["fromUnit", "toKw", "toUnit"]),
|
|
507
|
+
interval_unit: (print) => print.spaced(["unitKw", "precision"]),
|
|
508
|
+
parametric_data_type: (print) => print(["typeKw", "params"]),
|
|
509
|
+
generic_type_params: (print) => group(["<", indent([softline, print("params")]), softline, ">"]),
|
|
510
|
+
array_type_param: (print) => print.spaced(["dataType", "constraints"]),
|
|
511
|
+
struct_type_param: (print) => print.spaced(["name", "dataType", "constraints"]),
|
|
512
|
+
table_data_type: (print) => print.spaced(["tableKw", "columns"])
|
|
513
|
+
};
|
|
514
|
+
function isMultiWordTypeName(node) {
|
|
515
|
+
return isDataTypeName(node) && isArray(node.name) && node.name.length > 1;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/syntax/dcl.ts
|
|
519
|
+
var dclMap = {
|
|
520
|
+
grant_privilege_stmt: (print) => group(
|
|
521
|
+
join(print.dynamicLine(), [
|
|
522
|
+
group([print("grantKw"), indent([line, print("privileges")])]),
|
|
523
|
+
group(print.spaced(["onKw", "resource"])),
|
|
524
|
+
group([print("toKw"), indent([line, print("roles")])]),
|
|
525
|
+
...print("clauses")
|
|
526
|
+
])
|
|
527
|
+
),
|
|
528
|
+
grant_role_stmt: (print) => group(
|
|
529
|
+
join(print.dynamicLine(), [
|
|
530
|
+
group(
|
|
531
|
+
join(line, [
|
|
532
|
+
group([print("grantKw"), indent([line, print("grantedRoles")])]),
|
|
533
|
+
group([print("toKw"), indent([line, print("granteeRoles")])])
|
|
534
|
+
])
|
|
535
|
+
),
|
|
536
|
+
...print("clauses")
|
|
537
|
+
])
|
|
538
|
+
),
|
|
539
|
+
revoke_privilege_stmt: (print) => group(
|
|
540
|
+
join(print.dynamicLine(), [
|
|
541
|
+
group([
|
|
542
|
+
print.spaced(["revokeKw", "option"]),
|
|
543
|
+
indent([line, print("privileges")])
|
|
544
|
+
]),
|
|
545
|
+
group(print.spaced(["onKw", "resource"])),
|
|
546
|
+
group([print("fromKw"), indent([line, print("roles")])]),
|
|
547
|
+
...print(["grantedBy", "behaviorKw"])
|
|
548
|
+
])
|
|
549
|
+
),
|
|
550
|
+
revoke_role_stmt: (print) => group(
|
|
551
|
+
join(print.dynamicLine(), [
|
|
552
|
+
group(
|
|
553
|
+
join(line, [
|
|
554
|
+
group([
|
|
555
|
+
print.spaced(["revokeKw", "option"]),
|
|
556
|
+
indent([line, print("grantedRoles")])
|
|
557
|
+
]),
|
|
558
|
+
group([print("fromKw"), indent([line, print("granteeRoles")])])
|
|
559
|
+
])
|
|
560
|
+
),
|
|
561
|
+
...print(["grantedBy", "behaviorKw"])
|
|
562
|
+
])
|
|
563
|
+
),
|
|
564
|
+
privilege: (print) => print.spaced(["privilegeKw", "columns"]),
|
|
565
|
+
all_privileges: (print) => print.spaced(["allKw", "privilegesKw", "columns"]),
|
|
566
|
+
grant_resource_table: (print) => group(print.spaced(["tableKw", "tables"])),
|
|
567
|
+
grant_resource_view: (print) => group(print.spaced(["viewKw", "views"])),
|
|
568
|
+
grant_resource_schema: (print) => group(print.spaced(["schemaKw", "schemas"])),
|
|
569
|
+
grant_resource_sequence: (print) => group(print.spaced(["sequenceKw", "sequences"])),
|
|
570
|
+
grant_resource_database: (print) => group(print.spaced(["databaseKw", "databases"])),
|
|
571
|
+
grant_resource_domain: (print) => group(print.spaced(["domainKw", "domains"])),
|
|
572
|
+
grant_resource_foreign_data_wrapper: (print) => group(print.spaced(["foreignDataWrapperKw", "dataWrappers"])),
|
|
573
|
+
grant_resource_foreign_server: (print) => group(print.spaced(["foreignServerKw", "servers"])),
|
|
574
|
+
grant_resource_function: (print) => group(print.spaced(["functionKw", "functions"])),
|
|
575
|
+
grant_resource_language: (print) => group(print.spaced(["languageKw", "languages"])),
|
|
576
|
+
grant_resource_large_object: (print) => group(print.spaced(["largeObjectKw", "oids"])),
|
|
577
|
+
grant_resource_postgresql_option: (print) => group(print.spaced(["parameterKw", "options"])),
|
|
578
|
+
grant_resource_tablespace: (print) => group(print.spaced(["tablespaceKw", "tablespaces"])),
|
|
579
|
+
grant_resource_type: (print) => group(print.spaced(["typeKw", "types"])),
|
|
580
|
+
grant_resource_all_tables_in_schema: (print) => group(print.spaced(["allTablesInSchemaKw", "schemas"])),
|
|
581
|
+
grant_resource_all_sequences_in_schema: (print) => group(print.spaced(["allSequencesInSchemaKw", "schemas"])),
|
|
582
|
+
grant_resource_all_functions_in_schema: (print) => group(print.spaced(["allFunctionsInSchemaKw", "schemas"])),
|
|
583
|
+
with_grant_option_clause: (print) => group(print.spaced(["withKw", "nameKw", "value"])),
|
|
584
|
+
grant_option_for_clause: (print) => group(print.spaced(["nameKw", "optionForKw"])),
|
|
585
|
+
granted_by_clause: (print) => group(print.spaced(["grantedByKw", "role"])),
|
|
586
|
+
grantee_public: (print) => print("publicKw"),
|
|
587
|
+
grantee_group: (print) => group(print.spaced(["groupKw", "name"])),
|
|
588
|
+
alter_default_privileges_stmt: (print) => group(
|
|
589
|
+
join(print.dynamicLine(), [
|
|
590
|
+
print.spaced("alterDefaultPrivilegesKw"),
|
|
591
|
+
...print("clauses"),
|
|
592
|
+
print("action")
|
|
593
|
+
])
|
|
594
|
+
),
|
|
595
|
+
default_acl_for_role_clause: (print) => group(print.spaced(["forKw", "roleKw", "roles"])),
|
|
596
|
+
default_acl_in_schema_clause: (print) => group(print.spaced(["inKw", "schemaKw", "schemas"])),
|
|
597
|
+
grant_default_privileges_action: (print) => group(
|
|
598
|
+
join(line, [
|
|
599
|
+
group(print.spaced(["grantKw", "privileges", "onKw", "resourcesKw"])),
|
|
600
|
+
group(print.spaced(["toKw", "roles", "withGrantOption"]))
|
|
601
|
+
])
|
|
602
|
+
),
|
|
603
|
+
revoke_default_privileges_action: (print) => group(
|
|
604
|
+
join(line, [
|
|
605
|
+
group([
|
|
606
|
+
print.spaced(["revokeKw", "grantOptionFor"]),
|
|
607
|
+
indent([
|
|
608
|
+
line,
|
|
609
|
+
join(line, [
|
|
610
|
+
group(print("privileges")),
|
|
611
|
+
print.spaced(["onKw", "resourcesKw"])
|
|
612
|
+
])
|
|
613
|
+
])
|
|
614
|
+
]),
|
|
615
|
+
group(print.spaced(["fromKw", "roles", "behaviorKw"]))
|
|
616
|
+
])
|
|
617
|
+
)
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
// src/syntax/delete.ts
|
|
621
|
+
var deleteMap = {
|
|
622
|
+
delete_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
|
|
623
|
+
delete_clause: (print) => print.spaced(["deleteKw", "modifiers", "fromKw", "tables"])
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
// src/syntax/do.ts
|
|
627
|
+
var doMap = {
|
|
628
|
+
do_stmt: (print) => group(print.spaced(["doKw", "language", "body"]))
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
// src/syntax/domain.ts
|
|
632
|
+
var domainMap = {
|
|
633
|
+
create_domain_stmt: (print, node) => group([
|
|
634
|
+
print.spaced(["createDomainKw", "name", "asKw", "dataType"]),
|
|
635
|
+
node.constraints.length > 0 ? indent([print.dynamicLine(), join(line, print("constraints"))]) : []
|
|
636
|
+
]),
|
|
637
|
+
alter_domain_stmt: (print) => group(print.spaced(["alterDomainKw", "name", "action"])),
|
|
638
|
+
drop_domain_stmt: (print) => group(
|
|
639
|
+
print.spaced(["dropDomainKw", "ifExistsKw", "domains", "behaviorKw"])
|
|
640
|
+
)
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
// src/syntax/drop_table.ts
|
|
644
|
+
var dropTableMap = {
|
|
645
|
+
drop_table_stmt: (print) => group(
|
|
646
|
+
print.spaced([
|
|
647
|
+
"dropKw",
|
|
648
|
+
"kind",
|
|
649
|
+
"tableKw",
|
|
650
|
+
"ifExistsKw",
|
|
651
|
+
"tables",
|
|
652
|
+
"behaviorKw"
|
|
653
|
+
])
|
|
654
|
+
)
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
// src/syntax/explain.ts
|
|
658
|
+
var explainMap = {
|
|
659
|
+
explain_stmt: (print) => group([
|
|
660
|
+
print.spaced(["explainKw", "analyzeKw", "queryPlanKw"]),
|
|
661
|
+
indent([line, print("statement")])
|
|
662
|
+
])
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
// src/syntax/expr.ts
|
|
666
|
+
var exprMap = {
|
|
667
|
+
list_expr: (print, node, path) => {
|
|
668
|
+
const parent = path.getParentNode();
|
|
669
|
+
const children = print("items").map((it) => group(it));
|
|
670
|
+
const lineType = isValuesClause(parent) ? hardline : line;
|
|
671
|
+
if (isEmpty(last(node.items))) {
|
|
672
|
+
return [
|
|
673
|
+
join([",", lineType], children.slice(0, -1)),
|
|
674
|
+
",",
|
|
675
|
+
last(children)
|
|
676
|
+
];
|
|
677
|
+
} else {
|
|
678
|
+
return join([",", lineType], children);
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
paren_expr: (print, node, path) => {
|
|
682
|
+
if (isParenExpr(node.expr)) {
|
|
683
|
+
return print("expr");
|
|
684
|
+
}
|
|
685
|
+
if (isListExpr(path.getParentNode(0)) && isFuncArgs(path.getParentNode(1)) && !isSelectStmt(node.expr) && !isCompoundSelectStmt(node.expr)) {
|
|
686
|
+
return print("expr");
|
|
687
|
+
}
|
|
688
|
+
const parent = path.getParentNode();
|
|
689
|
+
const lineStyle = isCreateTableStmt(parent) && print.dynamicLine() === hardline ? hardline : softline;
|
|
690
|
+
return group(["(", indent([lineStyle, print("expr")]), lineStyle, ")"]);
|
|
691
|
+
},
|
|
692
|
+
binary_expr: (print, node) => {
|
|
693
|
+
if (isKeyword(node.operator) && isBooleanOp(node.operator)) {
|
|
694
|
+
return join(line, [print("left"), print.spaced(["operator", "right"])]);
|
|
695
|
+
}
|
|
696
|
+
if (node.operator === "") {
|
|
697
|
+
return print.spaced(["left", "right"]);
|
|
698
|
+
}
|
|
699
|
+
return print.spaced(["left", "operator", "right"]);
|
|
700
|
+
},
|
|
701
|
+
prefix_op_expr: (print, node) => (isString(node.operator) ? print : print.spaced)(["operator", "expr"]),
|
|
702
|
+
postfix_op_expr: (print) => print.spaced(["expr", "operator"]),
|
|
703
|
+
between_expr: (print) => print.spaced(["left", "betweenKw", "begin", "andKw", "end"]),
|
|
704
|
+
case_expr: (print) => [
|
|
705
|
+
print.spaced(["caseKw", "expr"]),
|
|
706
|
+
indent([hardline, join(hardline, print("clauses"))]),
|
|
707
|
+
hardline,
|
|
708
|
+
print("endKw")
|
|
709
|
+
],
|
|
710
|
+
case_when: (print, node) => {
|
|
711
|
+
if (isProgram(node.result)) {
|
|
712
|
+
return [
|
|
713
|
+
print.spaced(["whenKw", "condition", "thenKw"]),
|
|
714
|
+
indent([hardline, stripTrailingHardline(print("result"))])
|
|
715
|
+
];
|
|
716
|
+
}
|
|
717
|
+
return print.spaced(["whenKw", "condition", "thenKw", "result"]);
|
|
718
|
+
},
|
|
719
|
+
case_else: (print, node) => {
|
|
720
|
+
if (isProgram(node.result)) {
|
|
721
|
+
return [
|
|
722
|
+
print("elseKw"),
|
|
723
|
+
indent([hardline, stripTrailingHardline(print("result"))])
|
|
724
|
+
];
|
|
725
|
+
}
|
|
726
|
+
return print.spaced(["elseKw", "result"]);
|
|
727
|
+
},
|
|
728
|
+
member_expr: (print, node) => isArraySubscript(node.property) ? print(["object", "property"]) : [print("object"), ".", print("property")],
|
|
729
|
+
bigquery_quoted_member_expr: (print) => ["`", print("expr"), "`"],
|
|
730
|
+
array_subscript: (print) => group(["[", indent([softline, print("expr")]), softline, "]"]),
|
|
731
|
+
array_subscript_specifier: (print) => print(["specifierKw", "args"]),
|
|
732
|
+
array_slice_specifier: (print) => [print("from"), ":", print("to")],
|
|
733
|
+
func_call: (print) => {
|
|
734
|
+
const fnCall = print(["name", "args"]);
|
|
735
|
+
const extras = print(["filter", "over"]);
|
|
736
|
+
if (extras.length > 1) {
|
|
737
|
+
return group([fnCall, indent([line, join(line, extras)])]);
|
|
738
|
+
} else {
|
|
739
|
+
return group(join(" ", [fnCall, ...extras]));
|
|
740
|
+
}
|
|
741
|
+
},
|
|
742
|
+
func_args: (print, node) => join(line, [
|
|
743
|
+
...print(["distinctKw", "args"]),
|
|
744
|
+
...node.nullHandlingKw ? print.spaced("nullHandlingKw") : [],
|
|
745
|
+
...print(["orderBy", "limit", "having"])
|
|
746
|
+
]),
|
|
747
|
+
filter_arg: (print) => print.spaced(["filterKw", "where"]),
|
|
748
|
+
over_arg: (print) => print.spaced(["overKw", "window"]),
|
|
749
|
+
having_arg: (print) => print.spaced(["havingKw", "minMaxKw", "expr"]),
|
|
750
|
+
named_arg: (print) => group([
|
|
751
|
+
print("name"),
|
|
752
|
+
" ",
|
|
753
|
+
print("operator"),
|
|
754
|
+
indent([line, print("value")])
|
|
755
|
+
]),
|
|
756
|
+
cast_expr: (print) => print(["castKw", "args"]),
|
|
757
|
+
cast_arg: (print) => print.spaced(["expr", "asKw", "dataType", "format"]),
|
|
758
|
+
cast_format: (print) => print.spaced(["formatKw", "string", "timezone"]),
|
|
759
|
+
cast_format_timezone: (print) => print.spaced(["atTimeZoneKw", "timezone"]),
|
|
760
|
+
cast_operator_expr: (print) => [
|
|
761
|
+
print("left"),
|
|
762
|
+
print("operator"),
|
|
763
|
+
print("right")
|
|
764
|
+
],
|
|
765
|
+
string_with_charset: (print) => ["_", print(["charset", "string"])],
|
|
766
|
+
raise_expr: (print) => print(["raiseKw", "args"]),
|
|
767
|
+
raise_expr_type: (print) => print("typeKw"),
|
|
768
|
+
extract_expr: (print) => print(["extractKw", "args"]),
|
|
769
|
+
extract_from: (print) => print.spaced(["unit", "fromKw", "expr"]),
|
|
770
|
+
week_expr: (print) => print(["weekKw", "args"]),
|
|
771
|
+
interval_literal: (print) => print.spaced(["intervalKw", "precision", "value", "unit"]),
|
|
772
|
+
array_literal_expr: (print) => print(["arrayKw", "expr"]),
|
|
773
|
+
array_expr: (print) => group(["[", indent([softline, print("expr")]), softline, "]"]),
|
|
774
|
+
struct_expr: (print) => group(["(", indent([softline, print("expr")]), softline, ")"]),
|
|
775
|
+
typed_expr: (print) => print(["dataType", "expr"]),
|
|
776
|
+
row_constructor: (print) => print(["rowKw", "row"]),
|
|
777
|
+
array_constructor: (print) => print(["arrayKw", "expr"]),
|
|
778
|
+
quantifier_expr: (print) => print.spaced(["quantifierKw", "expr"]),
|
|
779
|
+
full_text_match_expr: (print) => print.spaced(["matchKw", "columns", "againstKw", "args"]),
|
|
780
|
+
full_text_match_args: (print) => print.spaced(["expr", "modifier"]),
|
|
781
|
+
/** cst-ignore: value */
|
|
782
|
+
number_literal: (print) => print("text"),
|
|
783
|
+
/** cst-ignore: value */
|
|
784
|
+
boolean_literal: (print, node, path, options2) => printLiteral(node.valueKw, options2),
|
|
785
|
+
/** cst-ignore: value */
|
|
786
|
+
string_literal: (print) => print("text"),
|
|
787
|
+
/** cst-ignore: value */
|
|
788
|
+
blob_literal: (print) => print("text"),
|
|
789
|
+
/** cst-ignore: value */
|
|
790
|
+
null_literal: (print, node, path, options2) => printLiteral(node.nullKw, options2),
|
|
791
|
+
numeric_literal: (print) => print.spaced(["numericKw", "string"]),
|
|
792
|
+
bignumeric_literal: (print) => print.spaced(["bignumericKw", "string"]),
|
|
793
|
+
date_literal: (print) => print.spaced(["dateKw", "string"]),
|
|
794
|
+
time_literal: (print) => print.spaced(["timeKw", "string"]),
|
|
795
|
+
datetime_literal: (print) => print.spaced(["datetimeKw", "string"]),
|
|
796
|
+
timestamp_literal: (print) => print.spaced(["timestampKw", "string"]),
|
|
797
|
+
json_literal: (print) => print.spaced(["jsonKw", "string"]),
|
|
798
|
+
jsonb_literal: (print) => print.spaced(["jsonbKw", "string"]),
|
|
799
|
+
/** cst-ignore: name */
|
|
800
|
+
identifier: (print, node, path, options2) => {
|
|
801
|
+
if (isQuotedIdentifier(node) || isInsideBigqueryQuotedMemberExpr(path)) {
|
|
802
|
+
return print("text");
|
|
803
|
+
} else {
|
|
804
|
+
if (isFunctionName(node, path)) {
|
|
805
|
+
return printFunctionName(node, options2);
|
|
806
|
+
} else {
|
|
807
|
+
return printIdentifier(node, options2);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
/** cst-ignore: name */
|
|
812
|
+
variable: (print, node, path, options2) => isQuotedVariable(node) ? print("text") : printIdentifier(node, options2),
|
|
813
|
+
parameter: (print, node, path, options2) => isQuotedParameter(node) ? print("text") : printIdentifier(node, options2)
|
|
814
|
+
};
|
|
815
|
+
var printLiteral = (node, options2) => {
|
|
816
|
+
switch (options2.sqlLiteralCase) {
|
|
817
|
+
case "preserve":
|
|
818
|
+
return node.text;
|
|
819
|
+
case "upper":
|
|
820
|
+
return node.text.toUpperCase();
|
|
821
|
+
case "lower":
|
|
822
|
+
return node.text.toLowerCase();
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
var printIdentifier = (node, options2) => {
|
|
826
|
+
switch (options2.sqlIdentifierCase) {
|
|
827
|
+
case "preserve":
|
|
828
|
+
return node.text;
|
|
829
|
+
case "upper":
|
|
830
|
+
return node.text.toUpperCase();
|
|
831
|
+
case "lower":
|
|
832
|
+
return node.text.toLowerCase();
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
var printFunctionName = (node, options2) => {
|
|
836
|
+
switch (options2.sqlFunctionCase) {
|
|
837
|
+
case "preserve":
|
|
838
|
+
return node.text;
|
|
839
|
+
case "upper":
|
|
840
|
+
return node.text.toUpperCase();
|
|
841
|
+
case "lower":
|
|
842
|
+
return node.text.toLowerCase();
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
var isQuotedIdentifier = (node) => node.name !== node.text;
|
|
846
|
+
var isQuotedVariable = (node) => !(node.text === "@" + node.name || node.text === "@@" + node.name);
|
|
847
|
+
var isQuotedParameter = (node) => /`$/.test(node.text);
|
|
848
|
+
var isInsideBigqueryQuotedMemberExpr = (path) => path.ancestors.some(isBigqueryQuotedMemberExpr);
|
|
849
|
+
var isFunctionName = (node, path) => {
|
|
850
|
+
const parent = path.parent;
|
|
851
|
+
if (isFunctionContext(parent, path.grandparent)) {
|
|
852
|
+
return true;
|
|
853
|
+
}
|
|
854
|
+
if (isMemberExpr(parent) && parent.property === node) {
|
|
855
|
+
const [_, gp, ggp] = path.ancestors;
|
|
856
|
+
return isFunctionContext(gp, ggp);
|
|
857
|
+
}
|
|
858
|
+
return false;
|
|
859
|
+
};
|
|
860
|
+
var isFunctionContext = (node, parent) => {
|
|
861
|
+
return isFuncCall(node) || isFunctionSignature(node) || isCreateFunctionStmt(node) || isCreateProcedureStmt(node) || isAlterActionRename(node) && (isAlterFunctionStmt(parent) || isAlterProcedureStmt(parent)) || isExecuteClause(node) && isCreateTriggerStmt(parent);
|
|
862
|
+
};
|
|
863
|
+
var isBooleanOp = ({ name }) => name === "AND" || name === "OR";
|
|
864
|
+
|
|
865
|
+
// src/syntax/extension.ts
|
|
866
|
+
var extensionMap = {
|
|
867
|
+
create_extension_stmt: (print, node) => group([
|
|
868
|
+
print.spaced(["createExtensionKw", "ifNotExistsKw", "name"]),
|
|
869
|
+
node.clauses.length > 0 ? indent([line, print.spaced(["withKw", "clauses"])]) : []
|
|
870
|
+
]),
|
|
871
|
+
extension_cascade_clause: (print) => group(print.spaced(["cascadeKw"])),
|
|
872
|
+
extension_schema_clause: (print) => group(print.spaced(["schemaKw", "name"])),
|
|
873
|
+
extension_version_clause: (print) => group(print.spaced(["versionKw", "name"])),
|
|
874
|
+
drop_extension_stmt: (print) => group(
|
|
875
|
+
print.spaced(["dropExtensionKw", "ifExistsKw", "names", "behaviorKw"])
|
|
876
|
+
)
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
// src/syntax/frame.ts
|
|
880
|
+
var frameMap = {
|
|
881
|
+
frame_clause: (print, node) => [
|
|
882
|
+
print.spaced(["unitKw", "extent"]),
|
|
883
|
+
node.exclusion ? [hardline, print("exclusion")] : []
|
|
884
|
+
],
|
|
885
|
+
frame_bound_current_row: (print) => print.spaced("currentRowKw"),
|
|
886
|
+
frame_bound_preceding: (print) => print.spaced(["expr", "precedingKw"]),
|
|
887
|
+
frame_bound_following: (print) => print.spaced(["expr", "followingKw"]),
|
|
888
|
+
frame_unbounded: (print) => print.spaced("unboundedKw"),
|
|
889
|
+
frame_between: (print) => print.spaced(["betweenKw", "begin", "andKw", "end"]),
|
|
890
|
+
frame_exclusion: (print) => print.spaced(["excludeKw", "kindKw"])
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
// src/syntax/function.ts
|
|
894
|
+
var functionMap = {
|
|
895
|
+
create_function_stmt: (print, node) => group([
|
|
896
|
+
print.spaced([
|
|
897
|
+
"createKw",
|
|
898
|
+
"orReplaceKw",
|
|
899
|
+
"temporaryKw",
|
|
900
|
+
"tableKw",
|
|
901
|
+
"functionKw",
|
|
902
|
+
"ifNotExistsKw",
|
|
903
|
+
"name"
|
|
904
|
+
]),
|
|
905
|
+
print("params"),
|
|
906
|
+
hasOnlyAsClause(node) ? [" ", group(print("clauses"))] : [
|
|
907
|
+
hardline,
|
|
908
|
+
join(
|
|
909
|
+
hardline,
|
|
910
|
+
print("clauses").map((cls) => group(cls))
|
|
911
|
+
)
|
|
912
|
+
]
|
|
913
|
+
]),
|
|
914
|
+
function_signature: (print) => print(["name", "params"]),
|
|
915
|
+
function_param: (print) => print.spaced(["mode", "name", "dataType", "default"]),
|
|
916
|
+
function_param_default: (print) => print.spaced(["operator", "expr"]),
|
|
917
|
+
return_clause: (print) => print.spaced(["returnKw", "expr"]),
|
|
918
|
+
function_behavior_clause: (print) => print.spaced(["behaviorKw"]),
|
|
919
|
+
function_security_clause: (print) => print.spaced(["externalKw", "securityKw"]),
|
|
920
|
+
function_cost_clause: (print) => print.spaced(["costKw", "cost"]),
|
|
921
|
+
function_rows_clause: (print) => print.spaced(["rowsKw", "rows"]),
|
|
922
|
+
function_support_clause: (print) => print.spaced(["supportKw", "name"]),
|
|
923
|
+
function_window_clause: (print) => print.spaced("windowKw"),
|
|
924
|
+
function_transform_clause: (print) => print.spaced(["transformKw", "types"]),
|
|
925
|
+
transform_type: (print) => print.spaced(["forTypeKw", "dataType"]),
|
|
926
|
+
dynamically_loaded_function: (print) => join(", ", print(["objectFile", "symbol"])),
|
|
927
|
+
drop_function_stmt: (print) => group([
|
|
928
|
+
print.spaced([
|
|
929
|
+
"dropKw",
|
|
930
|
+
"tableKw",
|
|
931
|
+
"functionKw",
|
|
932
|
+
"ifExistsKw",
|
|
933
|
+
"signatures",
|
|
934
|
+
"behaviorKw"
|
|
935
|
+
])
|
|
936
|
+
]),
|
|
937
|
+
// almost exact copy of alter_procedure_stmt
|
|
938
|
+
alter_function_stmt: (print, node) => group([
|
|
939
|
+
print.spaced(["alterKw", "functionKw"]),
|
|
940
|
+
" ",
|
|
941
|
+
print(["signature"]),
|
|
942
|
+
print.dynamicLine(),
|
|
943
|
+
join(print.dynamicLine(), print("actions")),
|
|
944
|
+
node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : []
|
|
945
|
+
])
|
|
946
|
+
};
|
|
947
|
+
var hasOnlyAsClause = (node) => node.clauses.length === 1 && isAsClause(node.clauses[0]);
|
|
948
|
+
|
|
949
|
+
// src/syntax/index.ts
|
|
950
|
+
var indexMap = {
|
|
951
|
+
create_index_stmt: (print) => group(
|
|
952
|
+
join(print.dynamicLine(), [
|
|
953
|
+
print.spaced([
|
|
954
|
+
"createKw",
|
|
955
|
+
"orReplaceKw",
|
|
956
|
+
"indexTypeKw",
|
|
957
|
+
"indexKw",
|
|
958
|
+
"concurrentlyKw",
|
|
959
|
+
"ifNotExistsKw",
|
|
960
|
+
"name",
|
|
961
|
+
"onKw",
|
|
962
|
+
"table",
|
|
963
|
+
"using",
|
|
964
|
+
"columns"
|
|
965
|
+
]),
|
|
966
|
+
...print("clauses")
|
|
967
|
+
])
|
|
968
|
+
),
|
|
969
|
+
index_specification: (print) => print.spaced(["expr", "opclass", "direction", "nullHandlingKw"]),
|
|
970
|
+
index_include_clause: (print) => print.spaced(["includeKw", "columns"]),
|
|
971
|
+
index_nulls_distinct_clause: (print) => print.spaced(["nullsDistinctKw"]),
|
|
972
|
+
index_nulls_not_distinct_clause: (print) => print.spaced(["nullsNotDistinctKw"]),
|
|
973
|
+
drop_index_stmt: (print) => group(
|
|
974
|
+
print.spaced([
|
|
975
|
+
"dropKw",
|
|
976
|
+
"indexTypeKw",
|
|
977
|
+
"indexKw",
|
|
978
|
+
"concurrentlyKw",
|
|
979
|
+
"ifExistsKw",
|
|
980
|
+
"indexes",
|
|
981
|
+
"onKw",
|
|
982
|
+
"table",
|
|
983
|
+
"behaviorKw"
|
|
984
|
+
])
|
|
985
|
+
),
|
|
986
|
+
verbose_all_columns: (print) => print.spaced("allColumnsKw"),
|
|
987
|
+
alter_index_stmt: (print) => group([
|
|
988
|
+
print.spaced(["alterKw", "indexKw", "ifExistsKw", "index"]),
|
|
989
|
+
print.dynamicLine(),
|
|
990
|
+
print("action")
|
|
991
|
+
]),
|
|
992
|
+
alter_index_all_in_tablespace_stmt: (print) => group([
|
|
993
|
+
print.spaced([
|
|
994
|
+
"alterIndexKw",
|
|
995
|
+
"allInTablespaceKw",
|
|
996
|
+
"tablespace",
|
|
997
|
+
"ownedBy"
|
|
998
|
+
]),
|
|
999
|
+
print.dynamicLine(),
|
|
1000
|
+
print("action")
|
|
1001
|
+
]),
|
|
1002
|
+
reindex_stmt: (print) => group(
|
|
1003
|
+
print.spaced([
|
|
1004
|
+
"reindexKw",
|
|
1005
|
+
"options",
|
|
1006
|
+
"targetKw",
|
|
1007
|
+
"concurrentlyKw",
|
|
1008
|
+
"name"
|
|
1009
|
+
])
|
|
1010
|
+
),
|
|
1011
|
+
reindex_option_concurrently: (print) => print.spaced(["concurrentlyKw", "value"]),
|
|
1012
|
+
reindex_option_tablespace: (print) => print.spaced(["tablespaceKw", "name"]),
|
|
1013
|
+
reindex_option_verbose: (print) => print.spaced(["verboseKw", "value"])
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
// src/syntax/insert.ts
|
|
1017
|
+
var insertMap = {
|
|
1018
|
+
insert_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
|
|
1019
|
+
insert_clause: (print, node) => group([
|
|
1020
|
+
print.spaced(["insertKw", "modifiers", "orAction", "intoKw", "table"]),
|
|
1021
|
+
node.columns ? indent([print.dynamicLine(), print("columns")]) : []
|
|
1022
|
+
]),
|
|
1023
|
+
values_clause: (print) => group([print("valuesKw"), indent([print.dynamicLine(), print("values")])]),
|
|
1024
|
+
or_alternate_action: (print) => print.spaced(["orKw", "actionKw"]),
|
|
1025
|
+
default: (print) => print("defaultKw"),
|
|
1026
|
+
default_values: (print) => print.spaced("defaultValuesKw"),
|
|
1027
|
+
upsert_clause: (print) => print.spaced(["onConflictKw", "conflictTarget", "where", "doKw", "action"]),
|
|
1028
|
+
conflict_target_on_constraint: (print) => print.spaced(["onConstraintKw", "constraint"]),
|
|
1029
|
+
upsert_action_nothing: (print) => print("nothingKw"),
|
|
1030
|
+
upsert_action_update: (print) => group([
|
|
1031
|
+
print("updateKw"),
|
|
1032
|
+
indent([
|
|
1033
|
+
print.dynamicLine(),
|
|
1034
|
+
join(print.dynamicLine(), print(["set", "where"]))
|
|
1035
|
+
])
|
|
1036
|
+
]),
|
|
1037
|
+
row_alias_clause: (print, node) => group([
|
|
1038
|
+
print.spaced(["asKw", "rowAlias"]),
|
|
1039
|
+
node.columnAliases ? indent([print.dynamicLine(), print("columnAliases")]) : []
|
|
1040
|
+
]),
|
|
1041
|
+
on_duplicate_key_update_clause: (print) => group([
|
|
1042
|
+
print.spaced("onDuplicateKeyUpdateKw"),
|
|
1043
|
+
indent([print.dynamicLine(), print("assignments")])
|
|
1044
|
+
]),
|
|
1045
|
+
overriding_clause: (print) => print.spaced("overridingKw")
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
// src/syntax/merge.ts
|
|
1049
|
+
var mergeMap = {
|
|
1050
|
+
merge_stmt: (print) => group(join(hardline, print("clauses"))),
|
|
1051
|
+
merge_clause: (print) => join(line, [
|
|
1052
|
+
print.spaced(["mergeKw", "intoKw", "target"]),
|
|
1053
|
+
print.spaced(["usingKw", "source"]),
|
|
1054
|
+
group([print("onKw"), indent([line, print("condition")])])
|
|
1055
|
+
]),
|
|
1056
|
+
merge_when_clause: (print, node) => [
|
|
1057
|
+
group([
|
|
1058
|
+
print.spaced(["whenKw", "matchedKw", "byKw"]),
|
|
1059
|
+
node.condition ? indent([line, print("condition")]) : [],
|
|
1060
|
+
[line, print("thenKw")]
|
|
1061
|
+
]),
|
|
1062
|
+
indent([hardline, group(print("action"))])
|
|
1063
|
+
],
|
|
1064
|
+
merge_when_condition: (print) => print.spaced(["andKw", "expr"]),
|
|
1065
|
+
merge_action_delete: (print) => print("deleteKw"),
|
|
1066
|
+
merge_action_insert: (print, node) => [
|
|
1067
|
+
group([
|
|
1068
|
+
print("insertKw"),
|
|
1069
|
+
node.columns ? indent([hardline, print("columns")]) : []
|
|
1070
|
+
]),
|
|
1071
|
+
line,
|
|
1072
|
+
join(hardline, print("clauses"))
|
|
1073
|
+
],
|
|
1074
|
+
merge_action_insert_row_clause: (print) => print("rowKw"),
|
|
1075
|
+
merge_action_update: (print) => print.spaced(["updateKw", "set"]),
|
|
1076
|
+
merge_action_do_nothing: (print) => print.spaced(["doNothingKw"])
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
// src/syntax/other_clauses.ts
|
|
1080
|
+
var otherClausesMap = {
|
|
1081
|
+
// CLUSTER BY clause
|
|
1082
|
+
cluster_by_clause: (print) => group([print.spaced("clusterByKw"), indent([line, print("columns")])]),
|
|
1083
|
+
// RETURNING clause
|
|
1084
|
+
returning_clause: (print) => group([print("returningKw"), indent([line, print("columns")])]),
|
|
1085
|
+
// WHERE CURRENT OF clause
|
|
1086
|
+
where_current_of_clause: (print) => print.spaced(["whereCurrentOfKw", "cursor"])
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
// src/syntax/rename_table.ts
|
|
1090
|
+
var renameTableMap = {
|
|
1091
|
+
rename_table_stmt: (print) => group([
|
|
1092
|
+
print.spaced(["renameKw", "tableKw"]),
|
|
1093
|
+
indent([line, print("actions")])
|
|
1094
|
+
]),
|
|
1095
|
+
rename_action: (print) => print.spaced(["from", "toKw", "to"])
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
// src/syntax/role.ts
|
|
1099
|
+
var roleMap = {
|
|
1100
|
+
create_role_stmt: (print, node) => group([
|
|
1101
|
+
print.spaced(["createRoleKw", "name", "withKw"]),
|
|
1102
|
+
...node.options?.length ? [indent([line, join(print.dynamicLine(), print("options"))])] : []
|
|
1103
|
+
]),
|
|
1104
|
+
alter_role_stmt: (print, node) => group([
|
|
1105
|
+
join(print.dynamicLine(), [
|
|
1106
|
+
group([print.spaced("alterRoleKw"), indent([line, print("name")])]),
|
|
1107
|
+
...node.database ? print(["database"]) : []
|
|
1108
|
+
]),
|
|
1109
|
+
node.action.type === "alter_action_with_role_options" && !node.action.withKw ? indent([print.dynamicLine(), print("action")]) : [print.dynamicLine(), print("action")]
|
|
1110
|
+
]),
|
|
1111
|
+
drop_role_stmt: (print) => group(print.spaced(["dropRoleKw", "ifExistsKw", "names"])),
|
|
1112
|
+
set_role_stmt: (print) => group(print.spaced(["setKw", "scopeKw", "roleKw", "name"])),
|
|
1113
|
+
reset_role_stmt: (print) => group(print.spaced("resetRoleKw")),
|
|
1114
|
+
role_option_keyword: (print) => print("kw"),
|
|
1115
|
+
role_option_connection_limit: (print) => group(print.spaced(["connectionLimitKw", "limit"])),
|
|
1116
|
+
role_option_password: (print) => group(print.spaced(["encryptedKw", "passwordKw", "password"])),
|
|
1117
|
+
role_option_valid_until: (print) => group(print.spaced(["validUntilKw", "timestamp"])),
|
|
1118
|
+
role_option_in_role: (print) => group(print.spaced(["inRoleKw", "names"])),
|
|
1119
|
+
role_option_role: (print) => group(print.spaced(["roleKw", "names"])),
|
|
1120
|
+
role_option_admin: (print) => group(print.spaced(["adminKw", "names"])),
|
|
1121
|
+
role_option_sysid: (print) => group(print.spaced(["sysIdKw", "sysId"])),
|
|
1122
|
+
in_database_clause: (print) => group(print.spaced(["inDatabaseKw", "name"]))
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
// src/syntax/parameter.ts
|
|
1126
|
+
var parameterMap = {
|
|
1127
|
+
// SET
|
|
1128
|
+
set_parameter_stmt: (print) => group(print.spaced(["setKw", "modifierKw", "name", "operator", "value"])),
|
|
1129
|
+
set_time_zone_parameter_stmt: (print) => group(print.spaced(["setKw", "modifierKw", "timeZoneKw", "value"])),
|
|
1130
|
+
set_parameter_clause: (print) => print.spaced(["setKw", "name", "operator", "value"]),
|
|
1131
|
+
local_parameter_value: (print) => print("localKw"),
|
|
1132
|
+
set_parameter_from_current_clause: (print) => print.spaced(["setKw", "name", "fromCurrentKw"]),
|
|
1133
|
+
// RESET
|
|
1134
|
+
reset_parameter_stmt: (print) => group(print.spaced(["resetKw", "name"])),
|
|
1135
|
+
reset_parameter_clause: (print) => print.spaced(["resetKw", "name"]),
|
|
1136
|
+
all_parameters: (print) => print("allKw"),
|
|
1137
|
+
// SHOW
|
|
1138
|
+
show_parameter_stmt: (print) => group(print.spaced(["showKw", "name"])),
|
|
1139
|
+
/** cst-ignore: value */
|
|
1140
|
+
boolean_on_off_literal: (print, node, path, options2) => printLiteral(node.valueKw, options2)
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
// src/syntax/policy.ts
|
|
1144
|
+
var policyMap = {
|
|
1145
|
+
create_policy_stmt: (print, node) => group([
|
|
1146
|
+
print.spaced(["createPolicyKw", "name", "onKw", "table"]),
|
|
1147
|
+
node.clauses.length > 0 ? print.dynamicLine() : [],
|
|
1148
|
+
join(print.dynamicLine(), print("clauses"))
|
|
1149
|
+
]),
|
|
1150
|
+
policy_permissive_clause: (print) => group(print.spaced(["asKw", "permissiveKw"])),
|
|
1151
|
+
policy_restrictive_clause: (print) => group(print.spaced(["asKw", "restrictiveKw"])),
|
|
1152
|
+
policy_command_clause: (print) => group(print.spaced(["forKw", "commandKw"])),
|
|
1153
|
+
policy_roles_clause: (print) => group(print.spaced(["toKw", "roles"])),
|
|
1154
|
+
policy_using_clause: (print) => group(print.spaced(["usingKw", "expr"])),
|
|
1155
|
+
policy_check_clause: (print) => group(print.spaced(["withKw", "checkKw", "expr"])),
|
|
1156
|
+
alter_policy_stmt: (print) => group([
|
|
1157
|
+
print.spaced(["alterPolicyKw", "name", "onKw", "table"]),
|
|
1158
|
+
print.dynamicLine(),
|
|
1159
|
+
join(print.dynamicLine(), print("actions"))
|
|
1160
|
+
]),
|
|
1161
|
+
drop_policy_stmt: (print) => group(
|
|
1162
|
+
print.spaced([
|
|
1163
|
+
"dropPolicyKw",
|
|
1164
|
+
"ifExistsKw",
|
|
1165
|
+
"name",
|
|
1166
|
+
"onKw",
|
|
1167
|
+
"table",
|
|
1168
|
+
"behaviorKw"
|
|
1169
|
+
])
|
|
1170
|
+
)
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
// src/syntax/prepared_statements.ts
|
|
1174
|
+
var preparedStatementsMap = {
|
|
1175
|
+
// EXECUTE
|
|
1176
|
+
execute_stmt: (print, node) => {
|
|
1177
|
+
if (node.args?.type === "execute_using_clause") {
|
|
1178
|
+
return group(print.spaced(["executeKw", "name", "args"]));
|
|
1179
|
+
} else {
|
|
1180
|
+
return group([print.spaced(["executeKw", "name"]), print("args")]);
|
|
1181
|
+
}
|
|
1182
|
+
},
|
|
1183
|
+
execute_immediate_stmt: (print) => group(
|
|
1184
|
+
join(hardline, [
|
|
1185
|
+
group([
|
|
1186
|
+
print.spaced(["executeKw", "immediateKw"]),
|
|
1187
|
+
indent([line, print("expr")])
|
|
1188
|
+
]),
|
|
1189
|
+
...print(["into", "using"]).map((clause) => group(clause))
|
|
1190
|
+
])
|
|
1191
|
+
),
|
|
1192
|
+
execute_into_clause: (print) => print.spaced(["intoKw", "variables"]),
|
|
1193
|
+
execute_using_clause: (print) => group([print("usingKw"), indent([line, print("values")])]),
|
|
1194
|
+
// PREPARE
|
|
1195
|
+
prepare_stmt: (print) => group(
|
|
1196
|
+
join(" ", [
|
|
1197
|
+
print("prepareKw"),
|
|
1198
|
+
print(["name", "params"]),
|
|
1199
|
+
print("source")
|
|
1200
|
+
])
|
|
1201
|
+
),
|
|
1202
|
+
prepare_from_clause: (print) => group([print("fromKw"), indent([line, print("expr")])]),
|
|
1203
|
+
// DEALLOCATE
|
|
1204
|
+
deallocate_stmt: (print) => group(print.spaced(["deallocateKw", "name"])),
|
|
1205
|
+
deallocate_all: (print) => print("allKw")
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
// src/syntax/procedural_language.ts
|
|
1209
|
+
var proceduralLanguageMap = {
|
|
1210
|
+
// BEGIN .. END
|
|
1211
|
+
block_stmt: (print, node) => group([
|
|
1212
|
+
print.spaced(["beginKw", "atomicKw"]),
|
|
1213
|
+
indent([hardline, stripTrailingHardline(print("program"))]),
|
|
1214
|
+
node.exception ? [hardline, print("exception")] : [],
|
|
1215
|
+
hardline,
|
|
1216
|
+
print("endKw")
|
|
1217
|
+
]),
|
|
1218
|
+
exception_clause: (print) => group([
|
|
1219
|
+
print.spaced(["exceptionKw", "whenKw", "condition", "thenKw"]),
|
|
1220
|
+
indent([hardline, stripTrailingHardline(print("program"))])
|
|
1221
|
+
]),
|
|
1222
|
+
error_category: (print) => print("errorKw"),
|
|
1223
|
+
// DECLARE
|
|
1224
|
+
declare_stmt: (print) => group(
|
|
1225
|
+
join(" ", [
|
|
1226
|
+
print("declareKw"),
|
|
1227
|
+
group(print("names")),
|
|
1228
|
+
...print.spaced(["dataType", "default"])
|
|
1229
|
+
])
|
|
1230
|
+
),
|
|
1231
|
+
declare_default: (print) => print.spaced(["defaultKw", "expr"]),
|
|
1232
|
+
// SET
|
|
1233
|
+
set_stmt: (print) => group(print.spaced(["setKw", "assignments"])),
|
|
1234
|
+
// IF
|
|
1235
|
+
if_stmt: (print) => group(join(hardline, [...print("clauses"), print.spaced("endIfKw")])),
|
|
1236
|
+
if_clause: (print) => [
|
|
1237
|
+
group([
|
|
1238
|
+
print("ifKw"),
|
|
1239
|
+
indent([line, print("condition")]),
|
|
1240
|
+
line,
|
|
1241
|
+
print("thenKw")
|
|
1242
|
+
]),
|
|
1243
|
+
indent([hardline, stripTrailingHardline(print("consequent"))])
|
|
1244
|
+
],
|
|
1245
|
+
elseif_clause: (print) => [
|
|
1246
|
+
group([
|
|
1247
|
+
print("elseifKw"),
|
|
1248
|
+
indent([line, print("condition")]),
|
|
1249
|
+
line,
|
|
1250
|
+
print("thenKw")
|
|
1251
|
+
]),
|
|
1252
|
+
indent([hardline, stripTrailingHardline(print("consequent"))])
|
|
1253
|
+
],
|
|
1254
|
+
else_clause: (print) => [
|
|
1255
|
+
print("elseKw"),
|
|
1256
|
+
indent([hardline, stripTrailingHardline(print("consequent"))])
|
|
1257
|
+
],
|
|
1258
|
+
// CASE
|
|
1259
|
+
case_stmt: (print) => group([
|
|
1260
|
+
print.spaced(["caseKw", "expr"]),
|
|
1261
|
+
indent([hardline, join(hardline, print("clauses"))]),
|
|
1262
|
+
hardline,
|
|
1263
|
+
print.spaced("endCaseKw")
|
|
1264
|
+
]),
|
|
1265
|
+
// LOOP
|
|
1266
|
+
loop_stmt: (print) => group([
|
|
1267
|
+
print("loopKw"),
|
|
1268
|
+
indent([hardline, stripTrailingHardline(print("body"))]),
|
|
1269
|
+
hardline,
|
|
1270
|
+
print.spaced("endLoopKw")
|
|
1271
|
+
]),
|
|
1272
|
+
// REPEAT
|
|
1273
|
+
repeat_stmt: (print) => group([
|
|
1274
|
+
print("repeatKw"),
|
|
1275
|
+
indent([hardline, stripTrailingHardline(print("body"))]),
|
|
1276
|
+
hardline,
|
|
1277
|
+
print.spaced(["untilKw", "condition", "endRepeatKw"])
|
|
1278
|
+
]),
|
|
1279
|
+
// WHILE
|
|
1280
|
+
while_stmt: (print) => group([
|
|
1281
|
+
print.spaced(["whileKw", "condition", "doKw"]),
|
|
1282
|
+
indent([hardline, stripTrailingHardline(print("body"))]),
|
|
1283
|
+
hardline,
|
|
1284
|
+
print.spaced("endWhileKw")
|
|
1285
|
+
]),
|
|
1286
|
+
// FOR .. IN
|
|
1287
|
+
for_stmt: (print) => group([
|
|
1288
|
+
print.spaced(["forKw", "left", "inKw", "right", "doKw"]),
|
|
1289
|
+
indent([hardline, stripTrailingHardline(print("body"))]),
|
|
1290
|
+
hardline,
|
|
1291
|
+
print.spaced("endForKw")
|
|
1292
|
+
]),
|
|
1293
|
+
// BREAK/CONTINUE
|
|
1294
|
+
break_stmt: (print) => group(print.spaced(["breakKw", "label"])),
|
|
1295
|
+
continue_stmt: (print) => group(print.spaced(["continueKw", "label"])),
|
|
1296
|
+
labeled_stmt: (print, node) => group([
|
|
1297
|
+
print("beginLabel"),
|
|
1298
|
+
": ",
|
|
1299
|
+
print("statement"),
|
|
1300
|
+
node.endLabel ? [" ", print(["endLabel"])] : []
|
|
1301
|
+
]),
|
|
1302
|
+
// CALL
|
|
1303
|
+
call_stmt: (print) => group(print.spaced(["callKw", "func"])),
|
|
1304
|
+
// RETURN
|
|
1305
|
+
return_stmt: (print) => group(print.spaced(["returnKw", "expr"])),
|
|
1306
|
+
// RAISE
|
|
1307
|
+
raise_stmt: (print) => group(print.spaced(["raiseKw", "message"])),
|
|
1308
|
+
raise_message: (print) => [
|
|
1309
|
+
print.spaced("usingMessageKw"),
|
|
1310
|
+
" = ",
|
|
1311
|
+
print("string")
|
|
1312
|
+
]
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
// src/syntax/procedure.ts
|
|
1316
|
+
var procedureMap = {
|
|
1317
|
+
create_procedure_stmt: (print, node) => group([
|
|
1318
|
+
print.spaced([
|
|
1319
|
+
"createKw",
|
|
1320
|
+
"orReplaceKw",
|
|
1321
|
+
"procedureKw",
|
|
1322
|
+
"ifNotExistsKw",
|
|
1323
|
+
"name"
|
|
1324
|
+
]),
|
|
1325
|
+
print("params"),
|
|
1326
|
+
hasOnlyAsClause(node) ? [" ", group(print("clauses"))] : [
|
|
1327
|
+
hardline,
|
|
1328
|
+
join(
|
|
1329
|
+
hardline,
|
|
1330
|
+
print("clauses").map((clause) => group(clause))
|
|
1331
|
+
)
|
|
1332
|
+
]
|
|
1333
|
+
]),
|
|
1334
|
+
drop_procedure_stmt: (print) => group([
|
|
1335
|
+
print.spaced([
|
|
1336
|
+
"dropKw",
|
|
1337
|
+
"procedureKw",
|
|
1338
|
+
"ifExistsKw",
|
|
1339
|
+
"signatures",
|
|
1340
|
+
"behaviorKw"
|
|
1341
|
+
])
|
|
1342
|
+
]),
|
|
1343
|
+
// almost exact copy of alter_function_stmt
|
|
1344
|
+
alter_procedure_stmt: (print, node) => group([
|
|
1345
|
+
print.spaced(["alterKw", "procedureKw"]),
|
|
1346
|
+
" ",
|
|
1347
|
+
print(["signature"]),
|
|
1348
|
+
print.dynamicLine(),
|
|
1349
|
+
join(print.dynamicLine(), print("actions")),
|
|
1350
|
+
node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : []
|
|
1351
|
+
])
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
// src/syntax/proc_clause.ts
|
|
1355
|
+
var procClauseMap = {
|
|
1356
|
+
returns_clause: (print) => print.spaced(["returnsKw", "dataType"]),
|
|
1357
|
+
determinism_clause: (print) => print.spaced("deterministicKw"),
|
|
1358
|
+
language_clause: (print) => print.spaced(["languageKw", "name"]),
|
|
1359
|
+
as_clause: (print, node) => {
|
|
1360
|
+
if (isStringLiteral(node.expr) || isDynamicallyLoadedFunction(node.expr)) {
|
|
1361
|
+
return print.spaced(["asKw", "expr"]);
|
|
1362
|
+
}
|
|
1363
|
+
return [print("asKw"), indent([hardline, print("expr")])];
|
|
1364
|
+
},
|
|
1365
|
+
with_connection_clause: (print) => print.spaced(["withConnectionKw", "connection"])
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
// src/syntax/program.ts
|
|
1369
|
+
var programMap = {
|
|
1370
|
+
program: (print, node, path, options2) => print("statements").map(
|
|
1371
|
+
(doc2, i) => i === node.statements.length - 1 ? printFinalStatement(doc2, i, node.statements, options2) : printStatement(doc2, i, node.statements, options2)
|
|
1372
|
+
)
|
|
1373
|
+
};
|
|
1374
|
+
var printStatement = (doc2, i, statements, options2) => {
|
|
1375
|
+
const prevNode = statements[i - 1];
|
|
1376
|
+
const node = statements[i];
|
|
1377
|
+
if (i === 0) {
|
|
1378
|
+
return doc2;
|
|
1379
|
+
} else if (node.type !== "empty") {
|
|
1380
|
+
if (hasEmptyLineBetweenNodes(prevNode, node, options2)) {
|
|
1381
|
+
return [";", hardline, hardline, doc2];
|
|
1382
|
+
} else {
|
|
1383
|
+
return [";", hardline, doc2];
|
|
1384
|
+
}
|
|
1385
|
+
} else {
|
|
1386
|
+
return [";", hardline, doc2];
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
var printFinalStatement = (doc2, i, statements, options2) => {
|
|
1390
|
+
const stmtDoc = printStatement(doc2, i, statements, options2);
|
|
1391
|
+
if (statements[i].type === "empty") {
|
|
1392
|
+
return stmtDoc;
|
|
1393
|
+
} else {
|
|
1394
|
+
return [stmtDoc, hardline];
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1398
|
+
// src/syntax/publication.ts
|
|
1399
|
+
var publicationMap = {
|
|
1400
|
+
create_publication_stmt: (print, node) => group([
|
|
1401
|
+
print.spaced(["createPublicationKw", "name"]),
|
|
1402
|
+
print("clauses").map((printedClause, i) => {
|
|
1403
|
+
if (node.clauses[i].type === "for_publication_objects_clause") {
|
|
1404
|
+
return [" ", printedClause];
|
|
1405
|
+
} else {
|
|
1406
|
+
return [line, printedClause];
|
|
1407
|
+
}
|
|
1408
|
+
})
|
|
1409
|
+
]),
|
|
1410
|
+
for_publication_objects_clause: (print) => group([print("forKw"), indent([line, print("publicationObjects")])]),
|
|
1411
|
+
all_publication_object: (print) => group(print.spaced(["allKw", "typesKw"])),
|
|
1412
|
+
publication_object_table: (print) => group(print.spaced(["tableKw", "table", "columns", "where"])),
|
|
1413
|
+
publication_object_tables_in_schema: (print) => group(print.spaced(["tablesInSchemaKw", "schema"])),
|
|
1414
|
+
alter_publication_stmt: (print) => group([
|
|
1415
|
+
print.spaced(["alterPublicationKw", "name"]),
|
|
1416
|
+
print.dynamicLine(),
|
|
1417
|
+
print("action")
|
|
1418
|
+
]),
|
|
1419
|
+
alter_action_add_publication_objects: (print) => group([print("addKw"), indent([line, print("publicationObjects")])]),
|
|
1420
|
+
alter_action_set_publication_objects: (print) => group([print("setKw"), indent([line, print("publicationObjects")])]),
|
|
1421
|
+
alter_action_drop_publication_objects: (print) => group([print("dropKw"), indent([line, print("publicationObjects")])]),
|
|
1422
|
+
drop_publication_stmt: (print) => group(
|
|
1423
|
+
print.spaced(["dropPublicationKw", "ifExistsKw", "names", "behaviorKw"])
|
|
1424
|
+
)
|
|
1425
|
+
};
|
|
1426
|
+
|
|
1427
|
+
// src/syntax/schema.ts
|
|
1428
|
+
var schemaMap = {
|
|
1429
|
+
create_schema_stmt: (print, node) => group([
|
|
1430
|
+
group(
|
|
1431
|
+
join(print.dynamicLine(), [
|
|
1432
|
+
print.spaced(["createSchemaKw", "ifNotExistsKw", "name"]),
|
|
1433
|
+
...print("clauses")
|
|
1434
|
+
])
|
|
1435
|
+
),
|
|
1436
|
+
node.statements.length > 0 ? indent([hardline, join(hardline, print("statements"))]) : []
|
|
1437
|
+
]),
|
|
1438
|
+
create_schema_authorization_clause: (print) => print.spaced(["authorizationKw", "role"]),
|
|
1439
|
+
drop_schema_stmt: (print) => group(
|
|
1440
|
+
print.spaced(["dropSchemaKw", "ifExistsKw", "schemas", "behaviorKw"])
|
|
1441
|
+
),
|
|
1442
|
+
alter_schema_stmt: (print) => group(
|
|
1443
|
+
join(print.dynamicLine(), [
|
|
1444
|
+
print.spaced(["alterSchemaKw", "ifExistsKw", "name"]),
|
|
1445
|
+
...print("actions")
|
|
1446
|
+
])
|
|
1447
|
+
)
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1450
|
+
// src/syntax/select.ts
|
|
1451
|
+
var selectMap = {
|
|
1452
|
+
compound_select_stmt: (print) => group(
|
|
1453
|
+
join(hardline, [print("left"), print.spaced("operator"), print("right")])
|
|
1454
|
+
),
|
|
1455
|
+
select_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
|
|
1456
|
+
// WITH clause
|
|
1457
|
+
with_clause: (print) => group([
|
|
1458
|
+
print.spaced(["withKw", "recursiveKw"]),
|
|
1459
|
+
indent([line, print("tables")])
|
|
1460
|
+
]),
|
|
1461
|
+
common_table_expr: (print, node) => [
|
|
1462
|
+
print(["table", "columns"]),
|
|
1463
|
+
" ",
|
|
1464
|
+
print.spaced(["asKw", "materializedKw", "expr"]),
|
|
1465
|
+
group([
|
|
1466
|
+
node.search || node.cycle ? indent([line, print.separated(line, ["search", "cycle"])]) : []
|
|
1467
|
+
])
|
|
1468
|
+
],
|
|
1469
|
+
cte_search_clause: (print) => group(
|
|
1470
|
+
join(line, [
|
|
1471
|
+
[print.spaced("searchKw"), group(indent([line, print("columns")]))],
|
|
1472
|
+
print.spaced(["setKw", "resultColumn"])
|
|
1473
|
+
])
|
|
1474
|
+
),
|
|
1475
|
+
cte_cycle_clause: (print, node) => group(
|
|
1476
|
+
join(
|
|
1477
|
+
line,
|
|
1478
|
+
[
|
|
1479
|
+
[print("cycleKw"), group(indent([line, print("columns")]))],
|
|
1480
|
+
print.spaced(["setKw", "resultColumn"]),
|
|
1481
|
+
node.values ? print("values") : void 0,
|
|
1482
|
+
print.spaced(["usingKw", "pathColumn"])
|
|
1483
|
+
].filter(isDefined)
|
|
1484
|
+
)
|
|
1485
|
+
),
|
|
1486
|
+
cte_cycle_clause_values: (print) => join(line, [
|
|
1487
|
+
print.spaced(["toKw", "markValue"]),
|
|
1488
|
+
print.spaced(["defaultKw", "defaultValue"])
|
|
1489
|
+
]),
|
|
1490
|
+
// SELECT clause
|
|
1491
|
+
select_clause: (print, node, path, opts) => group([
|
|
1492
|
+
print.spaced(["selectKw", "modifiers"]),
|
|
1493
|
+
node.columns ? indent([line, print("columns")]) : [],
|
|
1494
|
+
containsNewline(node, opts) ? breakParent : []
|
|
1495
|
+
]),
|
|
1496
|
+
select_all: (print) => print.spaced(["allKw"]),
|
|
1497
|
+
select_distinct: (print) => print.spaced(["distinctKw"]),
|
|
1498
|
+
select_distinct_on: (print) => group([print.spaced(["distinctOnKw", "columns"])]),
|
|
1499
|
+
select_as_struct: (print) => print.spaced(["asStructKw"]),
|
|
1500
|
+
select_as_value: (print) => print.spaced(["asValueKw"]),
|
|
1501
|
+
except_columns: (print) => print.spaced(["expr", "exceptKw", "columns"]),
|
|
1502
|
+
replace_columns: (print) => print.spaced(["expr", "replaceKw", "columns"]),
|
|
1503
|
+
// FROM clause
|
|
1504
|
+
from_clause: (print) => group([print("fromKw"), indent([line, print("expr")])]),
|
|
1505
|
+
join_expr: (print, node) => {
|
|
1506
|
+
if (node.operator === ",") {
|
|
1507
|
+
return join([",", hardline], print(["left", "right"]));
|
|
1508
|
+
} else {
|
|
1509
|
+
return [
|
|
1510
|
+
print("left"),
|
|
1511
|
+
hardline,
|
|
1512
|
+
group(
|
|
1513
|
+
join(" ", [
|
|
1514
|
+
print.spaced("operator"),
|
|
1515
|
+
[
|
|
1516
|
+
print("right"),
|
|
1517
|
+
node.specification ? indent([line, print(["specification"])]) : []
|
|
1518
|
+
]
|
|
1519
|
+
])
|
|
1520
|
+
)
|
|
1521
|
+
];
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
join_on_specification: (print) => group(print.spaced(["onKw", "expr"])),
|
|
1525
|
+
join_using_specification: (print) => group(print.spaced(["usingKw", "expr"])),
|
|
1526
|
+
table_with_inheritance: (print) => [print("table"), " ", "*"],
|
|
1527
|
+
table_without_inheritance: (print) => print.spaced(["onlyKw", "table"]),
|
|
1528
|
+
indexed_table: (print) => print.spaced(["table", "indexedByKw", "index"]),
|
|
1529
|
+
not_indexed_table: (print) => print.spaced(["table", "notIndexedKw"]),
|
|
1530
|
+
unnest_expr: (print) => print(["unnestKw", "expr"]),
|
|
1531
|
+
unnest_with_offset_expr: (print) => print.spaced(["unnest", "withOffsetKw"]),
|
|
1532
|
+
pivot_expr: (print) => [print("left"), hardline, print(["pivotKw", "args"])],
|
|
1533
|
+
pivot_for_in: (print) => group(
|
|
1534
|
+
join(line, [
|
|
1535
|
+
group(print("aggregations")),
|
|
1536
|
+
print.spaced(["forKw", "inputColumn"]),
|
|
1537
|
+
print.spaced(["inKw", "pivotColumns"])
|
|
1538
|
+
])
|
|
1539
|
+
),
|
|
1540
|
+
unpivot_expr: (print, node) => [
|
|
1541
|
+
print("left"),
|
|
1542
|
+
hardline,
|
|
1543
|
+
(node.nullHandlingKw ? print.spaced : print)([
|
|
1544
|
+
"unpivotKw",
|
|
1545
|
+
"nullHandlingKw",
|
|
1546
|
+
"args"
|
|
1547
|
+
])
|
|
1548
|
+
],
|
|
1549
|
+
unpivot_for_in: (print) => group(
|
|
1550
|
+
join(line, [
|
|
1551
|
+
print("valuesColumn"),
|
|
1552
|
+
print.spaced(["forKw", "nameColumn"]),
|
|
1553
|
+
print.spaced(["inKw", "unpivotColumns"])
|
|
1554
|
+
])
|
|
1555
|
+
),
|
|
1556
|
+
tablesample_expr: (print) => group([
|
|
1557
|
+
print("left"),
|
|
1558
|
+
line,
|
|
1559
|
+
print.spaced(["tablesampleKw", "method", "args", "repeatable"])
|
|
1560
|
+
]),
|
|
1561
|
+
tablesample_method: (print) => print.spaced(["methodKw"]),
|
|
1562
|
+
tablesample_percent: (print) => print.spaced(["percent", "percentKw"]),
|
|
1563
|
+
tablesample_repeatable: (print) => print.spaced(["repeatableKw", "seed"]),
|
|
1564
|
+
for_system_time_as_of_expr: (print) => group([print("left"), line, print.spaced(["forSystemTimeAsOfKw", "expr"])]),
|
|
1565
|
+
partitioned_table: (print) => print.spaced(["table", "partitionKw", "partitions"]),
|
|
1566
|
+
dual_table: (print) => print("dualKw"),
|
|
1567
|
+
lateral_derived_table: (print) => print.spaced(["lateralKw", "expr"]),
|
|
1568
|
+
rows_from_expr: (print) => print.spaced(["rowsFromKw", "expr"]),
|
|
1569
|
+
with_ordinality_expr: (print) => print.spaced(["expr", "withOrdinalityKw"]),
|
|
1570
|
+
func_call_with_column_definitions: (print) => print.spaced(["funcCall", "asKw", "columns"]),
|
|
1571
|
+
// WHERE clause
|
|
1572
|
+
where_clause: (print) => group([print("whereKw"), indent([line, print("expr")])]),
|
|
1573
|
+
// ORDER BY clause
|
|
1574
|
+
order_by_clause: (print, node) => group([
|
|
1575
|
+
print.spaced("orderByKw"),
|
|
1576
|
+
indent([line, print.separated(line, ["specifications", "withRollupKw"])])
|
|
1577
|
+
]),
|
|
1578
|
+
sort_specification: (print) => print.spaced(["expr", "direction", "nullHandlingKw"]),
|
|
1579
|
+
sort_direction_asc: (print) => print("ascKw"),
|
|
1580
|
+
sort_direction_desc: (print) => print("descKw"),
|
|
1581
|
+
sort_direction_using_operator: (print) => print.spaced(["usingKw", "operator"]),
|
|
1582
|
+
// GROUP BY clause
|
|
1583
|
+
group_by_clause: (print, node) => group([
|
|
1584
|
+
print.spaced(["groupByKw", "distinctKw"]),
|
|
1585
|
+
indent([line, print.separated(line, ["columns", "withRollupKw"])])
|
|
1586
|
+
]),
|
|
1587
|
+
group_by_rollup: (print) => print(["rollupKw", "columns"]),
|
|
1588
|
+
group_by_cube: (print) => print(["cubeKw", "columns"]),
|
|
1589
|
+
group_by_grouping_sets: (print) => print.spaced(["groupingSetsKw", "columns"]),
|
|
1590
|
+
group_by_all: (print) => print(["allKw"]),
|
|
1591
|
+
// PARTITION BY clause
|
|
1592
|
+
partition_by_clause: (print) => group([
|
|
1593
|
+
print.spaced("partitionByKw"),
|
|
1594
|
+
indent([line, print("specifications")])
|
|
1595
|
+
]),
|
|
1596
|
+
// HAVING clause
|
|
1597
|
+
having_clause: (print) => group([print("havingKw"), indent([line, print("expr")])]),
|
|
1598
|
+
// QUALIFY clause
|
|
1599
|
+
qualify_clause: (print) => group([print("qualifyKw"), indent([line, print("expr")])]),
|
|
1600
|
+
// LIMIT clause
|
|
1601
|
+
/** cst-ignore: count, offsetKw, offset */
|
|
1602
|
+
limit_clause: (print, node) => group([
|
|
1603
|
+
print("limitKw"),
|
|
1604
|
+
indent([
|
|
1605
|
+
line,
|
|
1606
|
+
printLimitValues(print, node),
|
|
1607
|
+
node.rowsExamined ? [line, print("rowsExamined")] : []
|
|
1608
|
+
])
|
|
1609
|
+
]),
|
|
1610
|
+
limit_all: (print) => print("allKw"),
|
|
1611
|
+
limit_rows_examined: (print) => print.spaced(["rowsExaminedKw", "count"]),
|
|
1612
|
+
// OFFSET clause
|
|
1613
|
+
offset_clause: (print) => group([
|
|
1614
|
+
print("offsetKw"),
|
|
1615
|
+
indent([line, print.spaced(["offset", "rowsKw"])])
|
|
1616
|
+
]),
|
|
1617
|
+
// FETCH clause
|
|
1618
|
+
fetch_clause: (print) => print.spaced(["fetchKw", "count", "rowsKw", "withTiesKw"]),
|
|
1619
|
+
// WINDOW clause
|
|
1620
|
+
window_clause: (print, node) => {
|
|
1621
|
+
const lineType = node.namedWindows.items.length > 1 ? hardline : line;
|
|
1622
|
+
return group([
|
|
1623
|
+
print("windowKw"),
|
|
1624
|
+
indent([lineType, print("namedWindows")])
|
|
1625
|
+
]);
|
|
1626
|
+
},
|
|
1627
|
+
named_window: (print) => print.spaced(["name", "asKw", "window"]),
|
|
1628
|
+
window_definition: (print, node) => {
|
|
1629
|
+
const itemCount = [
|
|
1630
|
+
node.baseWindowName,
|
|
1631
|
+
node.partitionBy,
|
|
1632
|
+
node.orderBy,
|
|
1633
|
+
node.frame
|
|
1634
|
+
].filter(isDefined).length;
|
|
1635
|
+
const lineType = itemCount > 1 ? hardline : line;
|
|
1636
|
+
return group(
|
|
1637
|
+
join(
|
|
1638
|
+
lineType,
|
|
1639
|
+
print(["baseWindowName", "partitionBy", "orderBy", "frame"])
|
|
1640
|
+
)
|
|
1641
|
+
);
|
|
1642
|
+
},
|
|
1643
|
+
// INTO clause
|
|
1644
|
+
into_table_clause: (print) => print.spaced(["intoKw", "kind", "tableKw", "name"]),
|
|
1645
|
+
into_variables_clause: (print) => group([print("intoKw"), indent([line, print("variables")])]),
|
|
1646
|
+
into_dumpfile_clause: (print) => print.spaced(["intoDumpfileKw", "filename"]),
|
|
1647
|
+
into_outfile_clause: (print, node) => {
|
|
1648
|
+
const hasOptions = node.charset || node.fields || node.lines;
|
|
1649
|
+
return group([
|
|
1650
|
+
print.spaced(["intoOutfileKw", "filename"]),
|
|
1651
|
+
hasOptions ? indent([
|
|
1652
|
+
hardline,
|
|
1653
|
+
join(hardline, print(["charset", "fields", "lines"]))
|
|
1654
|
+
]) : []
|
|
1655
|
+
]);
|
|
1656
|
+
},
|
|
1657
|
+
outfile_fields: (print) => print.spaced(["fieldsKw", "options"]),
|
|
1658
|
+
outfile_lines: (print) => print.spaced(["linesKw", "options"]),
|
|
1659
|
+
outfile_option_character_set: (print) => print.spaced(["characterSetKw", "value"]),
|
|
1660
|
+
outfile_option_starting_by: (print) => print.spaced(["startingByKw", "value"]),
|
|
1661
|
+
outfile_option_terminated_by: (print) => print.spaced(["terminatedByKw", "value"]),
|
|
1662
|
+
outfile_option_enclosed_by: (print) => print.spaced(["optionallyKw", "enclosedByKw", "value"]),
|
|
1663
|
+
outfile_option_escaped_by: (print) => print.spaced(["escapedByKw", "value"]),
|
|
1664
|
+
// FOR clause (locking)
|
|
1665
|
+
for_clause: (print, node) => group([
|
|
1666
|
+
print.spaced(["forKw", "lockStrengthKw", "tables"]),
|
|
1667
|
+
node.waitingKw ? indent([line, print.spaced("waitingKw")]) : []
|
|
1668
|
+
]),
|
|
1669
|
+
for_clause_tables: (print) => [
|
|
1670
|
+
print("ofKw"),
|
|
1671
|
+
indent([line, print("tables")])
|
|
1672
|
+
],
|
|
1673
|
+
lock_in_share_mode_clause: (print) => print.spaced("lockInShareModeKw"),
|
|
1674
|
+
// TABLE clause
|
|
1675
|
+
table_clause: (print) => print.spaced(["tableKw", "table"])
|
|
1676
|
+
};
|
|
1677
|
+
var printLimitValues = (print, node) => {
|
|
1678
|
+
if (node.offsetKw) {
|
|
1679
|
+
return print.spaced(["count", "offsetKw", "offset"]);
|
|
1680
|
+
} else if (node.offset) {
|
|
1681
|
+
return join([",", " "], print(["offset", "count"]));
|
|
1682
|
+
} else {
|
|
1683
|
+
return print("count");
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
|
|
1687
|
+
// src/syntax/sequence.ts
|
|
1688
|
+
var sequenceMap = {
|
|
1689
|
+
create_sequence_stmt: (print, node) => group([
|
|
1690
|
+
print.spaced(["createKw", "kind", "sequenceKw", "ifNotExistsKw", "name"]),
|
|
1691
|
+
node.options.length > 0 ? indent([print.dynamicLine(), join(line, print("options"))]) : []
|
|
1692
|
+
]),
|
|
1693
|
+
alter_sequence_stmt: (print) => group([
|
|
1694
|
+
print.spaced(["alterKw", "sequenceKw", "ifExistsKw", "sequence"]),
|
|
1695
|
+
indent([print.dynamicLine(), join(line, print("actions"))])
|
|
1696
|
+
]),
|
|
1697
|
+
drop_sequence_stmt: (print) => group(
|
|
1698
|
+
print.spaced([
|
|
1699
|
+
"dropKw",
|
|
1700
|
+
"sequenceKw",
|
|
1701
|
+
"ifExistsKw",
|
|
1702
|
+
"sequences",
|
|
1703
|
+
"behaviorKw"
|
|
1704
|
+
])
|
|
1705
|
+
),
|
|
1706
|
+
sequence_option_sequence_name: (print) => print.spaced(["sequenceNameKw", "name"]),
|
|
1707
|
+
sequence_option_logged: (print) => print.spaced("loggedKw"),
|
|
1708
|
+
sequence_option_unlogged: (print) => print.spaced("unloggedKw"),
|
|
1709
|
+
sequence_option_as_type: (print) => print.spaced(["asKw", "dataType"]),
|
|
1710
|
+
sequence_option_increment: (print) => print.spaced(["incrementKw", "byKw", "value"]),
|
|
1711
|
+
sequence_option_minvalue: (print) => print.spaced(["minvalueKw", "value"]),
|
|
1712
|
+
sequence_option_maxvalue: (print) => print.spaced(["maxvalueKw", "value"]),
|
|
1713
|
+
sequence_option_no_minvalue: (print) => print.spaced("noMinvalueKw"),
|
|
1714
|
+
sequence_option_no_maxvalue: (print) => print.spaced("noMaxvalueKw"),
|
|
1715
|
+
sequence_option_start: (print) => print.spaced(["startKw", "withKw", "value"]),
|
|
1716
|
+
sequence_option_restart: (print) => print.spaced(["restartKw", "withKw", "value"]),
|
|
1717
|
+
sequence_option_cache: (print) => print.spaced(["cacheKw", "value"]),
|
|
1718
|
+
sequence_option_cycle: (print) => print.spaced("cycleKw"),
|
|
1719
|
+
sequence_option_no_cycle: (print) => print.spaced("noCycleKw"),
|
|
1720
|
+
sequence_option_owned_by: (print) => print.spaced(["ownedByKw", "owner"]),
|
|
1721
|
+
sequence_option_list: (print) => join(line, print("options"))
|
|
1722
|
+
};
|
|
1723
|
+
|
|
1724
|
+
// src/syntax/subscription.ts
|
|
1725
|
+
var subscriptionMap = {
|
|
1726
|
+
create_subscription_stmt: (print, node) => group(
|
|
1727
|
+
join(line, [
|
|
1728
|
+
print.spaced(["createSubscriptionKw", "name"]),
|
|
1729
|
+
print.spaced(["connectionKw", "connectionInfo"]),
|
|
1730
|
+
print.spaced(["publicationKw", "publications"]),
|
|
1731
|
+
...node.with ? [print.spaced(["with"])] : []
|
|
1732
|
+
])
|
|
1733
|
+
),
|
|
1734
|
+
drop_subscription_stmt: (print) => group(
|
|
1735
|
+
print.spaced(["dropSubscriptionKw", "ifExistsKw", "name", "behaviorKw"])
|
|
1736
|
+
)
|
|
1737
|
+
};
|
|
1738
|
+
|
|
1739
|
+
// src/syntax/transaction.ts
|
|
1740
|
+
var transactionMap = {
|
|
1741
|
+
start_transaction_stmt: (print, node) => group([
|
|
1742
|
+
print.spaced(["startKw", "behaviorKw", "transactionKw"]),
|
|
1743
|
+
node.modes ? indent([line, print("modes")]) : []
|
|
1744
|
+
]),
|
|
1745
|
+
commit_transaction_stmt: (print) => group(print.spaced(["commitKw", "transactionKw", "chain"])),
|
|
1746
|
+
rollback_transaction_stmt: (print) => group(print.spaced(["rollbackKw", "transactionKw", "savepoint", "chain"])),
|
|
1747
|
+
rollback_to_savepoint: (print) => print.spaced(["toKw", "savepointKw", "savepoint"]),
|
|
1748
|
+
savepoint_stmt: (print) => group(print.spaced(["savepointKw", "savepoint"])),
|
|
1749
|
+
release_savepoint_stmt: (print) => group(print.spaced(["releaseKw", "savepointKw", "savepoint"])),
|
|
1750
|
+
transaction_chain_clause: (print) => print.spaced("andChainKw"),
|
|
1751
|
+
transaction_no_chain_clause: (print) => print.spaced("andNoChainKw"),
|
|
1752
|
+
transaction_mode_isolation_level: (print) => print.spaced(["isolationLevelKw", "levelKw"]),
|
|
1753
|
+
transaction_mode_deferrable: (print) => print.spaced("deferrableKw"),
|
|
1754
|
+
transaction_mode_not_deferrable: (print) => print.spaced("notDeferrableKw"),
|
|
1755
|
+
transaction_mode_read_only: (print) => print.spaced("readOnlyKw"),
|
|
1756
|
+
transaction_mode_read_write: (print) => print.spaced("readWriteKw")
|
|
1757
|
+
};
|
|
1758
|
+
|
|
1759
|
+
// src/syntax/trigger.ts
|
|
1760
|
+
var triggerMap = {
|
|
1761
|
+
create_trigger_stmt: (print, node) => group(
|
|
1762
|
+
join(hardline, [
|
|
1763
|
+
print.spaced([
|
|
1764
|
+
"createKw",
|
|
1765
|
+
"orReplaceKw",
|
|
1766
|
+
"kind",
|
|
1767
|
+
"triggerKw",
|
|
1768
|
+
"ifNotExistsKw",
|
|
1769
|
+
"name"
|
|
1770
|
+
]),
|
|
1771
|
+
group([
|
|
1772
|
+
node.timeKw ? [print.spaced("timeKw"), " "] : [],
|
|
1773
|
+
print("event"),
|
|
1774
|
+
line,
|
|
1775
|
+
print("target")
|
|
1776
|
+
]),
|
|
1777
|
+
...print("clauses"),
|
|
1778
|
+
print("body")
|
|
1779
|
+
])
|
|
1780
|
+
),
|
|
1781
|
+
trigger_event: (print, node) => group([
|
|
1782
|
+
print.spaced(["eventKw", "ofKw"]),
|
|
1783
|
+
node.columns ? indent([line, print("columns")]) : []
|
|
1784
|
+
]),
|
|
1785
|
+
trigger_target: (print) => print.spaced(["onKw", "table"]),
|
|
1786
|
+
when_clause: (print) => group([print("whenKw"), indent([line, print("expr")])]),
|
|
1787
|
+
for_each_clause: (print) => print.spaced(["forEachKw", "itemKw"]),
|
|
1788
|
+
execute_clause: (print) => [
|
|
1789
|
+
print.spaced(["executeKw", "functionKw", "name"]),
|
|
1790
|
+
print("args")
|
|
1791
|
+
],
|
|
1792
|
+
from_referenced_table_clause: (print) => print.spaced(["fromKw", "table"]),
|
|
1793
|
+
trigger_timing_clause: (print) => print.spaced(["timingKw"]),
|
|
1794
|
+
trigger_referencing_clause: (print) => group([
|
|
1795
|
+
print.spaced(["referencingKw"]),
|
|
1796
|
+
indent([line, print("transitions")])
|
|
1797
|
+
]),
|
|
1798
|
+
trigger_transition: (print) => [
|
|
1799
|
+
print.spaced(["oldOrNewKw", "rowOrTableKw", "asKw", "name"])
|
|
1800
|
+
],
|
|
1801
|
+
alter_trigger_stmt: (print) => group(
|
|
1802
|
+
join(print.dynamicLine(), [
|
|
1803
|
+
print.spaced(["alterTriggerKw", "trigger", "target"]),
|
|
1804
|
+
print("action")
|
|
1805
|
+
])
|
|
1806
|
+
),
|
|
1807
|
+
drop_trigger_stmt: (print) => group(
|
|
1808
|
+
print.spaced([
|
|
1809
|
+
"dropTriggerKw",
|
|
1810
|
+
"ifExistsKw",
|
|
1811
|
+
"trigger",
|
|
1812
|
+
"target",
|
|
1813
|
+
"behaviorKw"
|
|
1814
|
+
])
|
|
1815
|
+
)
|
|
1816
|
+
};
|
|
1817
|
+
|
|
1818
|
+
// src/syntax/truncate.ts
|
|
1819
|
+
var truncateMap = {
|
|
1820
|
+
truncate_stmt: (print) => group([
|
|
1821
|
+
print.spaced(["truncateKw", "tableKw"]),
|
|
1822
|
+
indent([
|
|
1823
|
+
line,
|
|
1824
|
+
print.separated(line, ["tables", "restartOrContinueKw", "behaviorKw"])
|
|
1825
|
+
])
|
|
1826
|
+
])
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1829
|
+
// src/syntax/type.ts
|
|
1830
|
+
var typeMap = {
|
|
1831
|
+
create_type_stmt: (print) => group([print.spaced(["createTypeKw", "name", "definition"])]),
|
|
1832
|
+
composite_type_definition: (print) => group(print.spaced(["asKw", "columns"])),
|
|
1833
|
+
enum_type_definition: (print) => group(print.spaced(["asEnumKw", "values"])),
|
|
1834
|
+
alter_type_stmt: (print, node) => group([
|
|
1835
|
+
print.spaced(["alterTypeKw", "name"]),
|
|
1836
|
+
print.dynamicLine(),
|
|
1837
|
+
print("actions")
|
|
1838
|
+
]),
|
|
1839
|
+
drop_type_stmt: (print) => group(print.spaced(["dropTypeKw", "ifExistsKw", "types", "behaviorKw"]))
|
|
1840
|
+
};
|
|
1841
|
+
|
|
1842
|
+
// src/syntax/unsupported_grammar.ts
|
|
1843
|
+
var unsupportedGrammarMap = {
|
|
1844
|
+
unsupported_grammar_stmt: (print) => group(print("text"))
|
|
1845
|
+
};
|
|
1846
|
+
|
|
1847
|
+
// src/syntax/update.ts
|
|
1848
|
+
var updateMap = {
|
|
1849
|
+
update_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
|
|
1850
|
+
update_clause: (print) => print.spaced(["updateKw", "modifiers", "orAction", "tables"]),
|
|
1851
|
+
set_clause: (print, node) => {
|
|
1852
|
+
if (node.assignments.items.length > 1) {
|
|
1853
|
+
return [print("setKw"), indent([hardline, print("assignments")])];
|
|
1854
|
+
} else {
|
|
1855
|
+
return print.spaced(["setKw", "assignments"]);
|
|
1856
|
+
}
|
|
1857
|
+
},
|
|
1858
|
+
column_assignment: (print) => join([" ", "=", " "], print(["column", "expr"]))
|
|
1859
|
+
};
|
|
1860
|
+
|
|
1861
|
+
// src/syntax/view.ts
|
|
1862
|
+
var viewMap = {
|
|
1863
|
+
create_view_stmt: (print, node) => {
|
|
1864
|
+
const hasOnlyAsClause2 = node.clauses.length === 1;
|
|
1865
|
+
const hasManyClauses = node.clauses.length > 1;
|
|
1866
|
+
return group([
|
|
1867
|
+
print.spaced([
|
|
1868
|
+
"createKw",
|
|
1869
|
+
"orReplaceKw",
|
|
1870
|
+
"kinds",
|
|
1871
|
+
"viewKw",
|
|
1872
|
+
"ifNotExistsKw",
|
|
1873
|
+
"name",
|
|
1874
|
+
"columns"
|
|
1875
|
+
]),
|
|
1876
|
+
hasOnlyAsClause2 ? [" ", print("clauses")] : [],
|
|
1877
|
+
hasManyClauses ? [hardline, join(hardline, print("clauses"))] : []
|
|
1878
|
+
]);
|
|
1879
|
+
},
|
|
1880
|
+
with_check_option_clause: (print) => print.spaced(["withKw", "levelKw", "checkOptionKw"]),
|
|
1881
|
+
as_replica_of_clause: (print) => print.spaced(["asReplicaOfKw", "view"]),
|
|
1882
|
+
drop_view_stmt: (print) => group(
|
|
1883
|
+
print.spaced([
|
|
1884
|
+
"dropKw",
|
|
1885
|
+
"kind",
|
|
1886
|
+
"viewKw",
|
|
1887
|
+
"ifExistsKw",
|
|
1888
|
+
"views",
|
|
1889
|
+
"behaviorKw"
|
|
1890
|
+
])
|
|
1891
|
+
),
|
|
1892
|
+
alter_view_stmt: (print) => group([
|
|
1893
|
+
print.spaced([
|
|
1894
|
+
"alterKw",
|
|
1895
|
+
"kind",
|
|
1896
|
+
"viewKw",
|
|
1897
|
+
"ifExistsKw",
|
|
1898
|
+
"name",
|
|
1899
|
+
"columns"
|
|
1900
|
+
]),
|
|
1901
|
+
hardline,
|
|
1902
|
+
print("actions")
|
|
1903
|
+
]),
|
|
1904
|
+
refresh_materialized_view_stmt: (print, node) => group([
|
|
1905
|
+
print.spaced(["refreshMaterializedViewKw", "concurrentlyKw", "name"]),
|
|
1906
|
+
node.clauses.length > 0 ? [print.dynamicLine(), join(line, print("clauses"))] : []
|
|
1907
|
+
])
|
|
1908
|
+
};
|
|
1909
|
+
|
|
1910
|
+
// src/syntax/dialects/bigquery.ts
|
|
1911
|
+
var bigqueryMap = {
|
|
1912
|
+
bigquery_options: (print) => print.spaced(["optionsKw", "options"]),
|
|
1913
|
+
bigquery_option_default_collate: (print) => print.spaced(["defaultCollateKw", "collation"]),
|
|
1914
|
+
// ROW ACCESS POLICY
|
|
1915
|
+
create_row_access_policy_stmt: (print) => group(
|
|
1916
|
+
join(hardline, [
|
|
1917
|
+
print.spaced([
|
|
1918
|
+
"createKw",
|
|
1919
|
+
"orReplaceKw",
|
|
1920
|
+
"rowAccessPolicyKw",
|
|
1921
|
+
"ifNotExistsKw",
|
|
1922
|
+
"name",
|
|
1923
|
+
"onKw",
|
|
1924
|
+
"table"
|
|
1925
|
+
]),
|
|
1926
|
+
...print("clauses")
|
|
1927
|
+
])
|
|
1928
|
+
),
|
|
1929
|
+
row_access_policy_grant_clause: (print) => print.spaced(["grantToKw", "grantees"]),
|
|
1930
|
+
row_access_policy_filter_clause: (print) => print.spaced(["filterUsingKw", "expr"]),
|
|
1931
|
+
drop_row_access_policy_stmt: (print) => group(
|
|
1932
|
+
print.spaced([
|
|
1933
|
+
"dropKw",
|
|
1934
|
+
"allKw",
|
|
1935
|
+
"rowAccessPolicyKw",
|
|
1936
|
+
"ifExistsKw",
|
|
1937
|
+
"name",
|
|
1938
|
+
"onKw",
|
|
1939
|
+
"table"
|
|
1940
|
+
])
|
|
1941
|
+
),
|
|
1942
|
+
// CAPACITY
|
|
1943
|
+
create_capacity_stmt: (print) => group([
|
|
1944
|
+
print.spaced(["createKw", "capacityKw", "name"]),
|
|
1945
|
+
hardline,
|
|
1946
|
+
print("options")
|
|
1947
|
+
]),
|
|
1948
|
+
drop_capacity_stmt: (print) => group(print.spaced(["dropKw", "capacityKw", "ifExistsKw", "name"])),
|
|
1949
|
+
// RESERVATION
|
|
1950
|
+
create_reservation_stmt: (print) => group([
|
|
1951
|
+
print.spaced(["createKw", "reservationKw", "name"]),
|
|
1952
|
+
hardline,
|
|
1953
|
+
print("options")
|
|
1954
|
+
]),
|
|
1955
|
+
drop_reservation_stmt: (print) => group(print.spaced(["dropKw", "reservationKw", "ifExistsKw", "name"])),
|
|
1956
|
+
// ASSIGNMENT
|
|
1957
|
+
create_assignment_stmt: (print) => group([
|
|
1958
|
+
print.spaced(["createKw", "assignmentKw", "name"]),
|
|
1959
|
+
hardline,
|
|
1960
|
+
print("options")
|
|
1961
|
+
]),
|
|
1962
|
+
drop_assignment_stmt: (print) => group(print.spaced(["dropKw", "assignmentKw", "ifExistsKw", "name"])),
|
|
1963
|
+
// ALTER ORGANIZATION
|
|
1964
|
+
alter_organization_stmt: (print) => group(
|
|
1965
|
+
join(hardline, [print.spaced("alterOrganizationKw"), print("actions")])
|
|
1966
|
+
),
|
|
1967
|
+
// ALTER PROJECT
|
|
1968
|
+
alter_project_stmt: (print) => group(
|
|
1969
|
+
join(hardline, [
|
|
1970
|
+
print.spaced(["alterProjectKw", "name"]),
|
|
1971
|
+
print("actions")
|
|
1972
|
+
])
|
|
1973
|
+
),
|
|
1974
|
+
alter_bi_capacity_stmt: (print) => group(
|
|
1975
|
+
join(hardline, [
|
|
1976
|
+
print.spaced(["alterBiCapacityKw", "name"]),
|
|
1977
|
+
print("actions")
|
|
1978
|
+
])
|
|
1979
|
+
),
|
|
1980
|
+
alter_capacity_stmt: (print) => group(
|
|
1981
|
+
join(hardline, [
|
|
1982
|
+
print.spaced(["alterCapacityKw", "name"]),
|
|
1983
|
+
print("actions")
|
|
1984
|
+
])
|
|
1985
|
+
),
|
|
1986
|
+
alter_reservation_stmt: (print) => group(
|
|
1987
|
+
join(hardline, [
|
|
1988
|
+
print.spaced(["alterReservationKw", "name"]),
|
|
1989
|
+
print("actions")
|
|
1990
|
+
])
|
|
1991
|
+
),
|
|
1992
|
+
// ASSERT
|
|
1993
|
+
assert_stmt: (print) => group(print.spaced(["assertKw", "expr", "as"])),
|
|
1994
|
+
// EXPORT
|
|
1995
|
+
export_data_stmt: (print) => group(
|
|
1996
|
+
join(hardline, [
|
|
1997
|
+
print.spaced("exportDataKw"),
|
|
1998
|
+
...print.spaced(["withConnection"]),
|
|
1999
|
+
print.spaced("options"),
|
|
2000
|
+
print.spaced("as")
|
|
2001
|
+
])
|
|
2002
|
+
),
|
|
2003
|
+
// LOAD
|
|
2004
|
+
load_data_stmt: (print) => group(
|
|
2005
|
+
join(hardline, [
|
|
2006
|
+
print.spaced(["loadDataKw", "intoKw", "table", "columns"]),
|
|
2007
|
+
...print("clauses")
|
|
2008
|
+
])
|
|
2009
|
+
),
|
|
2010
|
+
from_files_options: (print) => print.spaced(["fromFilesKw", "options"])
|
|
2011
|
+
};
|
|
2012
|
+
|
|
2013
|
+
// src/syntax/dialects/mysql.ts
|
|
2014
|
+
var mysqlMap = {
|
|
2015
|
+
mysql_modifier: (print) => print.spaced("modifierKw")
|
|
2016
|
+
};
|
|
2017
|
+
|
|
2018
|
+
// src/syntax/dialects/sqlite.ts
|
|
2019
|
+
var sqliteMap = {
|
|
2020
|
+
attach_database_stmt: (print) => group(print.spaced(["attachKw", "databaseKw", "file", "asKw", "schema"])),
|
|
2021
|
+
detach_database_stmt: (print) => group(print.spaced(["detachKw", "databaseKw", "schema"])),
|
|
2022
|
+
vacuum_stmt: (print) => group(print.spaced(["vacuumKw", "schema", "intoKw", "file"])),
|
|
2023
|
+
pragma_stmt: (print) => group(print.spaced(["pragmaKw", "pragma"])),
|
|
2024
|
+
pragma_assignment: (print) => join(" = ", print(["name", "value"])),
|
|
2025
|
+
pragma_func_call: (print) => print(["name", "args"])
|
|
2026
|
+
};
|
|
2027
|
+
|
|
2028
|
+
// src/syntax/dialects/postgresql.ts
|
|
2029
|
+
var postgresqlMap = {
|
|
2030
|
+
postgresql_operator_expr: (print) => print(["operatorKw", "expr"]),
|
|
2031
|
+
postgresql_operator: (print) => print("operator"),
|
|
2032
|
+
postgresql_operator_class: (print) => print.spaced(["name", "options"]),
|
|
2033
|
+
postgresql_with_options: (print) => group(print.spaced(["withKw", "options"])),
|
|
2034
|
+
postgresql_options: (print) => print.spaced(["optionsKw", "options"]),
|
|
2035
|
+
postgresql_option_element: (print) => print.spaced(["name", "value"])
|
|
2036
|
+
};
|
|
2037
|
+
|
|
2038
|
+
// src/syntax/transformMap.ts
|
|
2039
|
+
var transformMap = {
|
|
2040
|
+
...aliasMap,
|
|
2041
|
+
...alterActionMap,
|
|
2042
|
+
...alterTableMap,
|
|
2043
|
+
...analyzeMap,
|
|
2044
|
+
...baseMap,
|
|
2045
|
+
...castMap,
|
|
2046
|
+
...commentMap,
|
|
2047
|
+
...constraintMap,
|
|
2048
|
+
...createTableMap,
|
|
2049
|
+
...dataTypeMap,
|
|
2050
|
+
...dclMap,
|
|
2051
|
+
...deleteMap,
|
|
2052
|
+
...doMap,
|
|
2053
|
+
...domainMap,
|
|
2054
|
+
...dropTableMap,
|
|
2055
|
+
...explainMap,
|
|
2056
|
+
...exprMap,
|
|
2057
|
+
...extensionMap,
|
|
2058
|
+
...frameMap,
|
|
2059
|
+
...functionMap,
|
|
2060
|
+
...indexMap,
|
|
2061
|
+
...insertMap,
|
|
2062
|
+
...mergeMap,
|
|
2063
|
+
...otherClausesMap,
|
|
2064
|
+
...parameterMap,
|
|
2065
|
+
...policyMap,
|
|
2066
|
+
...preparedStatementsMap,
|
|
2067
|
+
...procClauseMap,
|
|
2068
|
+
...proceduralLanguageMap,
|
|
2069
|
+
...procedureMap,
|
|
2070
|
+
...programMap,
|
|
2071
|
+
...publicationMap,
|
|
2072
|
+
...renameTableMap,
|
|
2073
|
+
...roleMap,
|
|
2074
|
+
...schemaMap,
|
|
2075
|
+
...selectMap,
|
|
2076
|
+
...sequenceMap,
|
|
2077
|
+
...subscriptionMap,
|
|
2078
|
+
...transactionMap,
|
|
2079
|
+
...triggerMap,
|
|
2080
|
+
...truncateMap,
|
|
2081
|
+
...typeMap,
|
|
2082
|
+
...unsupportedGrammarMap,
|
|
2083
|
+
...updateMap,
|
|
2084
|
+
...viewMap,
|
|
2085
|
+
...bigqueryMap,
|
|
2086
|
+
...mysqlMap,
|
|
2087
|
+
...postgresqlMap,
|
|
2088
|
+
...sqliteMap
|
|
2089
|
+
};
|
|
2090
|
+
|
|
2091
|
+
// src/printSql.ts
|
|
2092
|
+
function printSql(path, options2, oldPrint) {
|
|
2093
|
+
return printNode(path, options2, createPrintFn(path, oldPrint, options2));
|
|
2094
|
+
}
|
|
2095
|
+
var cachedPrintFn;
|
|
2096
|
+
var cachedPath;
|
|
2097
|
+
function createPrintFn(path, oldPrint, opts) {
|
|
2098
|
+
if (cachedPath === path) {
|
|
2099
|
+
return cachedPrintFn;
|
|
2100
|
+
}
|
|
2101
|
+
cachedPath = path;
|
|
2102
|
+
cachedPrintFn = ((selector) => {
|
|
2103
|
+
if (isArray(selector)) {
|
|
2104
|
+
const node = path.node;
|
|
2105
|
+
return selector.filter((sel) => isDefined(node[sel])).map(oldPrint);
|
|
2106
|
+
} else {
|
|
2107
|
+
return oldPrint(selector);
|
|
2108
|
+
}
|
|
2109
|
+
});
|
|
2110
|
+
cachedPrintFn.separated = (separator, selector) => {
|
|
2111
|
+
const node = path.node;
|
|
2112
|
+
const docs = arrayWrap(selector).filter((sel) => isDefined(node[sel])).map((sel) => [sel, oldPrint(sel)]).filter(([sel, doc2]) => !isEmptyArray(doc2)).map(([sel, doc2]) => isArray(node[sel]) ? join(" ", doc2) : doc2);
|
|
2113
|
+
return docs.length > 0 ? [join(separator, docs)] : [];
|
|
2114
|
+
};
|
|
2115
|
+
cachedPrintFn.spaced = (selector) => cachedPrintFn.separated(" ", selector);
|
|
2116
|
+
cachedPrintFn.dynamicLine = () => {
|
|
2117
|
+
const node = path.node;
|
|
2118
|
+
return containsNewline(node, opts) ? hardline : line;
|
|
2119
|
+
};
|
|
2120
|
+
return cachedPrintFn;
|
|
2121
|
+
}
|
|
2122
|
+
function printNode(path, options2, print) {
|
|
2123
|
+
const node = path.node;
|
|
2124
|
+
if (isArray(node)) {
|
|
2125
|
+
return path.map(print);
|
|
2126
|
+
}
|
|
2127
|
+
if (isString(node)) {
|
|
2128
|
+
return node;
|
|
2129
|
+
}
|
|
2130
|
+
if (!node?.type) {
|
|
2131
|
+
throw new Error(`No type field on node: ${JSON.stringify(node)}`);
|
|
2132
|
+
}
|
|
2133
|
+
const fn = transformMap[node.type];
|
|
2134
|
+
if (!fn) {
|
|
2135
|
+
throw new Error(`Unexpected node type: ${node.type}`);
|
|
2136
|
+
}
|
|
2137
|
+
return fn(print, node, path, options2);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
// src/printComment.ts
|
|
2141
|
+
var printComment = (path) => {
|
|
2142
|
+
const node = path.node;
|
|
2143
|
+
if (node.type === "line_comment") {
|
|
2144
|
+
if (/^--[^ \t]/.test(node.text)) {
|
|
2145
|
+
return node.text.replace(/^--/, "-- ");
|
|
2146
|
+
}
|
|
2147
|
+
if (/^#[^ \t!]/.test(node.text)) {
|
|
2148
|
+
return node.text.replace(/^#/, "# ");
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
return node.text;
|
|
2152
|
+
};
|
|
2153
|
+
|
|
2154
|
+
// src/embedJs.ts
|
|
2155
|
+
var embedJs = (path, options2) => {
|
|
2156
|
+
const node = path.node;
|
|
2157
|
+
const parent = path.getParentNode(0);
|
|
2158
|
+
const grandParent = path.getParentNode(1);
|
|
2159
|
+
if (isStringLiteral(node) && isAsClause(parent) && isCreateFunctionStmt(grandParent) && grandParent.clauses.some(isJavaScriptLanguageClause)) {
|
|
2160
|
+
return async (textToDoc) => {
|
|
2161
|
+
const quotes = detectQuotes(node.value);
|
|
2162
|
+
if (!quotes) {
|
|
2163
|
+
return void 0;
|
|
2164
|
+
}
|
|
2165
|
+
const js = await textToDoc(node.value, {
|
|
2166
|
+
...options2,
|
|
2167
|
+
parser: "babel"
|
|
2168
|
+
});
|
|
2169
|
+
return [
|
|
2170
|
+
quotes[0],
|
|
2171
|
+
indent([hardline, stripTrailingHardline(js)]),
|
|
2172
|
+
hardline,
|
|
2173
|
+
quotes[1]
|
|
2174
|
+
];
|
|
2175
|
+
};
|
|
2176
|
+
}
|
|
2177
|
+
return null;
|
|
2178
|
+
};
|
|
2179
|
+
var isJavaScriptLanguageClause = (clause) => isLanguageClause(clause) && clause.name.name === "js";
|
|
2180
|
+
var detectQuotes = (js) => {
|
|
2181
|
+
if (!/'''/.test(js)) {
|
|
2182
|
+
return ["r'''", "'''"];
|
|
2183
|
+
}
|
|
2184
|
+
if (!/"""/.test(js)) {
|
|
2185
|
+
return ['r"""', '"""'];
|
|
2186
|
+
}
|
|
2187
|
+
return void 0;
|
|
2188
|
+
};
|
|
2189
|
+
|
|
2190
|
+
// src/embedJson.ts
|
|
2191
|
+
var embedJson = (path, options2) => {
|
|
2192
|
+
const node = path.node;
|
|
2193
|
+
const parent = path.getParentNode();
|
|
2194
|
+
if (isStringLiteral(node) && (isJsonLiteral(parent) || isJsonbLiteral(parent))) {
|
|
2195
|
+
return async (textToDoc) => {
|
|
2196
|
+
if (containsTripleQuote(node.value) || containsBackslash(node.value) || isRawString(node)) {
|
|
2197
|
+
return void 0;
|
|
2198
|
+
}
|
|
2199
|
+
const json = await textToDoc(node.value, {
|
|
2200
|
+
...options2,
|
|
2201
|
+
parser: "json"
|
|
2202
|
+
});
|
|
2203
|
+
const inlineQuote = containsSingleQuote(node.value) ? "'''" : "'";
|
|
2204
|
+
return [
|
|
2205
|
+
ifBreak("'''", inlineQuote),
|
|
2206
|
+
indent([softline, stripTrailingHardline(json)]),
|
|
2207
|
+
softline,
|
|
2208
|
+
ifBreak("'''", inlineQuote)
|
|
2209
|
+
];
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
return null;
|
|
2213
|
+
};
|
|
2214
|
+
var containsSingleQuote = (json) => /'/.test(json);
|
|
2215
|
+
var containsTripleQuote = (json) => /'''/.test(json);
|
|
2216
|
+
var containsBackslash = (json) => /\\/.test(json);
|
|
2217
|
+
var isRawString = (node) => /^R/i.test(node.text);
|
|
2218
|
+
|
|
2219
|
+
// src/embedSql.ts
|
|
2220
|
+
var embedSql = (path, options2) => {
|
|
2221
|
+
const node = path.node;
|
|
2222
|
+
const parent = path.getParentNode(0);
|
|
2223
|
+
const grandParent = path.getParentNode(1);
|
|
2224
|
+
if (isStringLiteral(node) && isAsClause(parent) && (isCreateFunctionStmt(grandParent) || isCreateProcedureStmt(grandParent)) && grandParent.clauses.some(isSqlLanguageClause)) {
|
|
2225
|
+
return async (textToDoc) => {
|
|
2226
|
+
const quote = detectQuote(node);
|
|
2227
|
+
if (!quote) {
|
|
2228
|
+
return void 0;
|
|
2229
|
+
}
|
|
2230
|
+
const sql = await textToDoc(node.value, options2);
|
|
2231
|
+
return [
|
|
2232
|
+
quote,
|
|
2233
|
+
indent([hardline, stripTrailingHardline(sql)]),
|
|
2234
|
+
hardline,
|
|
2235
|
+
quote
|
|
2236
|
+
];
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2239
|
+
return null;
|
|
2240
|
+
};
|
|
2241
|
+
var isSqlLanguageClause = (clause) => isLanguageClause(clause) && clause.name.name.toLowerCase() === "sql";
|
|
2242
|
+
var detectQuote = (node) => {
|
|
2243
|
+
const match = node.text.match(/^('|\$[^$]*\$)/);
|
|
2244
|
+
const quote = match?.[1];
|
|
2245
|
+
if (quote === "'") {
|
|
2246
|
+
return node.value.includes("$$") ? void 0 : "$$";
|
|
2247
|
+
} else {
|
|
2248
|
+
return quote;
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2252
|
+
// src/embed.ts
|
|
2253
|
+
var embed = (...args) => {
|
|
2254
|
+
return embedJson(...args) || embedJs(...args) || embedSql(...args);
|
|
2255
|
+
};
|
|
2256
|
+
|
|
2257
|
+
// src/visitAllNodes.ts
|
|
2258
|
+
var visitAllNodes = (node, visit) => {
|
|
2259
|
+
visit(node);
|
|
2260
|
+
for (const child of Object.values(node)) {
|
|
2261
|
+
if (isNode(child)) {
|
|
2262
|
+
visitAllNodes(child, visit);
|
|
2263
|
+
} else if (isArray(child)) {
|
|
2264
|
+
child.filter(isNode).forEach((childNode) => visitAllNodes(childNode, visit));
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
|
|
2269
|
+
// src/transform/comments.ts
|
|
2270
|
+
var moveCommentsToRoot = (cst) => {
|
|
2271
|
+
return {
|
|
2272
|
+
...cst,
|
|
2273
|
+
comments: extractComments(cst)
|
|
2274
|
+
};
|
|
2275
|
+
};
|
|
2276
|
+
var extractComments = (cst) => {
|
|
2277
|
+
const comments = [];
|
|
2278
|
+
visitAllNodes(cst, (node) => {
|
|
2279
|
+
comments.push(...node.leading || [], ...node.trailing || []);
|
|
2280
|
+
});
|
|
2281
|
+
return comments;
|
|
2282
|
+
};
|
|
2283
|
+
|
|
2284
|
+
// src/transform/aliasAs.ts
|
|
2285
|
+
import { cstVisitor } from "sql-parser-cst";
|
|
2286
|
+
var processAliasAs = (cst) => {
|
|
2287
|
+
cstVisitor({
|
|
2288
|
+
alias: (node) => {
|
|
2289
|
+
node.asKw = node.asKw || { type: "keyword", name: "AS", text: "AS" };
|
|
2290
|
+
}
|
|
2291
|
+
})(cst);
|
|
2292
|
+
return cst;
|
|
2293
|
+
};
|
|
2294
|
+
|
|
2295
|
+
// src/transform/stripTrailingCommas.ts
|
|
2296
|
+
import { cstVisitor as cstVisitor2 } from "sql-parser-cst";
|
|
2297
|
+
var stripTrailingCommas = (cst) => {
|
|
2298
|
+
cstVisitor2({
|
|
2299
|
+
select_clause: (node) => {
|
|
2300
|
+
if (node.columns && isEmpty(last(node.columns.items))) {
|
|
2301
|
+
node.columns.items = node.columns.items.slice(0, -1);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
})(cst);
|
|
2305
|
+
return cst;
|
|
2306
|
+
};
|
|
2307
|
+
|
|
2308
|
+
// src/transform/addFinalSemicolon.ts
|
|
2309
|
+
var addFinalSemicolon = (program, originalText) => {
|
|
2310
|
+
if (!isEmpty(last(program.statements))) {
|
|
2311
|
+
const end = originalText.length;
|
|
2312
|
+
program.statements.push({ type: "empty", range: [end, end] });
|
|
2313
|
+
}
|
|
2314
|
+
return program;
|
|
2315
|
+
};
|
|
2316
|
+
|
|
2317
|
+
// src/transform/canonicKeywords.ts
|
|
2318
|
+
import { cstVisitor as cstVisitor3 } from "sql-parser-cst";
|
|
2319
|
+
|
|
2320
|
+
// src/transform/transformUtils.ts
|
|
2321
|
+
function keyword(name) {
|
|
2322
|
+
return { type: "keyword", name, text: name };
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
// src/transform/canonicKeywords.ts
|
|
2326
|
+
var canonicKeywords = (cst) => {
|
|
2327
|
+
cstVisitor3({
|
|
2328
|
+
// Replaces TEMP with TEMPORARY
|
|
2329
|
+
relation_kind: (node) => {
|
|
2330
|
+
if (Array.isArray(node.kindKw)) {
|
|
2331
|
+
} else {
|
|
2332
|
+
if (node.kindKw.name === "TEMP") {
|
|
2333
|
+
node.kindKw.name = "TEMPORARY";
|
|
2334
|
+
node.kindKw.text = "TEMPORARY";
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
},
|
|
2338
|
+
// Replaces MySQL SELECT DISTINCTROW with SELECT DISTINCT
|
|
2339
|
+
select_distinct: (node) => {
|
|
2340
|
+
if (node.distinctKw.name === "DISTINCTROW") {
|
|
2341
|
+
node.distinctKw.name = "DISTINCT";
|
|
2342
|
+
node.distinctKw.text = "DISTINCT";
|
|
2343
|
+
}
|
|
13
2344
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2345
|
+
// Replaces RENAME & RENAME AS with RENAME TO
|
|
2346
|
+
alter_action_rename: (node) => {
|
|
2347
|
+
if (Array.isArray(node.renameKw)) {
|
|
2348
|
+
if (node.renameKw[1].name === "AS") {
|
|
2349
|
+
node.renameKw[1].name = "TO";
|
|
2350
|
+
node.renameKw[1].text = "TO";
|
|
2351
|
+
}
|
|
2352
|
+
} else {
|
|
2353
|
+
node.renameKw = [node.renameKw, keyword("TO")];
|
|
2354
|
+
}
|
|
18
2355
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2356
|
+
// Replaces INSERT with INSERT INTO
|
|
2357
|
+
insert_clause: (node) => {
|
|
2358
|
+
if (!node.intoKw) {
|
|
2359
|
+
node.intoKw = keyword("INTO");
|
|
2360
|
+
}
|
|
23
2361
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2362
|
+
// Replaces MERGE with MERGE INTO
|
|
2363
|
+
merge_clause: (node) => {
|
|
2364
|
+
if (!node.intoKw) {
|
|
2365
|
+
node.intoKw = keyword("INTO");
|
|
2366
|
+
}
|
|
28
2367
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
2368
|
+
// Replaces DELETE with DELETE FROM
|
|
2369
|
+
delete_clause: (node) => {
|
|
2370
|
+
if (!node.fromKw) {
|
|
2371
|
+
node.fromKw = keyword("FROM");
|
|
2372
|
+
}
|
|
33
2373
|
},
|
|
2374
|
+
// Replaces TRUNCATE with TRUNCATE TABLE
|
|
2375
|
+
truncate_stmt: (node) => {
|
|
2376
|
+
if (!node.tableKw) {
|
|
2377
|
+
node.tableKw = keyword("TABLE");
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
})(cst);
|
|
2381
|
+
return cst;
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2384
|
+
// src/transform/canonicOperators.ts
|
|
2385
|
+
import { cstVisitor as cstVisitor4 } from "sql-parser-cst";
|
|
2386
|
+
var canonicOperators = (cst, originalText, options2) => {
|
|
2387
|
+
cstVisitor4({
|
|
2388
|
+
binary_expr: (node) => {
|
|
2389
|
+
if (node.operator === "<>") {
|
|
2390
|
+
node.operator = "!=";
|
|
2391
|
+
}
|
|
2392
|
+
if (options2.parser === "mysql" || options2.parser === "mariadb") {
|
|
2393
|
+
if (node.operator === "&&") {
|
|
2394
|
+
node.operator = keyword("AND");
|
|
2395
|
+
}
|
|
2396
|
+
if (node.operator === "||") {
|
|
2397
|
+
node.operator = keyword("OR");
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
},
|
|
2401
|
+
// Replaces PostgreSQL deprecated := operator with =>
|
|
2402
|
+
named_arg: (node) => {
|
|
2403
|
+
if (node.operator === ":=") {
|
|
2404
|
+
node.operator = "=>";
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
})(cst);
|
|
2408
|
+
return cst;
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2411
|
+
// src/transform/transformCst.ts
|
|
2412
|
+
var transformCst = (cst, originalText, options2) => {
|
|
2413
|
+
const transforms = [
|
|
2414
|
+
// Note that we first perform moveCommentsToRoot transform,
|
|
2415
|
+
// so we don't need to worry about comments interfering with other transforms
|
|
2416
|
+
moveCommentsToRoot,
|
|
2417
|
+
stripTrailingCommas
|
|
2418
|
+
];
|
|
2419
|
+
if (options2.sqlFinalSemicolon) {
|
|
2420
|
+
transforms.push(addFinalSemicolon);
|
|
2421
|
+
}
|
|
2422
|
+
if (options2.sqlCanonicalSyntax) {
|
|
2423
|
+
transforms.push(processAliasAs, canonicOperators, canonicKeywords);
|
|
2424
|
+
}
|
|
2425
|
+
return transforms.reduce(
|
|
2426
|
+
(cst2, transform) => transform(cst2, originalText, options2),
|
|
2427
|
+
cst
|
|
2428
|
+
);
|
|
2429
|
+
};
|
|
2430
|
+
|
|
2431
|
+
// src/options.ts
|
|
2432
|
+
var options = {
|
|
2433
|
+
sqlKeywordCase: {
|
|
2434
|
+
type: "choice",
|
|
2435
|
+
category: "SQL",
|
|
2436
|
+
default: "upper",
|
|
2437
|
+
description: "Enforces upper/lower case for SQL keywords",
|
|
2438
|
+
choices: [
|
|
2439
|
+
{
|
|
2440
|
+
value: "preserve",
|
|
2441
|
+
description: "preserves the existing case",
|
|
2442
|
+
since: "0.1.0"
|
|
2443
|
+
},
|
|
2444
|
+
{
|
|
2445
|
+
value: "upper",
|
|
2446
|
+
description: "forces all keywords to uppercase",
|
|
2447
|
+
since: "0.1.0"
|
|
2448
|
+
},
|
|
2449
|
+
{
|
|
2450
|
+
value: "lower",
|
|
2451
|
+
description: "forces all keywords to lowercase",
|
|
2452
|
+
since: "0.1.0"
|
|
2453
|
+
}
|
|
2454
|
+
]
|
|
2455
|
+
},
|
|
2456
|
+
sqlLiteralCase: {
|
|
2457
|
+
type: "choice",
|
|
2458
|
+
category: "SQL",
|
|
2459
|
+
default: "upper",
|
|
2460
|
+
description: "Enforces upper/lower case for SQL literals (TRUE, FALSE, NULL)",
|
|
2461
|
+
choices: [
|
|
2462
|
+
{
|
|
2463
|
+
value: "preserve",
|
|
2464
|
+
description: "preserves the existing case",
|
|
2465
|
+
since: "0.14.0"
|
|
2466
|
+
},
|
|
2467
|
+
{
|
|
2468
|
+
value: "upper",
|
|
2469
|
+
description: "forces all literals to uppercase",
|
|
2470
|
+
since: "0.14.0"
|
|
2471
|
+
},
|
|
2472
|
+
{
|
|
2473
|
+
value: "lower",
|
|
2474
|
+
description: "forces all literals to lowercase",
|
|
2475
|
+
since: "0.14.0"
|
|
2476
|
+
}
|
|
2477
|
+
]
|
|
2478
|
+
},
|
|
2479
|
+
sqlTypeCase: {
|
|
2480
|
+
type: "choice",
|
|
2481
|
+
category: "SQL",
|
|
2482
|
+
default: "upper",
|
|
2483
|
+
description: "Enforces upper/lower case for SQL types",
|
|
2484
|
+
choices: [
|
|
2485
|
+
{
|
|
2486
|
+
value: "preserve",
|
|
2487
|
+
description: "preserves the existing case",
|
|
2488
|
+
since: "0.17.0"
|
|
2489
|
+
},
|
|
2490
|
+
{
|
|
2491
|
+
value: "upper",
|
|
2492
|
+
description: "forces all type names to uppercase",
|
|
2493
|
+
since: "0.17.0"
|
|
2494
|
+
},
|
|
2495
|
+
{
|
|
2496
|
+
value: "lower",
|
|
2497
|
+
description: "forces all type names to lowercase",
|
|
2498
|
+
since: "0.17.0"
|
|
2499
|
+
}
|
|
2500
|
+
]
|
|
2501
|
+
},
|
|
2502
|
+
sqlIdentifierCase: {
|
|
2503
|
+
type: "choice",
|
|
2504
|
+
category: "SQL",
|
|
2505
|
+
default: "preserve",
|
|
2506
|
+
description: "Enforces upper/lower case for unquoted SQL identifiers",
|
|
2507
|
+
choices: [
|
|
2508
|
+
{
|
|
2509
|
+
value: "preserve",
|
|
2510
|
+
description: "preserves the existing case",
|
|
2511
|
+
since: "0.17.0"
|
|
2512
|
+
},
|
|
2513
|
+
{
|
|
2514
|
+
value: "upper",
|
|
2515
|
+
description: "forces all unquoted identifier names to uppercase",
|
|
2516
|
+
since: "0.17.0"
|
|
2517
|
+
},
|
|
2518
|
+
{
|
|
2519
|
+
value: "lower",
|
|
2520
|
+
description: "forces all unquoted identifier names to lowercase",
|
|
2521
|
+
since: "0.17.0"
|
|
2522
|
+
}
|
|
2523
|
+
]
|
|
2524
|
+
},
|
|
2525
|
+
sqlFunctionCase: {
|
|
2526
|
+
type: "choice",
|
|
2527
|
+
category: "SQL",
|
|
2528
|
+
default: "preserve",
|
|
2529
|
+
description: "Enforces upper/lower case for SQL function names",
|
|
2530
|
+
choices: [
|
|
2531
|
+
{
|
|
2532
|
+
value: "preserve",
|
|
2533
|
+
description: "preserves the existing case",
|
|
2534
|
+
since: "0.17.0"
|
|
2535
|
+
},
|
|
2536
|
+
{
|
|
2537
|
+
value: "upper",
|
|
2538
|
+
description: "forces all unquoted function names to uppercase",
|
|
2539
|
+
since: "0.17.0"
|
|
2540
|
+
},
|
|
2541
|
+
{
|
|
2542
|
+
value: "lower",
|
|
2543
|
+
description: "forces all unquoted function names to lowercase",
|
|
2544
|
+
since: "0.17.0"
|
|
2545
|
+
}
|
|
2546
|
+
]
|
|
2547
|
+
},
|
|
2548
|
+
sqlParamTypes: {
|
|
2549
|
+
type: "string",
|
|
2550
|
+
array: true,
|
|
2551
|
+
category: "SQL",
|
|
2552
|
+
default: [{ value: [] }],
|
|
2553
|
+
description: "Syntax for bound parameters"
|
|
2554
|
+
// Since 0.7.0
|
|
2555
|
+
// Possible values in array: "?" | "?nr" | "$nr" | ":name" | "$name" | "@name" | "@`name`"
|
|
2556
|
+
},
|
|
2557
|
+
sqlCanonicalSyntax: {
|
|
2558
|
+
type: "boolean",
|
|
2559
|
+
category: "SQL",
|
|
2560
|
+
default: true,
|
|
2561
|
+
description: "Enforces one true style of SQL syntax (adds and removes keywords)"
|
|
2562
|
+
// Since 0.11.0
|
|
2563
|
+
},
|
|
2564
|
+
sqlFinalSemicolon: {
|
|
2565
|
+
type: "boolean",
|
|
2566
|
+
category: "SQL",
|
|
2567
|
+
default: true,
|
|
2568
|
+
description: "Enforces a semicolon at the end of last SQL statement"
|
|
2569
|
+
// Since 0.13.0
|
|
2570
|
+
},
|
|
2571
|
+
sqlAcceptUnsupportedGrammar: {
|
|
2572
|
+
type: "boolean",
|
|
2573
|
+
category: "SQL",
|
|
2574
|
+
default: false,
|
|
2575
|
+
description: "Skips formatting unsupported SQL statements instead of exiting with an error"
|
|
2576
|
+
// Since 0.12.0
|
|
2577
|
+
}
|
|
2578
|
+
};
|
|
2579
|
+
|
|
2580
|
+
// src/index.ts
|
|
2581
|
+
var languages = [
|
|
2582
|
+
{
|
|
2583
|
+
extensions: [".sql", ".sqlite"],
|
|
2584
|
+
name: "SQLite SQL",
|
|
2585
|
+
parsers: ["sqlite"]
|
|
2586
|
+
},
|
|
2587
|
+
{
|
|
2588
|
+
extensions: [".bigquery"],
|
|
2589
|
+
name: "BigQuery SQL",
|
|
2590
|
+
parsers: ["bigquery"]
|
|
2591
|
+
},
|
|
2592
|
+
{
|
|
2593
|
+
extensions: [],
|
|
2594
|
+
name: "Experimental MySQL SQL",
|
|
2595
|
+
parsers: ["mysql"]
|
|
2596
|
+
},
|
|
2597
|
+
{
|
|
2598
|
+
extensions: [],
|
|
2599
|
+
name: "Experimental MariaDB SQL",
|
|
2600
|
+
parsers: ["mariadb"]
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
extensions: [],
|
|
2604
|
+
name: "Experimental PostgreSQL SQL",
|
|
2605
|
+
parsers: ["postgresql"]
|
|
2606
|
+
}
|
|
34
2607
|
];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
2608
|
+
var createParser = (dialect) => ({
|
|
2609
|
+
parse: (text, options2) => transformCst(
|
|
2610
|
+
parse(text, {
|
|
2611
|
+
dialect,
|
|
2612
|
+
includeRange: true,
|
|
2613
|
+
includeComments: true,
|
|
2614
|
+
filename: options2.filepath,
|
|
2615
|
+
paramTypes: options2.sqlParamTypes,
|
|
2616
|
+
acceptUnsupportedGrammar: options2.sqlAcceptUnsupportedGrammar
|
|
2617
|
+
}),
|
|
2618
|
+
text,
|
|
2619
|
+
options2
|
|
2620
|
+
),
|
|
2621
|
+
astFormat: "sql-cst",
|
|
2622
|
+
locStart: (node) => node.range?.[0],
|
|
2623
|
+
locEnd: (node) => node.range?.[1]
|
|
48
2624
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
2625
|
+
var parsers = {
|
|
2626
|
+
sqlite: createParser("sqlite"),
|
|
2627
|
+
bigquery: createParser("bigquery"),
|
|
2628
|
+
mysql: createParser("mysql"),
|
|
2629
|
+
mariadb: createParser("mariadb"),
|
|
2630
|
+
postgresql: createParser("postgresql")
|
|
2631
|
+
};
|
|
2632
|
+
var printers = {
|
|
2633
|
+
"sql-cst": {
|
|
2634
|
+
print: printSql,
|
|
2635
|
+
embed,
|
|
2636
|
+
printComment,
|
|
2637
|
+
canAttachComment: isNode,
|
|
2638
|
+
isBlockComment: (node) => node.type === "block_comment"
|
|
2639
|
+
}
|
|
2640
|
+
};
|
|
2641
|
+
export {
|
|
2642
|
+
languages,
|
|
2643
|
+
options,
|
|
2644
|
+
parsers,
|
|
2645
|
+
printers
|
|
64
2646
|
};
|