prettier-plugin-sql-cst 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CstToDocMap.d.ts +2 -2
- package/dist/CstToDocMap.js +1 -2
- package/dist/PrintFn.js +1 -2
- package/dist/embed.js +5 -13
- package/dist/embedJs.js +28 -84
- package/dist/embedJson.js +29 -85
- package/dist/embedSql.js +26 -76
- package/dist/index.js +28 -34
- package/dist/node_utils.d.ts +1 -0
- package/dist/node_utils.js +44 -54
- package/dist/options.js +1 -4
- package/dist/printComment.js +2 -6
- package/dist/printSql.js +29 -39
- package/dist/print_utils.js +19 -38
- package/dist/syntax/alias.js +2 -5
- package/dist/syntax/alter_action.js +115 -208
- package/dist/syntax/alter_table.js +18 -27
- package/dist/syntax/analyze.js +3 -8
- package/dist/syntax/base.js +6 -9
- package/dist/syntax/cast.js +3 -6
- package/dist/syntax/comment.js +53 -122
- package/dist/syntax/constraint.d.ts +1 -1
- package/dist/syntax/constraint.js +54 -90
- package/dist/syntax/create_table.js +49 -87
- package/dist/syntax/data_type.js +25 -44
- package/dist/syntax/dcl.js +78 -136
- package/dist/syntax/delete.js +4 -9
- package/dist/syntax/dialects/bigquery.js +70 -116
- package/dist/syntax/dialects/mysql.js +2 -5
- package/dist/syntax/dialects/postgresql.js +8 -13
- package/dist/syntax/dialects/sqlite.js +8 -17
- package/dist/syntax/do.js +3 -6
- package/dist/syntax/domain.js +10 -19
- package/dist/syntax/drop_table.js +10 -15
- package/dist/syntax/explain.js +6 -11
- package/dist/syntax/expr.js +124 -173
- package/dist/syntax/extension.js +12 -21
- package/dist/syntax/frame.js +11 -16
- package/dist/syntax/function.js +53 -63
- package/dist/syntax/index.js +54 -81
- package/dist/syntax/insert.js +32 -49
- package/dist/syntax/merge.js +25 -30
- package/dist/syntax/other_clauses.js +5 -14
- package/dist/syntax/parameter.js +13 -26
- package/dist/syntax/policy.js +26 -41
- package/dist/syntax/prepared_statements.js +23 -43
- package/dist/syntax/proc_clause.js +10 -15
- package/dist/syntax/procedural_language.js +80 -111
- package/dist/syntax/procedure.js +36 -40
- package/dist/syntax/program.js +15 -22
- package/dist/syntax/publication.js +26 -47
- package/dist/syntax/rename_table.js +7 -12
- package/dist/syntax/role.js +30 -55
- package/dist/syntax/schema.js +17 -35
- package/dist/syntax/select.js +157 -226
- package/dist/syntax/sequence.js +35 -52
- package/dist/syntax/subscription.js +9 -24
- package/dist/syntax/transaction.js +18 -33
- package/dist/syntax/transformMap.js +99 -63
- package/dist/syntax/trigger.js +48 -72
- package/dist/syntax/truncate.js +9 -14
- package/dist/syntax/type.js +11 -22
- package/dist/syntax/unsupported_grammar.js +3 -6
- package/dist/syntax/update.js +7 -14
- package/dist/syntax/view.js +32 -43
- package/dist/transform/addFinalSemicolon.js +5 -9
- package/dist/transform/aliasAs.js +4 -8
- package/dist/transform/canonicKeywords.js +16 -20
- package/dist/transform/canonicOperators.js +8 -12
- package/dist/transform/comments.js +10 -31
- package/dist/transform/stripTrailingCommas.js +7 -11
- package/dist/transform/transformCst.js +13 -17
- package/dist/transform/transformUtils.js +2 -6
- package/dist/utils.js +9 -30
- package/dist/visitAllNodes.js +8 -13
- package/package.json +9 -8
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return print.spaced(["toKw", "savepointKw", "savepoint"]);
|
|
20
|
-
},
|
|
21
|
-
savepoint_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["savepointKw", "savepoint"])); },
|
|
22
|
-
release_savepoint_stmt: function (print) {
|
|
23
|
-
return (0, print_utils_1.group)(print.spaced(["releaseKw", "savepointKw", "savepoint"]));
|
|
24
|
-
},
|
|
25
|
-
transaction_chain_clause: function (print) { return print.spaced("andChainKw"); },
|
|
26
|
-
transaction_no_chain_clause: function (print) { return print.spaced("andNoChainKw"); },
|
|
27
|
-
transaction_mode_isolation_level: function (print) {
|
|
28
|
-
return print.spaced(["isolationLevelKw", "levelKw"]);
|
|
29
|
-
},
|
|
30
|
-
transaction_mode_deferrable: function (print) { return print.spaced("deferrableKw"); },
|
|
31
|
-
transaction_mode_not_deferrable: function (print) { return print.spaced("notDeferrableKw"); },
|
|
32
|
-
transaction_mode_read_only: function (print) { return print.spaced("readOnlyKw"); },
|
|
33
|
-
transaction_mode_read_write: function (print) { return print.spaced("readWriteKw"); },
|
|
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"),
|
|
34
19
|
};
|
|
@@ -1,64 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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,
|
|
12
100
|
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.transformMap = void 0;
|
|
15
|
-
var alias_1 = require("./alias");
|
|
16
|
-
var alter_action_1 = require("./alter_action");
|
|
17
|
-
var alter_table_1 = require("./alter_table");
|
|
18
|
-
var analyze_1 = require("./analyze");
|
|
19
|
-
var base_1 = require("./base");
|
|
20
|
-
var cast_1 = require("./cast");
|
|
21
|
-
var comment_1 = require("./comment");
|
|
22
|
-
var constraint_1 = require("./constraint");
|
|
23
|
-
var create_table_1 = require("./create_table");
|
|
24
|
-
var data_type_1 = require("./data_type");
|
|
25
|
-
var dcl_1 = require("./dcl");
|
|
26
|
-
var delete_1 = require("./delete");
|
|
27
|
-
var do_1 = require("./do");
|
|
28
|
-
var domain_1 = require("./domain");
|
|
29
|
-
var drop_table_1 = require("./drop_table");
|
|
30
|
-
var explain_1 = require("./explain");
|
|
31
|
-
var expr_1 = require("./expr");
|
|
32
|
-
var extension_1 = require("./extension");
|
|
33
|
-
var frame_1 = require("./frame");
|
|
34
|
-
var function_1 = require("./function");
|
|
35
|
-
var index_1 = require("./index");
|
|
36
|
-
var insert_1 = require("./insert");
|
|
37
|
-
var merge_1 = require("./merge");
|
|
38
|
-
var other_clauses_1 = require("./other_clauses");
|
|
39
|
-
var rename_table_1 = require("./rename_table");
|
|
40
|
-
var role_1 = require("./role");
|
|
41
|
-
var parameter_1 = require("./parameter");
|
|
42
|
-
var policy_1 = require("./policy");
|
|
43
|
-
var prepared_statements_1 = require("./prepared_statements");
|
|
44
|
-
var procedural_language_1 = require("./procedural_language");
|
|
45
|
-
var procedure_1 = require("./procedure");
|
|
46
|
-
var proc_clause_1 = require("./proc_clause");
|
|
47
|
-
var program_1 = require("./program");
|
|
48
|
-
var publication_1 = require("./publication");
|
|
49
|
-
var schema_1 = require("./schema");
|
|
50
|
-
var select_1 = require("./select");
|
|
51
|
-
var sequence_1 = require("./sequence");
|
|
52
|
-
var subscription_1 = require("./subscription");
|
|
53
|
-
var transaction_1 = require("./transaction");
|
|
54
|
-
var trigger_1 = require("./trigger");
|
|
55
|
-
var truncate_1 = require("./truncate");
|
|
56
|
-
var type_1 = require("./type");
|
|
57
|
-
var unsupported_grammar_1 = require("./unsupported_grammar");
|
|
58
|
-
var update_1 = require("./update");
|
|
59
|
-
var view_1 = require("./view");
|
|
60
|
-
var bigquery_1 = require("./dialects/bigquery");
|
|
61
|
-
var mysql_1 = require("./dialects/mysql");
|
|
62
|
-
var sqlite_1 = require("./dialects/sqlite");
|
|
63
|
-
var postgresql_1 = require("./dialects/postgresql");
|
|
64
|
-
exports.transformMap = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, alias_1.aliasMap), alter_action_1.alterActionMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), cast_1.castMap), comment_1.commentMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), dcl_1.dclMap), delete_1.deleteMap), do_1.doMap), domain_1.domainMap), drop_table_1.dropTableMap), explain_1.explainMap), expr_1.exprMap), extension_1.extensionMap), frame_1.frameMap), function_1.functionMap), index_1.indexMap), insert_1.insertMap), merge_1.mergeMap), other_clauses_1.otherClausesMap), parameter_1.parameterMap), policy_1.policyMap), prepared_statements_1.preparedStatementsMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), procedure_1.procedureMap), program_1.programMap), publication_1.publicationMap), rename_table_1.renameTableMap), role_1.roleMap), schema_1.schemaMap), select_1.selectMap), sequence_1.sequenceMap), subscription_1.subscriptionMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), type_1.typeMap), unsupported_grammar_1.unsupportedGrammarMap), update_1.updateMap), view_1.viewMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), sqlite_1.sqliteMap);
|
package/dist/syntax/trigger.js
CHANGED
|
@@ -1,76 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
print("target"),
|
|
30
|
-
])
|
|
31
|
-
], print("clauses"), true), [
|
|
32
|
-
print("body"),
|
|
33
|
-
], false)));
|
|
34
|
-
},
|
|
35
|
-
trigger_event: function (print, node) {
|
|
36
|
-
return (0, print_utils_1.group)([
|
|
37
|
-
print.spaced(["eventKw", "ofKw"]),
|
|
38
|
-
node.columns ? (0, print_utils_1.indent)([print_utils_1.line, print("columns")]) : [],
|
|
39
|
-
]);
|
|
40
|
-
},
|
|
41
|
-
trigger_target: function (print) { return print.spaced(["onKw", "table"]); },
|
|
42
|
-
when_clause: function (print) {
|
|
43
|
-
return (0, print_utils_1.group)([print("whenKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
|
|
44
|
-
},
|
|
45
|
-
for_each_clause: function (print) { return print.spaced(["forEachKw", "itemKw"]); },
|
|
46
|
-
execute_clause: function (print) { return [
|
|
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) => [
|
|
47
29
|
print.spaced(["executeKw", "functionKw", "name"]),
|
|
48
30
|
print("args"),
|
|
49
|
-
]
|
|
50
|
-
from_referenced_table_clause:
|
|
51
|
-
trigger_timing_clause:
|
|
52
|
-
trigger_referencing_clause:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
trigger_transition: function (print) { return [
|
|
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) => [
|
|
59
39
|
print.spaced(["oldOrNewKw", "rowOrTableKw", "asKw", "name"]),
|
|
60
|
-
]
|
|
61
|
-
alter_trigger_stmt:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"target",
|
|
73
|
-
"behaviorKw",
|
|
74
|
-
]));
|
|
75
|
-
},
|
|
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
|
+
])),
|
|
76
52
|
};
|
package/dist/syntax/truncate.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
print_utils_1.line,
|
|
11
|
-
print.separated(print_utils_1.line, ["tables", "restartOrContinueKw", "behaviorKw"]),
|
|
12
|
-
]),
|
|
13
|
-
]);
|
|
14
|
-
},
|
|
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
|
+
]),
|
|
15
10
|
};
|
package/dist/syntax/type.js
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
enum_type_definition: function (print) { return (0, print_utils_1.group)(print.spaced(["asEnumKw", "values"])); },
|
|
13
|
-
alter_type_stmt: function (print, node) {
|
|
14
|
-
return (0, print_utils_1.group)([
|
|
15
|
-
print.spaced(["alterTypeKw", "name"]),
|
|
16
|
-
print.dynamicLine(),
|
|
17
|
-
print("actions"),
|
|
18
|
-
]);
|
|
19
|
-
},
|
|
20
|
-
drop_type_stmt: function (print) {
|
|
21
|
-
return (0, print_utils_1.group)(print.spaced(["dropTypeKw", "ifExistsKw", "types", "behaviorKw"]));
|
|
22
|
-
},
|
|
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"])),
|
|
23
12
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var print_utils_1 = require("../print_utils");
|
|
5
|
-
exports.unsupportedGrammarMap = {
|
|
6
|
-
unsupported_grammar_stmt: function (print) { return (0, print_utils_1.group)(print("text")); },
|
|
1
|
+
import { group } from "../print_utils";
|
|
2
|
+
export const unsupportedGrammarMap = {
|
|
3
|
+
unsupported_grammar_stmt: (print) => group(print("text")),
|
|
7
4
|
};
|
package/dist/syntax/update.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
update_stmt: function (print) { return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), print("clauses"))); },
|
|
7
|
-
update_clause: function (print) {
|
|
8
|
-
return print.spaced(["updateKw", "modifiers", "orAction", "tables"]);
|
|
9
|
-
},
|
|
10
|
-
set_clause: function (print, node) {
|
|
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) => {
|
|
11
6
|
if (node.assignments.items.length > 1) {
|
|
12
|
-
return [print("setKw"),
|
|
7
|
+
return [print("setKw"), indent([hardline, print("assignments")])];
|
|
13
8
|
}
|
|
14
9
|
else {
|
|
15
10
|
return print.spaced(["setKw", "assignments"]);
|
|
16
11
|
}
|
|
17
12
|
},
|
|
18
|
-
column_assignment:
|
|
19
|
-
return (0, print_utils_1.join)([" ", "=", " "], print(["column", "expr"]));
|
|
20
|
-
},
|
|
13
|
+
column_assignment: (print) => join([" ", "=", " "], print(["column", "expr"])),
|
|
21
14
|
};
|
package/dist/syntax/view.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var hasOnlyAsClause = node.clauses.length === 1;
|
|
8
|
-
var hasManyClauses = node.clauses.length > 1;
|
|
9
|
-
return (0, print_utils_1.group)([
|
|
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([
|
|
10
7
|
print.spaced([
|
|
11
8
|
"createKw",
|
|
12
9
|
"orReplaceKw",
|
|
@@ -17,43 +14,35 @@ exports.viewMap = {
|
|
|
17
14
|
"columns",
|
|
18
15
|
]),
|
|
19
16
|
hasOnlyAsClause ? [" ", print("clauses")] : [],
|
|
20
|
-
hasManyClauses ? [
|
|
17
|
+
hasManyClauses ? [hardline, join(hardline, print("clauses"))] : [],
|
|
21
18
|
]);
|
|
22
19
|
},
|
|
23
|
-
with_check_option_clause:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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",
|
|
30
33
|
"kind",
|
|
31
34
|
"viewKw",
|
|
32
35
|
"ifExistsKw",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
])
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"columns",
|
|
46
|
-
]),
|
|
47
|
-
print_utils_1.hardline,
|
|
48
|
-
print("actions"),
|
|
49
|
-
]);
|
|
50
|
-
},
|
|
51
|
-
refresh_materialized_view_stmt: function (print, node) {
|
|
52
|
-
return (0, print_utils_1.group)([
|
|
53
|
-
print.spaced(["refreshMaterializedViewKw", "concurrentlyKw", "name"]),
|
|
54
|
-
node.clauses.length > 0
|
|
55
|
-
? [print.dynamicLine(), (0, print_utils_1.join)(print_utils_1.line, print("clauses"))]
|
|
56
|
-
: [],
|
|
57
|
-
]);
|
|
58
|
-
},
|
|
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
|
+
]),
|
|
59
48
|
};
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var addFinalSemicolon = function (program, originalText) {
|
|
7
|
-
if (!(0, node_utils_1.isEmpty)((0, utils_1.last)(program.statements))) {
|
|
8
|
-
var end = originalText.length;
|
|
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;
|
|
9
6
|
program.statements.push({ type: "empty", range: [end, end] });
|
|
10
7
|
}
|
|
11
8
|
return program;
|
|
12
9
|
};
|
|
13
|
-
exports.addFinalSemicolon = addFinalSemicolon;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processAliasAs = void 0;
|
|
4
|
-
var sql_parser_cst_1 = require("sql-parser-cst");
|
|
1
|
+
import { cstVisitor } from "sql-parser-cst";
|
|
5
2
|
// Adds AS keyword to aliases if none exists
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
alias:
|
|
3
|
+
export const processAliasAs = (cst) => {
|
|
4
|
+
cstVisitor({
|
|
5
|
+
alias: (node) => {
|
|
9
6
|
node.asKw = node.asKw || { type: "keyword", name: "AS", text: "AS" };
|
|
10
7
|
},
|
|
11
8
|
})(cst);
|
|
12
9
|
return cst;
|
|
13
10
|
};
|
|
14
|
-
exports.processAliasAs = processAliasAs;
|