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/syntax/select.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { isDefined } from "../utils";
|
|
2
|
-
import { join, line, hardline, indent, group, containsNewline, breakParent, } from "../print_utils";
|
|
3
|
-
export const selectMap = {
|
|
4
|
-
compound_select_stmt: (print) => group(join(hardline, [print("left"), print.spaced("operator"), print("right")])),
|
|
5
|
-
select_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
|
|
6
|
-
// WITH clause
|
|
7
|
-
with_clause: (print) => group([
|
|
8
|
-
print.spaced(["withKw", "recursiveKw"]),
|
|
9
|
-
indent([line, print("tables")]),
|
|
10
|
-
]),
|
|
11
|
-
common_table_expr: (print, node) => [
|
|
12
|
-
print(["table", "columns"]),
|
|
13
|
-
" ",
|
|
14
|
-
print.spaced(["asKw", "materializedKw", "expr"]),
|
|
15
|
-
group([
|
|
16
|
-
node.search || node.cycle
|
|
17
|
-
? indent([line, print.separated(line, ["search", "cycle"])])
|
|
18
|
-
: [],
|
|
19
|
-
]),
|
|
20
|
-
],
|
|
21
|
-
cte_search_clause: (print) => group(join(line, [
|
|
22
|
-
[print.spaced("searchKw"), group(indent([line, print("columns")]))],
|
|
23
|
-
print.spaced(["setKw", "resultColumn"]),
|
|
24
|
-
])),
|
|
25
|
-
cte_cycle_clause: (print, node) => group(join(line, [
|
|
26
|
-
[print("cycleKw"), group(indent([line, print("columns")]))],
|
|
27
|
-
print.spaced(["setKw", "resultColumn"]),
|
|
28
|
-
node.values ? print("values") : undefined,
|
|
29
|
-
print.spaced(["usingKw", "pathColumn"]),
|
|
30
|
-
].filter(isDefined))),
|
|
31
|
-
cte_cycle_clause_values: (print) => join(line, [
|
|
32
|
-
print.spaced(["toKw", "markValue"]),
|
|
33
|
-
print.spaced(["defaultKw", "defaultValue"]),
|
|
34
|
-
]),
|
|
35
|
-
// SELECT clause
|
|
36
|
-
select_clause: (print, node, path, opts) => group([
|
|
37
|
-
print.spaced(["selectKw", "modifiers"]),
|
|
38
|
-
node.columns ? indent([line, print("columns")]) : [],
|
|
39
|
-
containsNewline(node, opts) ? breakParent : [],
|
|
40
|
-
]),
|
|
41
|
-
select_all: (print) => print.spaced(["allKw"]),
|
|
42
|
-
select_distinct: (print) => print.spaced(["distinctKw"]),
|
|
43
|
-
select_distinct_on: (print) => group([print.spaced(["distinctOnKw", "columns"])]),
|
|
44
|
-
select_as_struct: (print) => print.spaced(["asStructKw"]),
|
|
45
|
-
select_as_value: (print) => print.spaced(["asValueKw"]),
|
|
46
|
-
except_columns: (print) => print.spaced(["expr", "exceptKw", "columns"]),
|
|
47
|
-
replace_columns: (print) => print.spaced(["expr", "replaceKw", "columns"]),
|
|
48
|
-
// FROM clause
|
|
49
|
-
from_clause: (print) => group([print("fromKw"), indent([line, print("expr")])]),
|
|
50
|
-
join_expr: (print, node) => {
|
|
51
|
-
if (node.operator === ",") {
|
|
52
|
-
return join([",", hardline], print(["left", "right"]));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return [
|
|
56
|
-
print("left"),
|
|
57
|
-
hardline,
|
|
58
|
-
group(join(" ", [
|
|
59
|
-
print.spaced("operator"),
|
|
60
|
-
[
|
|
61
|
-
print("right"),
|
|
62
|
-
node.specification
|
|
63
|
-
? indent([line, print(["specification"])])
|
|
64
|
-
: [],
|
|
65
|
-
],
|
|
66
|
-
])),
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
join_on_specification: (print) => group(print.spaced(["onKw", "expr"])),
|
|
71
|
-
join_using_specification: (print) => group(print.spaced(["usingKw", "expr"])),
|
|
72
|
-
table_with_inheritance: (print) => [print("table"), " ", "*"],
|
|
73
|
-
table_without_inheritance: (print) => print.spaced(["onlyKw", "table"]),
|
|
74
|
-
indexed_table: (print) => print.spaced(["table", "indexedByKw", "index"]),
|
|
75
|
-
not_indexed_table: (print) => print.spaced(["table", "notIndexedKw"]),
|
|
76
|
-
unnest_expr: (print) => print(["unnestKw", "expr"]),
|
|
77
|
-
unnest_with_offset_expr: (print) => print.spaced(["unnest", "withOffsetKw"]),
|
|
78
|
-
pivot_expr: (print) => [print("left"), hardline, print(["pivotKw", "args"])],
|
|
79
|
-
pivot_for_in: (print) => group(join(line, [
|
|
80
|
-
group(print("aggregations")),
|
|
81
|
-
print.spaced(["forKw", "inputColumn"]),
|
|
82
|
-
print.spaced(["inKw", "pivotColumns"]),
|
|
83
|
-
])),
|
|
84
|
-
unpivot_expr: (print, node) => [
|
|
85
|
-
print("left"),
|
|
86
|
-
hardline,
|
|
87
|
-
(node.nullHandlingKw ? print.spaced : print)([
|
|
88
|
-
"unpivotKw",
|
|
89
|
-
"nullHandlingKw",
|
|
90
|
-
"args",
|
|
91
|
-
]),
|
|
92
|
-
],
|
|
93
|
-
unpivot_for_in: (print) => group(join(line, [
|
|
94
|
-
print("valuesColumn"),
|
|
95
|
-
print.spaced(["forKw", "nameColumn"]),
|
|
96
|
-
print.spaced(["inKw", "unpivotColumns"]),
|
|
97
|
-
])),
|
|
98
|
-
tablesample_expr: (print) => group([
|
|
99
|
-
print("left"),
|
|
100
|
-
line,
|
|
101
|
-
print.spaced(["tablesampleKw", "method", "args", "repeatable"]),
|
|
102
|
-
]),
|
|
103
|
-
tablesample_method: (print) => print.spaced(["methodKw"]),
|
|
104
|
-
tablesample_percent: (print) => print.spaced(["percent", "percentKw"]),
|
|
105
|
-
tablesample_repeatable: (print) => print.spaced(["repeatableKw", "seed"]),
|
|
106
|
-
for_system_time_as_of_expr: (print) => group([print("left"), line, print.spaced(["forSystemTimeAsOfKw", "expr"])]),
|
|
107
|
-
partitioned_table: (print) => print.spaced(["table", "partitionKw", "partitions"]),
|
|
108
|
-
dual_table: (print) => print("dualKw"),
|
|
109
|
-
lateral_derived_table: (print) => print.spaced(["lateralKw", "expr"]),
|
|
110
|
-
rows_from_expr: (print) => print.spaced(["rowsFromKw", "expr"]),
|
|
111
|
-
with_ordinality_expr: (print) => print.spaced(["expr", "withOrdinalityKw"]),
|
|
112
|
-
func_call_with_column_definitions: (print) => print.spaced(["funcCall", "asKw", "columns"]),
|
|
113
|
-
// WHERE clause
|
|
114
|
-
where_clause: (print) => group([print("whereKw"), indent([line, print("expr")])]),
|
|
115
|
-
// ORDER BY clause
|
|
116
|
-
order_by_clause: (print, node) => group([
|
|
117
|
-
print.spaced("orderByKw"),
|
|
118
|
-
indent([line, print.separated(line, ["specifications", "withRollupKw"])]),
|
|
119
|
-
]),
|
|
120
|
-
sort_specification: (print) => print.spaced(["expr", "direction", "nullHandlingKw"]),
|
|
121
|
-
sort_direction_asc: (print) => print("ascKw"),
|
|
122
|
-
sort_direction_desc: (print) => print("descKw"),
|
|
123
|
-
sort_direction_using_operator: (print) => print.spaced(["usingKw", "operator"]),
|
|
124
|
-
// GROUP BY clause
|
|
125
|
-
group_by_clause: (print, node) => group([
|
|
126
|
-
print.spaced(["groupByKw", "distinctKw"]),
|
|
127
|
-
indent([line, print.separated(line, ["columns", "withRollupKw"])]),
|
|
128
|
-
]),
|
|
129
|
-
group_by_rollup: (print) => print(["rollupKw", "columns"]),
|
|
130
|
-
group_by_cube: (print) => print(["cubeKw", "columns"]),
|
|
131
|
-
group_by_grouping_sets: (print) => print.spaced(["groupingSetsKw", "columns"]),
|
|
132
|
-
group_by_all: (print) => print(["allKw"]),
|
|
133
|
-
// PARTITION BY clause
|
|
134
|
-
partition_by_clause: (print) => group([
|
|
135
|
-
print.spaced("partitionByKw"),
|
|
136
|
-
indent([line, print("specifications")]),
|
|
137
|
-
]),
|
|
138
|
-
// HAVING clause
|
|
139
|
-
having_clause: (print) => group([print("havingKw"), indent([line, print("expr")])]),
|
|
140
|
-
// QUALIFY clause
|
|
141
|
-
qualify_clause: (print) => group([print("qualifyKw"), indent([line, print("expr")])]),
|
|
142
|
-
// LIMIT clause
|
|
143
|
-
/** cst-ignore: count, offsetKw, offset */
|
|
144
|
-
limit_clause: (print, node) => group([
|
|
145
|
-
print("limitKw"),
|
|
146
|
-
indent([
|
|
147
|
-
line,
|
|
148
|
-
printLimitValues(print, node),
|
|
149
|
-
node.rowsExamined ? [line, print("rowsExamined")] : [],
|
|
150
|
-
]),
|
|
151
|
-
]),
|
|
152
|
-
limit_all: (print) => print("allKw"),
|
|
153
|
-
limit_rows_examined: (print) => print.spaced(["rowsExaminedKw", "count"]),
|
|
154
|
-
// OFFSET clause
|
|
155
|
-
offset_clause: (print) => group([
|
|
156
|
-
print("offsetKw"),
|
|
157
|
-
indent([line, print.spaced(["offset", "rowsKw"])]),
|
|
158
|
-
]),
|
|
159
|
-
// FETCH clause
|
|
160
|
-
fetch_clause: (print) => print.spaced(["fetchKw", "count", "rowsKw", "withTiesKw"]),
|
|
161
|
-
// WINDOW clause
|
|
162
|
-
window_clause: (print, node) => {
|
|
163
|
-
const lineType = node.namedWindows.items.length > 1 ? hardline : line;
|
|
164
|
-
return group([
|
|
165
|
-
print("windowKw"),
|
|
166
|
-
indent([lineType, print("namedWindows")]),
|
|
167
|
-
]);
|
|
168
|
-
},
|
|
169
|
-
named_window: (print) => print.spaced(["name", "asKw", "window"]),
|
|
170
|
-
window_definition: (print, node) => {
|
|
171
|
-
const itemCount = [
|
|
172
|
-
node.baseWindowName,
|
|
173
|
-
node.partitionBy,
|
|
174
|
-
node.orderBy,
|
|
175
|
-
node.frame,
|
|
176
|
-
].filter(isDefined).length;
|
|
177
|
-
const lineType = itemCount > 1 ? hardline : line;
|
|
178
|
-
return group(join(lineType, print(["baseWindowName", "partitionBy", "orderBy", "frame"])));
|
|
179
|
-
},
|
|
180
|
-
// INTO clause
|
|
181
|
-
into_table_clause: (print) => print.spaced(["intoKw", "kind", "tableKw", "name"]),
|
|
182
|
-
into_variables_clause: (print) => group([print("intoKw"), indent([line, print("variables")])]),
|
|
183
|
-
into_dumpfile_clause: (print) => print.spaced(["intoDumpfileKw", "filename"]),
|
|
184
|
-
into_outfile_clause: (print, node) => {
|
|
185
|
-
const hasOptions = node.charset || node.fields || node.lines;
|
|
186
|
-
return group([
|
|
187
|
-
print.spaced(["intoOutfileKw", "filename"]),
|
|
188
|
-
hasOptions
|
|
189
|
-
? indent([
|
|
190
|
-
hardline,
|
|
191
|
-
join(hardline, print(["charset", "fields", "lines"])),
|
|
192
|
-
])
|
|
193
|
-
: [],
|
|
194
|
-
]);
|
|
195
|
-
},
|
|
196
|
-
outfile_fields: (print) => print.spaced(["fieldsKw", "options"]),
|
|
197
|
-
outfile_lines: (print) => print.spaced(["linesKw", "options"]),
|
|
198
|
-
outfile_option_character_set: (print) => print.spaced(["characterSetKw", "value"]),
|
|
199
|
-
outfile_option_starting_by: (print) => print.spaced(["startingByKw", "value"]),
|
|
200
|
-
outfile_option_terminated_by: (print) => print.spaced(["terminatedByKw", "value"]),
|
|
201
|
-
outfile_option_enclosed_by: (print) => print.spaced(["optionallyKw", "enclosedByKw", "value"]),
|
|
202
|
-
outfile_option_escaped_by: (print) => print.spaced(["escapedByKw", "value"]),
|
|
203
|
-
// FOR clause (locking)
|
|
204
|
-
for_clause: (print, node) => group([
|
|
205
|
-
print.spaced(["forKw", "lockStrengthKw", "tables"]),
|
|
206
|
-
node.waitingKw ? indent([line, print.spaced("waitingKw")]) : [],
|
|
207
|
-
]),
|
|
208
|
-
for_clause_tables: (print) => [
|
|
209
|
-
print("ofKw"),
|
|
210
|
-
indent([line, print("tables")]),
|
|
211
|
-
],
|
|
212
|
-
lock_in_share_mode_clause: (print) => print.spaced("lockInShareModeKw"),
|
|
213
|
-
// TABLE clause
|
|
214
|
-
table_clause: (print) => print.spaced(["tableKw", "table"]),
|
|
215
|
-
};
|
|
216
|
-
const printLimitValues = (print, node) => {
|
|
217
|
-
if (node.offsetKw) {
|
|
218
|
-
return print.spaced(["count", "offsetKw", "offset"]);
|
|
219
|
-
}
|
|
220
|
-
else if (node.offset) {
|
|
221
|
-
return join([",", " "], print(["offset", "count"]));
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
return print("count");
|
|
225
|
-
}
|
|
226
|
-
};
|
package/dist/syntax/sequence.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { group, indent, join, line } from "../print_utils";
|
|
2
|
-
export const sequenceMap = {
|
|
3
|
-
create_sequence_stmt: (print, node) => group([
|
|
4
|
-
print.spaced(["createKw", "kind", "sequenceKw", "ifNotExistsKw", "name"]),
|
|
5
|
-
node.options.length > 0
|
|
6
|
-
? indent([print.dynamicLine(), join(line, print("options"))])
|
|
7
|
-
: [],
|
|
8
|
-
]),
|
|
9
|
-
alter_sequence_stmt: (print) => group([
|
|
10
|
-
print.spaced(["alterKw", "sequenceKw", "ifExistsKw", "sequence"]),
|
|
11
|
-
indent([print.dynamicLine(), join(line, print("actions"))]),
|
|
12
|
-
]),
|
|
13
|
-
drop_sequence_stmt: (print) => group(print.spaced([
|
|
14
|
-
"dropKw",
|
|
15
|
-
"sequenceKw",
|
|
16
|
-
"ifExistsKw",
|
|
17
|
-
"sequences",
|
|
18
|
-
"behaviorKw",
|
|
19
|
-
])),
|
|
20
|
-
sequence_option_sequence_name: (print) => print.spaced(["sequenceNameKw", "name"]),
|
|
21
|
-
sequence_option_logged: (print) => print.spaced("loggedKw"),
|
|
22
|
-
sequence_option_unlogged: (print) => print.spaced("unloggedKw"),
|
|
23
|
-
sequence_option_as_type: (print) => print.spaced(["asKw", "dataType"]),
|
|
24
|
-
sequence_option_increment: (print) => print.spaced(["incrementKw", "byKw", "value"]),
|
|
25
|
-
sequence_option_minvalue: (print) => print.spaced(["minvalueKw", "value"]),
|
|
26
|
-
sequence_option_maxvalue: (print) => print.spaced(["maxvalueKw", "value"]),
|
|
27
|
-
sequence_option_no_minvalue: (print) => print.spaced("noMinvalueKw"),
|
|
28
|
-
sequence_option_no_maxvalue: (print) => print.spaced("noMaxvalueKw"),
|
|
29
|
-
sequence_option_start: (print) => print.spaced(["startKw", "withKw", "value"]),
|
|
30
|
-
sequence_option_restart: (print) => print.spaced(["restartKw", "withKw", "value"]),
|
|
31
|
-
sequence_option_cache: (print) => print.spaced(["cacheKw", "value"]),
|
|
32
|
-
sequence_option_cycle: (print) => print.spaced("cycleKw"),
|
|
33
|
-
sequence_option_no_cycle: (print) => print.spaced("noCycleKw"),
|
|
34
|
-
sequence_option_owned_by: (print) => print.spaced(["ownedByKw", "owner"]),
|
|
35
|
-
sequence_option_list: (print) => join(line, print("options")),
|
|
36
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { group, line, join } from "../print_utils";
|
|
2
|
-
export const subscriptionMap = {
|
|
3
|
-
create_subscription_stmt: (print, node) => group(join(line, [
|
|
4
|
-
print.spaced(["createSubscriptionKw", "name"]),
|
|
5
|
-
print.spaced(["connectionKw", "connectionInfo"]),
|
|
6
|
-
print.spaced(["publicationKw", "publications"]),
|
|
7
|
-
...(node.with ? [print.spaced(["with"])] : []),
|
|
8
|
-
])),
|
|
9
|
-
drop_subscription_stmt: (print) => group(print.spaced(["dropSubscriptionKw", "ifExistsKw", "name", "behaviorKw"])),
|
|
10
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { group, indent, line } from "../print_utils";
|
|
2
|
-
export const transactionMap = {
|
|
3
|
-
start_transaction_stmt: (print, node) => group([
|
|
4
|
-
print.spaced(["startKw", "behaviorKw", "transactionKw"]),
|
|
5
|
-
node.modes ? indent([line, print("modes")]) : [],
|
|
6
|
-
]),
|
|
7
|
-
commit_transaction_stmt: (print) => group(print.spaced(["commitKw", "transactionKw", "chain"])),
|
|
8
|
-
rollback_transaction_stmt: (print) => group(print.spaced(["rollbackKw", "transactionKw", "savepoint", "chain"])),
|
|
9
|
-
rollback_to_savepoint: (print) => print.spaced(["toKw", "savepointKw", "savepoint"]),
|
|
10
|
-
savepoint_stmt: (print) => group(print.spaced(["savepointKw", "savepoint"])),
|
|
11
|
-
release_savepoint_stmt: (print) => group(print.spaced(["releaseKw", "savepointKw", "savepoint"])),
|
|
12
|
-
transaction_chain_clause: (print) => print.spaced("andChainKw"),
|
|
13
|
-
transaction_no_chain_clause: (print) => print.spaced("andNoChainKw"),
|
|
14
|
-
transaction_mode_isolation_level: (print) => print.spaced(["isolationLevelKw", "levelKw"]),
|
|
15
|
-
transaction_mode_deferrable: (print) => print.spaced("deferrableKw"),
|
|
16
|
-
transaction_mode_not_deferrable: (print) => print.spaced("notDeferrableKw"),
|
|
17
|
-
transaction_mode_read_only: (print) => print.spaced("readOnlyKw"),
|
|
18
|
-
transaction_mode_read_write: (print) => print.spaced("readWriteKw"),
|
|
19
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { aliasMap } from "./alias";
|
|
2
|
-
import { alterActionMap } from "./alter_action";
|
|
3
|
-
import { alterTableMap } from "./alter_table";
|
|
4
|
-
import { analyzeMap } from "./analyze";
|
|
5
|
-
import { baseMap } from "./base";
|
|
6
|
-
import { castMap } from "./cast";
|
|
7
|
-
import { commentMap } from "./comment";
|
|
8
|
-
import { constraintMap } from "./constraint";
|
|
9
|
-
import { createTableMap } from "./create_table";
|
|
10
|
-
import { dataTypeMap } from "./data_type";
|
|
11
|
-
import { dclMap } from "./dcl";
|
|
12
|
-
import { deleteMap } from "./delete";
|
|
13
|
-
import { doMap } from "./do";
|
|
14
|
-
import { domainMap } from "./domain";
|
|
15
|
-
import { dropTableMap } from "./drop_table";
|
|
16
|
-
import { explainMap } from "./explain";
|
|
17
|
-
import { exprMap } from "./expr";
|
|
18
|
-
import { extensionMap } from "./extension";
|
|
19
|
-
import { frameMap } from "./frame";
|
|
20
|
-
import { functionMap } from "./function";
|
|
21
|
-
import { indexMap } from "./index";
|
|
22
|
-
import { insertMap } from "./insert";
|
|
23
|
-
import { mergeMap } from "./merge";
|
|
24
|
-
import { otherClausesMap } from "./other_clauses";
|
|
25
|
-
import { renameTableMap } from "./rename_table";
|
|
26
|
-
import { roleMap } from "./role";
|
|
27
|
-
import { parameterMap } from "./parameter";
|
|
28
|
-
import { policyMap } from "./policy";
|
|
29
|
-
import { preparedStatementsMap } from "./prepared_statements";
|
|
30
|
-
import { proceduralLanguageMap } from "./procedural_language";
|
|
31
|
-
import { procedureMap } from "./procedure";
|
|
32
|
-
import { procClauseMap } from "./proc_clause";
|
|
33
|
-
import { programMap } from "./program";
|
|
34
|
-
import { publicationMap } from "./publication";
|
|
35
|
-
import { schemaMap } from "./schema";
|
|
36
|
-
import { selectMap } from "./select";
|
|
37
|
-
import { sequenceMap } from "./sequence";
|
|
38
|
-
import { subscriptionMap } from "./subscription";
|
|
39
|
-
import { transactionMap } from "./transaction";
|
|
40
|
-
import { triggerMap } from "./trigger";
|
|
41
|
-
import { truncateMap } from "./truncate";
|
|
42
|
-
import { typeMap } from "./type";
|
|
43
|
-
import { unsupportedGrammarMap } from "./unsupported_grammar";
|
|
44
|
-
import { updateMap } from "./update";
|
|
45
|
-
import { viewMap } from "./view";
|
|
46
|
-
import { bigqueryMap } from "./dialects/bigquery";
|
|
47
|
-
import { mysqlMap } from "./dialects/mysql";
|
|
48
|
-
import { sqliteMap } from "./dialects/sqlite";
|
|
49
|
-
import { postgresqlMap } from "./dialects/postgresql";
|
|
50
|
-
export const transformMap = {
|
|
51
|
-
...aliasMap,
|
|
52
|
-
...alterActionMap,
|
|
53
|
-
...alterTableMap,
|
|
54
|
-
...analyzeMap,
|
|
55
|
-
...baseMap,
|
|
56
|
-
...castMap,
|
|
57
|
-
...commentMap,
|
|
58
|
-
...constraintMap,
|
|
59
|
-
...createTableMap,
|
|
60
|
-
...dataTypeMap,
|
|
61
|
-
...dclMap,
|
|
62
|
-
...deleteMap,
|
|
63
|
-
...doMap,
|
|
64
|
-
...domainMap,
|
|
65
|
-
...dropTableMap,
|
|
66
|
-
...explainMap,
|
|
67
|
-
...exprMap,
|
|
68
|
-
...extensionMap,
|
|
69
|
-
...frameMap,
|
|
70
|
-
...functionMap,
|
|
71
|
-
...indexMap,
|
|
72
|
-
...insertMap,
|
|
73
|
-
...mergeMap,
|
|
74
|
-
...otherClausesMap,
|
|
75
|
-
...parameterMap,
|
|
76
|
-
...policyMap,
|
|
77
|
-
...preparedStatementsMap,
|
|
78
|
-
...procClauseMap,
|
|
79
|
-
...proceduralLanguageMap,
|
|
80
|
-
...procedureMap,
|
|
81
|
-
...programMap,
|
|
82
|
-
...publicationMap,
|
|
83
|
-
...renameTableMap,
|
|
84
|
-
...roleMap,
|
|
85
|
-
...schemaMap,
|
|
86
|
-
...selectMap,
|
|
87
|
-
...sequenceMap,
|
|
88
|
-
...subscriptionMap,
|
|
89
|
-
...transactionMap,
|
|
90
|
-
...triggerMap,
|
|
91
|
-
...truncateMap,
|
|
92
|
-
...typeMap,
|
|
93
|
-
...unsupportedGrammarMap,
|
|
94
|
-
...updateMap,
|
|
95
|
-
...viewMap,
|
|
96
|
-
...bigqueryMap,
|
|
97
|
-
...mysqlMap,
|
|
98
|
-
...postgresqlMap,
|
|
99
|
-
...sqliteMap,
|
|
100
|
-
};
|
package/dist/syntax/trigger.d.ts
DELETED
package/dist/syntax/trigger.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { group, hardline, indent, join, line } from "../print_utils";
|
|
2
|
-
export const triggerMap = {
|
|
3
|
-
create_trigger_stmt: (print, node) => group(join(hardline, [
|
|
4
|
-
print.spaced([
|
|
5
|
-
"createKw",
|
|
6
|
-
"orReplaceKw",
|
|
7
|
-
"kind",
|
|
8
|
-
"triggerKw",
|
|
9
|
-
"ifNotExistsKw",
|
|
10
|
-
"name",
|
|
11
|
-
]),
|
|
12
|
-
group([
|
|
13
|
-
node.timeKw ? [print.spaced("timeKw"), " "] : [],
|
|
14
|
-
print("event"),
|
|
15
|
-
line,
|
|
16
|
-
print("target"),
|
|
17
|
-
]),
|
|
18
|
-
...print("clauses"),
|
|
19
|
-
print("body"),
|
|
20
|
-
])),
|
|
21
|
-
trigger_event: (print, node) => group([
|
|
22
|
-
print.spaced(["eventKw", "ofKw"]),
|
|
23
|
-
node.columns ? indent([line, print("columns")]) : [],
|
|
24
|
-
]),
|
|
25
|
-
trigger_target: (print) => print.spaced(["onKw", "table"]),
|
|
26
|
-
when_clause: (print) => group([print("whenKw"), indent([line, print("expr")])]),
|
|
27
|
-
for_each_clause: (print) => print.spaced(["forEachKw", "itemKw"]),
|
|
28
|
-
execute_clause: (print) => [
|
|
29
|
-
print.spaced(["executeKw", "functionKw", "name"]),
|
|
30
|
-
print("args"),
|
|
31
|
-
],
|
|
32
|
-
from_referenced_table_clause: (print) => print.spaced(["fromKw", "table"]),
|
|
33
|
-
trigger_timing_clause: (print) => print.spaced(["timingKw"]),
|
|
34
|
-
trigger_referencing_clause: (print) => group([
|
|
35
|
-
print.spaced(["referencingKw"]),
|
|
36
|
-
indent([line, print("transitions")]),
|
|
37
|
-
]),
|
|
38
|
-
trigger_transition: (print) => [
|
|
39
|
-
print.spaced(["oldOrNewKw", "rowOrTableKw", "asKw", "name"]),
|
|
40
|
-
],
|
|
41
|
-
alter_trigger_stmt: (print) => group(join(print.dynamicLine(), [
|
|
42
|
-
print.spaced(["alterTriggerKw", "trigger", "target"]),
|
|
43
|
-
print("action"),
|
|
44
|
-
])),
|
|
45
|
-
drop_trigger_stmt: (print) => group(print.spaced([
|
|
46
|
-
"dropTriggerKw",
|
|
47
|
-
"ifExistsKw",
|
|
48
|
-
"trigger",
|
|
49
|
-
"target",
|
|
50
|
-
"behaviorKw",
|
|
51
|
-
])),
|
|
52
|
-
};
|
package/dist/syntax/truncate.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { group, indent, line } from "../print_utils";
|
|
2
|
-
export const truncateMap = {
|
|
3
|
-
truncate_stmt: (print) => group([
|
|
4
|
-
print.spaced(["truncateKw", "tableKw"]),
|
|
5
|
-
indent([
|
|
6
|
-
line,
|
|
7
|
-
print.separated(line, ["tables", "restartOrContinueKw", "behaviorKw"]),
|
|
8
|
-
]),
|
|
9
|
-
]),
|
|
10
|
-
};
|
package/dist/syntax/type.d.ts
DELETED
package/dist/syntax/type.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { group } from "../print_utils";
|
|
2
|
-
export const typeMap = {
|
|
3
|
-
create_type_stmt: (print) => group([print.spaced(["createTypeKw", "name", "definition"])]),
|
|
4
|
-
composite_type_definition: (print) => group(print.spaced(["asKw", "columns"])),
|
|
5
|
-
enum_type_definition: (print) => group(print.spaced(["asEnumKw", "values"])),
|
|
6
|
-
alter_type_stmt: (print, node) => group([
|
|
7
|
-
print.spaced(["alterTypeKw", "name"]),
|
|
8
|
-
print.dynamicLine(),
|
|
9
|
-
print("actions"),
|
|
10
|
-
]),
|
|
11
|
-
drop_type_stmt: (print) => group(print.spaced(["dropTypeKw", "ifExistsKw", "types", "behaviorKw"])),
|
|
12
|
-
};
|
package/dist/syntax/update.d.ts
DELETED
package/dist/syntax/update.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { join, hardline, indent, group } from "../print_utils";
|
|
2
|
-
export const updateMap = {
|
|
3
|
-
update_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
|
|
4
|
-
update_clause: (print) => print.spaced(["updateKw", "modifiers", "orAction", "tables"]),
|
|
5
|
-
set_clause: (print, node) => {
|
|
6
|
-
if (node.assignments.items.length > 1) {
|
|
7
|
-
return [print("setKw"), indent([hardline, print("assignments")])];
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
return print.spaced(["setKw", "assignments"]);
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
column_assignment: (print) => join([" ", "=", " "], print(["column", "expr"])),
|
|
14
|
-
};
|
package/dist/syntax/view.d.ts
DELETED
package/dist/syntax/view.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { group, hardline, join, line } from "../print_utils";
|
|
2
|
-
export const viewMap = {
|
|
3
|
-
create_view_stmt: (print, node) => {
|
|
4
|
-
const hasOnlyAsClause = node.clauses.length === 1;
|
|
5
|
-
const hasManyClauses = node.clauses.length > 1;
|
|
6
|
-
return group([
|
|
7
|
-
print.spaced([
|
|
8
|
-
"createKw",
|
|
9
|
-
"orReplaceKw",
|
|
10
|
-
"kinds",
|
|
11
|
-
"viewKw",
|
|
12
|
-
"ifNotExistsKw",
|
|
13
|
-
"name",
|
|
14
|
-
"columns",
|
|
15
|
-
]),
|
|
16
|
-
hasOnlyAsClause ? [" ", print("clauses")] : [],
|
|
17
|
-
hasManyClauses ? [hardline, join(hardline, print("clauses"))] : [],
|
|
18
|
-
]);
|
|
19
|
-
},
|
|
20
|
-
with_check_option_clause: (print) => print.spaced(["withKw", "levelKw", "checkOptionKw"]),
|
|
21
|
-
as_replica_of_clause: (print) => print.spaced(["asReplicaOfKw", "view"]),
|
|
22
|
-
drop_view_stmt: (print) => group(print.spaced([
|
|
23
|
-
"dropKw",
|
|
24
|
-
"kind",
|
|
25
|
-
"viewKw",
|
|
26
|
-
"ifExistsKw",
|
|
27
|
-
"views",
|
|
28
|
-
"behaviorKw",
|
|
29
|
-
])),
|
|
30
|
-
alter_view_stmt: (print) => group([
|
|
31
|
-
print.spaced([
|
|
32
|
-
"alterKw",
|
|
33
|
-
"kind",
|
|
34
|
-
"viewKw",
|
|
35
|
-
"ifExistsKw",
|
|
36
|
-
"name",
|
|
37
|
-
"columns",
|
|
38
|
-
]),
|
|
39
|
-
hardline,
|
|
40
|
-
print("actions"),
|
|
41
|
-
]),
|
|
42
|
-
refresh_materialized_view_stmt: (print, node) => group([
|
|
43
|
-
print.spaced(["refreshMaterializedViewKw", "concurrentlyKw", "name"]),
|
|
44
|
-
node.clauses.length > 0
|
|
45
|
-
? [print.dynamicLine(), join(line, print("clauses"))]
|
|
46
|
-
: [],
|
|
47
|
-
]),
|
|
48
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { isEmpty } from "../node_utils";
|
|
2
|
-
import { last } from "../utils";
|
|
3
|
-
export const addFinalSemicolon = (program, originalText) => {
|
|
4
|
-
if (!isEmpty(last(program.statements))) {
|
|
5
|
-
const end = originalText.length;
|
|
6
|
-
program.statements.push({ type: "empty", range: [end, end] });
|
|
7
|
-
}
|
|
8
|
-
return program;
|
|
9
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { cstVisitor } from "sql-parser-cst";
|
|
2
|
-
// Adds AS keyword to aliases if none exists
|
|
3
|
-
export const processAliasAs = (cst) => {
|
|
4
|
-
cstVisitor({
|
|
5
|
-
alias: (node) => {
|
|
6
|
-
node.asKw = node.asKw || { type: "keyword", name: "AS", text: "AS" };
|
|
7
|
-
},
|
|
8
|
-
})(cst);
|
|
9
|
-
return cst;
|
|
10
|
-
};
|