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,135 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.proceduralLanguageMap = void 0;
|
|
13
|
-
var print_utils_1 = require("../print_utils");
|
|
14
|
-
exports.proceduralLanguageMap = {
|
|
1
|
+
import { group, hardline, indent, join, line, stripTrailingHardline, } from "../print_utils";
|
|
2
|
+
export const proceduralLanguageMap = {
|
|
15
3
|
// BEGIN .. END
|
|
16
|
-
block_stmt:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
|
|
29
|
-
]);
|
|
30
|
-
},
|
|
31
|
-
error_category: function (print) { return print("errorKw"); },
|
|
4
|
+
block_stmt: (print, node) => group([
|
|
5
|
+
print.spaced(["beginKw", "atomicKw"]),
|
|
6
|
+
indent([hardline, stripTrailingHardline(print("program"))]),
|
|
7
|
+
node.exception ? [hardline, print("exception")] : [],
|
|
8
|
+
hardline,
|
|
9
|
+
print("endKw"),
|
|
10
|
+
]),
|
|
11
|
+
exception_clause: (print) => group([
|
|
12
|
+
print.spaced(["exceptionKw", "whenKw", "condition", "thenKw"]),
|
|
13
|
+
indent([hardline, stripTrailingHardline(print("program"))]),
|
|
14
|
+
]),
|
|
15
|
+
error_category: (print) => print("errorKw"),
|
|
32
16
|
// DECLARE
|
|
33
|
-
declare_stmt:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
declare_default: function (print) { return print.spaced(["defaultKw", "expr"]); },
|
|
17
|
+
declare_stmt: (print) => group(join(" ", [
|
|
18
|
+
print("declareKw"),
|
|
19
|
+
group(print("names")),
|
|
20
|
+
...print.spaced(["dataType", "default"]),
|
|
21
|
+
])),
|
|
22
|
+
declare_default: (print) => print.spaced(["defaultKw", "expr"]),
|
|
40
23
|
// SET
|
|
41
|
-
set_stmt:
|
|
24
|
+
set_stmt: (print) => group(print.spaced(["setKw", "assignments"])),
|
|
42
25
|
// IF
|
|
43
|
-
if_stmt:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if_clause: function (print) { return [
|
|
47
|
-
(0, print_utils_1.group)([
|
|
26
|
+
if_stmt: (print) => group(join(hardline, [...print("clauses"), print.spaced("endIfKw")])),
|
|
27
|
+
if_clause: (print) => [
|
|
28
|
+
group([
|
|
48
29
|
print("ifKw"),
|
|
49
|
-
|
|
50
|
-
|
|
30
|
+
indent([line, print("condition")]),
|
|
31
|
+
line,
|
|
51
32
|
print("thenKw"),
|
|
52
33
|
]),
|
|
53
|
-
|
|
54
|
-
]
|
|
55
|
-
elseif_clause:
|
|
56
|
-
|
|
34
|
+
indent([hardline, stripTrailingHardline(print("consequent"))]),
|
|
35
|
+
],
|
|
36
|
+
elseif_clause: (print) => [
|
|
37
|
+
group([
|
|
57
38
|
print("elseifKw"),
|
|
58
|
-
|
|
59
|
-
|
|
39
|
+
indent([line, print("condition")]),
|
|
40
|
+
line,
|
|
60
41
|
print("thenKw"),
|
|
61
42
|
]),
|
|
62
|
-
|
|
63
|
-
]
|
|
64
|
-
else_clause:
|
|
43
|
+
indent([hardline, stripTrailingHardline(print("consequent"))]),
|
|
44
|
+
],
|
|
45
|
+
else_clause: (print) => [
|
|
65
46
|
print("elseKw"),
|
|
66
|
-
|
|
67
|
-
]
|
|
47
|
+
indent([hardline, stripTrailingHardline(print("consequent"))]),
|
|
48
|
+
],
|
|
68
49
|
// CASE
|
|
69
|
-
case_stmt:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
]);
|
|
76
|
-
},
|
|
50
|
+
case_stmt: (print) => group([
|
|
51
|
+
print.spaced(["caseKw", "expr"]),
|
|
52
|
+
indent([hardline, join(hardline, print("clauses"))]),
|
|
53
|
+
hardline,
|
|
54
|
+
print.spaced("endCaseKw"),
|
|
55
|
+
]),
|
|
77
56
|
// LOOP
|
|
78
|
-
loop_stmt:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
]);
|
|
85
|
-
},
|
|
57
|
+
loop_stmt: (print) => group([
|
|
58
|
+
print("loopKw"),
|
|
59
|
+
indent([hardline, stripTrailingHardline(print("body"))]),
|
|
60
|
+
hardline,
|
|
61
|
+
print.spaced("endLoopKw"),
|
|
62
|
+
]),
|
|
86
63
|
// REPEAT
|
|
87
|
-
repeat_stmt:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
]);
|
|
94
|
-
},
|
|
64
|
+
repeat_stmt: (print) => group([
|
|
65
|
+
print("repeatKw"),
|
|
66
|
+
indent([hardline, stripTrailingHardline(print("body"))]),
|
|
67
|
+
hardline,
|
|
68
|
+
print.spaced(["untilKw", "condition", "endRepeatKw"]),
|
|
69
|
+
]),
|
|
95
70
|
// WHILE
|
|
96
|
-
while_stmt:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
]);
|
|
103
|
-
},
|
|
71
|
+
while_stmt: (print) => group([
|
|
72
|
+
print.spaced(["whileKw", "condition", "doKw"]),
|
|
73
|
+
indent([hardline, stripTrailingHardline(print("body"))]),
|
|
74
|
+
hardline,
|
|
75
|
+
print.spaced("endWhileKw"),
|
|
76
|
+
]),
|
|
104
77
|
// FOR .. IN
|
|
105
|
-
for_stmt:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
]);
|
|
112
|
-
},
|
|
78
|
+
for_stmt: (print) => group([
|
|
79
|
+
print.spaced(["forKw", "left", "inKw", "right", "doKw"]),
|
|
80
|
+
indent([hardline, stripTrailingHardline(print("body"))]),
|
|
81
|
+
hardline,
|
|
82
|
+
print.spaced("endForKw"),
|
|
83
|
+
]),
|
|
113
84
|
// BREAK/CONTINUE
|
|
114
|
-
break_stmt:
|
|
115
|
-
continue_stmt:
|
|
116
|
-
labeled_stmt:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
]);
|
|
123
|
-
},
|
|
85
|
+
break_stmt: (print) => group(print.spaced(["breakKw", "label"])),
|
|
86
|
+
continue_stmt: (print) => group(print.spaced(["continueKw", "label"])),
|
|
87
|
+
labeled_stmt: (print, node) => group([
|
|
88
|
+
print("beginLabel"),
|
|
89
|
+
": ",
|
|
90
|
+
print("statement"),
|
|
91
|
+
node.endLabel ? [" ", print(["endLabel"])] : [],
|
|
92
|
+
]),
|
|
124
93
|
// CALL
|
|
125
|
-
call_stmt:
|
|
94
|
+
call_stmt: (print) => group(print.spaced(["callKw", "func"])),
|
|
126
95
|
// RETURN
|
|
127
|
-
return_stmt:
|
|
96
|
+
return_stmt: (print) => group(print.spaced(["returnKw", "expr"])),
|
|
128
97
|
// RAISE
|
|
129
|
-
raise_stmt:
|
|
130
|
-
raise_message:
|
|
98
|
+
raise_stmt: (print) => group(print.spaced(["raiseKw", "message"])),
|
|
99
|
+
raise_message: (print) => [
|
|
131
100
|
print.spaced("usingMessageKw"),
|
|
132
101
|
" = ",
|
|
133
102
|
print("string"),
|
|
134
|
-
]
|
|
103
|
+
],
|
|
135
104
|
};
|
package/dist/syntax/procedure.js
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
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
|
-
]);
|
|
30
|
-
},
|
|
1
|
+
import { group, hardline, join } from "../print_utils";
|
|
2
|
+
import { hasOnlyAsClause } from "./function";
|
|
3
|
+
export const procedureMap = {
|
|
4
|
+
create_procedure_stmt: (print, node) => group([
|
|
5
|
+
print.spaced([
|
|
6
|
+
"createKw",
|
|
7
|
+
"orReplaceKw",
|
|
8
|
+
"procedureKw",
|
|
9
|
+
"ifNotExistsKw",
|
|
10
|
+
"name",
|
|
11
|
+
]),
|
|
12
|
+
print("params"),
|
|
13
|
+
hasOnlyAsClause(node)
|
|
14
|
+
? [" ", group(print("clauses"))]
|
|
15
|
+
: [
|
|
16
|
+
hardline,
|
|
17
|
+
join(hardline, print("clauses").map((clause) => group(clause))),
|
|
18
|
+
],
|
|
19
|
+
]),
|
|
20
|
+
drop_procedure_stmt: (print) => group([
|
|
21
|
+
print.spaced([
|
|
22
|
+
"dropKw",
|
|
23
|
+
"procedureKw",
|
|
24
|
+
"ifExistsKw",
|
|
25
|
+
"signatures",
|
|
26
|
+
"behaviorKw",
|
|
27
|
+
]),
|
|
28
|
+
]),
|
|
31
29
|
// almost exact copy of alter_function_stmt
|
|
32
|
-
alter_procedure_stmt:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
]);
|
|
41
|
-
},
|
|
30
|
+
alter_procedure_stmt: (print, node) => group([
|
|
31
|
+
print.spaced(["alterKw", "procedureKw"]),
|
|
32
|
+
" ",
|
|
33
|
+
print(["signature"]),
|
|
34
|
+
print.dynamicLine(),
|
|
35
|
+
join(print.dynamicLine(), print("actions")),
|
|
36
|
+
node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : [],
|
|
37
|
+
]),
|
|
42
38
|
};
|
package/dist/syntax/program.js
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
program: function (print, node, path, options) {
|
|
7
|
-
return print("statements").map(function (doc, i) {
|
|
8
|
-
return i === node.statements.length - 1
|
|
9
|
-
? printFinalStatement(doc, i, node.statements, options)
|
|
10
|
-
: printStatement(doc, i, node.statements, options);
|
|
11
|
-
});
|
|
12
|
-
},
|
|
1
|
+
import { hardline, hasEmptyLineBetweenNodes } from "../print_utils";
|
|
2
|
+
export const programMap = {
|
|
3
|
+
program: (print, node, path, options) => print("statements").map((doc, i) => i === node.statements.length - 1
|
|
4
|
+
? printFinalStatement(doc, i, node.statements, options)
|
|
5
|
+
: printStatement(doc, i, node.statements, options)),
|
|
13
6
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const printStatement = (doc, i, statements, options) => {
|
|
8
|
+
const prevNode = statements[i - 1];
|
|
9
|
+
const node = statements[i];
|
|
17
10
|
if (i === 0) {
|
|
18
11
|
return doc;
|
|
19
12
|
}
|
|
20
13
|
else if (node.type !== "empty") {
|
|
21
|
-
if (
|
|
22
|
-
return [";",
|
|
14
|
+
if (hasEmptyLineBetweenNodes(prevNode, node, options)) {
|
|
15
|
+
return [";", hardline, hardline, doc];
|
|
23
16
|
}
|
|
24
17
|
else {
|
|
25
|
-
return [";",
|
|
18
|
+
return [";", hardline, doc];
|
|
26
19
|
}
|
|
27
20
|
}
|
|
28
21
|
else {
|
|
29
|
-
return [";",
|
|
22
|
+
return [";", hardline, doc];
|
|
30
23
|
}
|
|
31
24
|
};
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
const printFinalStatement = (doc, i, statements, options) => {
|
|
26
|
+
const stmtDoc = printStatement(doc, i, statements, options);
|
|
34
27
|
if (statements[i].type === "empty") {
|
|
35
28
|
// When the final statement is an empty statement,
|
|
36
29
|
// this means we have inserted a semicolon and newline before it.
|
|
@@ -41,6 +34,6 @@ var printFinalStatement = function (doc, i, statements, options) {
|
|
|
41
34
|
// If the last statement is not empty,
|
|
42
35
|
// this means sqlFinalSemicolon option is false,
|
|
43
36
|
// so we need to add an empty line after it.
|
|
44
|
-
return [stmtDoc,
|
|
37
|
+
return [stmtDoc, hardline];
|
|
45
38
|
}
|
|
46
39
|
};
|
|
@@ -1,48 +1,27 @@
|
|
|
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
|
-
return (0, print_utils_1.group)(print.spaced(["tablesInSchemaKw", "schema"]));
|
|
28
|
-
},
|
|
29
|
-
alter_publication_stmt: function (print) {
|
|
30
|
-
return (0, print_utils_1.group)([
|
|
31
|
-
print.spaced(["alterPublicationKw", "name"]),
|
|
32
|
-
print.dynamicLine(),
|
|
33
|
-
print("action"),
|
|
34
|
-
]);
|
|
35
|
-
},
|
|
36
|
-
alter_action_add_publication_objects: function (print) {
|
|
37
|
-
return (0, print_utils_1.group)([print("addKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
|
|
38
|
-
},
|
|
39
|
-
alter_action_set_publication_objects: function (print) {
|
|
40
|
-
return (0, print_utils_1.group)([print("setKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
|
|
41
|
-
},
|
|
42
|
-
alter_action_drop_publication_objects: function (print) {
|
|
43
|
-
return (0, print_utils_1.group)([print("dropKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
|
|
44
|
-
},
|
|
45
|
-
drop_publication_stmt: function (print) {
|
|
46
|
-
return (0, print_utils_1.group)(print.spaced(["dropPublicationKw", "ifExistsKw", "names", "behaviorKw"]));
|
|
47
|
-
},
|
|
1
|
+
import { group, indent, line } from "../print_utils";
|
|
2
|
+
export const publicationMap = {
|
|
3
|
+
create_publication_stmt: (print, node) => group([
|
|
4
|
+
print.spaced(["createPublicationKw", "name"]),
|
|
5
|
+
print("clauses").map((printedClause, i) => {
|
|
6
|
+
if (node.clauses[i].type === "for_publication_objects_clause") {
|
|
7
|
+
return [" ", printedClause];
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return [line, printedClause];
|
|
11
|
+
}
|
|
12
|
+
}),
|
|
13
|
+
]),
|
|
14
|
+
for_publication_objects_clause: (print) => group([print("forKw"), indent([line, print("publicationObjects")])]),
|
|
15
|
+
all_publication_object: (print) => group(print.spaced(["allKw", "typesKw"])),
|
|
16
|
+
publication_object_table: (print) => group(print.spaced(["tableKw", "table", "columns", "where"])),
|
|
17
|
+
publication_object_tables_in_schema: (print) => group(print.spaced(["tablesInSchemaKw", "schema"])),
|
|
18
|
+
alter_publication_stmt: (print) => group([
|
|
19
|
+
print.spaced(["alterPublicationKw", "name"]),
|
|
20
|
+
print.dynamicLine(),
|
|
21
|
+
print("action"),
|
|
22
|
+
]),
|
|
23
|
+
alter_action_add_publication_objects: (print) => group([print("addKw"), indent([line, print("publicationObjects")])]),
|
|
24
|
+
alter_action_set_publication_objects: (print) => group([print("setKw"), indent([line, print("publicationObjects")])]),
|
|
25
|
+
alter_action_drop_publication_objects: (print) => group([print("dropKw"), indent([line, print("publicationObjects")])]),
|
|
26
|
+
drop_publication_stmt: (print) => group(print.spaced(["dropPublicationKw", "ifExistsKw", "names", "behaviorKw"])),
|
|
48
27
|
};
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
print.spaced(["renameKw", "tableKw"]),
|
|
9
|
-
(0, print_utils_1.indent)([print_utils_1.line, print("actions")]),
|
|
10
|
-
]);
|
|
11
|
-
},
|
|
12
|
-
rename_action: function (print) { return print.spaced(["from", "toKw", "to"]); },
|
|
1
|
+
import { group, indent, line } from "../print_utils";
|
|
2
|
+
export const renameTableMap = {
|
|
3
|
+
rename_table_stmt: (print) => group([
|
|
4
|
+
print.spaced(["renameKw", "tableKw"]),
|
|
5
|
+
indent([line, print("actions")]),
|
|
6
|
+
]),
|
|
7
|
+
rename_action: (print) => print.spaced(["from", "toKw", "to"]),
|
|
13
8
|
};
|
package/dist/syntax/role.js
CHANGED
|
@@ -1,56 +1,31 @@
|
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
: [print.dynamicLine(), print("action")],
|
|
32
|
-
]);
|
|
33
|
-
},
|
|
34
|
-
drop_role_stmt: function (print) {
|
|
35
|
-
return (0, print_utils_1.group)(print.spaced(["dropRoleKw", "ifExistsKw", "names"]));
|
|
36
|
-
},
|
|
37
|
-
set_role_stmt: function (print) {
|
|
38
|
-
return (0, print_utils_1.group)(print.spaced(["setKw", "scopeKw", "roleKw", "name"]));
|
|
39
|
-
},
|
|
40
|
-
reset_role_stmt: function (print) { return (0, print_utils_1.group)(print.spaced("resetRoleKw")); },
|
|
41
|
-
role_option_keyword: function (print) { return print("kw"); },
|
|
42
|
-
role_option_connection_limit: function (print) {
|
|
43
|
-
return (0, print_utils_1.group)(print.spaced(["connectionLimitKw", "limit"]));
|
|
44
|
-
},
|
|
45
|
-
role_option_password: function (print) {
|
|
46
|
-
return (0, print_utils_1.group)(print.spaced(["encryptedKw", "passwordKw", "password"]));
|
|
47
|
-
},
|
|
48
|
-
role_option_valid_until: function (print) {
|
|
49
|
-
return (0, print_utils_1.group)(print.spaced(["validUntilKw", "timestamp"]));
|
|
50
|
-
},
|
|
51
|
-
role_option_in_role: function (print) { return (0, print_utils_1.group)(print.spaced(["inRoleKw", "names"])); },
|
|
52
|
-
role_option_role: function (print) { return (0, print_utils_1.group)(print.spaced(["roleKw", "names"])); },
|
|
53
|
-
role_option_admin: function (print) { return (0, print_utils_1.group)(print.spaced(["adminKw", "names"])); },
|
|
54
|
-
role_option_sysid: function (print) { return (0, print_utils_1.group)(print.spaced(["sysIdKw", "sysId"])); },
|
|
55
|
-
in_database_clause: function (print) { return (0, print_utils_1.group)(print.spaced(["inDatabaseKw", "name"])); },
|
|
1
|
+
import { group, indent, join, line } from "../print_utils";
|
|
2
|
+
export const roleMap = {
|
|
3
|
+
create_role_stmt: (print, node) => group([
|
|
4
|
+
print.spaced(["createRoleKw", "name", "withKw"]),
|
|
5
|
+
...(node.options?.length
|
|
6
|
+
? [indent([line, join(print.dynamicLine(), print("options"))])]
|
|
7
|
+
: []),
|
|
8
|
+
]),
|
|
9
|
+
alter_role_stmt: (print, node) => group([
|
|
10
|
+
join(print.dynamicLine(), [
|
|
11
|
+
group([print.spaced("alterRoleKw"), indent([line, print("name")])]),
|
|
12
|
+
...(node.database ? print(["database"]) : []),
|
|
13
|
+
]),
|
|
14
|
+
node.action.type === "alter_action_with_role_options" &&
|
|
15
|
+
!node.action.withKw
|
|
16
|
+
? indent([print.dynamicLine(), print("action")])
|
|
17
|
+
: [print.dynamicLine(), print("action")],
|
|
18
|
+
]),
|
|
19
|
+
drop_role_stmt: (print) => group(print.spaced(["dropRoleKw", "ifExistsKw", "names"])),
|
|
20
|
+
set_role_stmt: (print) => group(print.spaced(["setKw", "scopeKw", "roleKw", "name"])),
|
|
21
|
+
reset_role_stmt: (print) => group(print.spaced("resetRoleKw")),
|
|
22
|
+
role_option_keyword: (print) => print("kw"),
|
|
23
|
+
role_option_connection_limit: (print) => group(print.spaced(["connectionLimitKw", "limit"])),
|
|
24
|
+
role_option_password: (print) => group(print.spaced(["encryptedKw", "passwordKw", "password"])),
|
|
25
|
+
role_option_valid_until: (print) => group(print.spaced(["validUntilKw", "timestamp"])),
|
|
26
|
+
role_option_in_role: (print) => group(print.spaced(["inRoleKw", "names"])),
|
|
27
|
+
role_option_role: (print) => group(print.spaced(["roleKw", "names"])),
|
|
28
|
+
role_option_admin: (print) => group(print.spaced(["adminKw", "names"])),
|
|
29
|
+
role_option_sysid: (print) => group(print.spaced(["sysIdKw", "sysId"])),
|
|
30
|
+
in_database_clause: (print) => group(print.spaced(["inDatabaseKw", "name"])),
|
|
56
31
|
};
|
package/dist/syntax/schema.js
CHANGED
|
@@ -1,36 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
print.spaced(["createSchemaKw", "ifNotExistsKw", "name"])
|
|
19
|
-
], print("clauses"), true))),
|
|
20
|
-
node.statements.length > 0
|
|
21
|
-
? (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("statements"))])
|
|
22
|
-
: [],
|
|
23
|
-
]);
|
|
24
|
-
},
|
|
25
|
-
create_schema_authorization_clause: function (print) {
|
|
26
|
-
return print.spaced(["authorizationKw", "role"]);
|
|
27
|
-
},
|
|
28
|
-
drop_schema_stmt: function (print) {
|
|
29
|
-
return (0, print_utils_1.group)(print.spaced(["dropSchemaKw", "ifExistsKw", "schemas", "behaviorKw"]));
|
|
30
|
-
},
|
|
31
|
-
alter_schema_stmt: function (print) {
|
|
32
|
-
return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
|
|
33
|
-
print.spaced(["alterSchemaKw", "ifExistsKw", "name"])
|
|
34
|
-
], print("actions"), true)));
|
|
35
|
-
},
|
|
1
|
+
import { group, hardline, indent, join } from "../print_utils";
|
|
2
|
+
export const schemaMap = {
|
|
3
|
+
create_schema_stmt: (print, node) => group([
|
|
4
|
+
group(join(print.dynamicLine(), [
|
|
5
|
+
print.spaced(["createSchemaKw", "ifNotExistsKw", "name"]),
|
|
6
|
+
...print("clauses"),
|
|
7
|
+
])),
|
|
8
|
+
node.statements.length > 0
|
|
9
|
+
? indent([hardline, join(hardline, print("statements"))])
|
|
10
|
+
: [],
|
|
11
|
+
]),
|
|
12
|
+
create_schema_authorization_clause: (print) => print.spaced(["authorizationKw", "role"]),
|
|
13
|
+
drop_schema_stmt: (print) => group(print.spaced(["dropSchemaKw", "ifExistsKw", "schemas", "behaviorKw"])),
|
|
14
|
+
alter_schema_stmt: (print) => group(join(print.dynamicLine(), [
|
|
15
|
+
print.spaced(["alterSchemaKw", "ifExistsKw", "name"]),
|
|
16
|
+
...print("actions"),
|
|
17
|
+
])),
|
|
36
18
|
};
|