prettier-plugin-sql-cst 0.19.1 → 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 +4 -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
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { group, hardline, join } from "../../print_utils";
|
|
2
|
-
export const bigqueryMap = {
|
|
3
|
-
bigquery_options: (print) => print.spaced(["optionsKw", "options"]),
|
|
4
|
-
bigquery_option_default_collate: (print) => print.spaced(["defaultCollateKw", "collation"]),
|
|
5
|
-
// ROW ACCESS POLICY
|
|
6
|
-
create_row_access_policy_stmt: (print) => group(join(hardline, [
|
|
7
|
-
print.spaced([
|
|
8
|
-
"createKw",
|
|
9
|
-
"orReplaceKw",
|
|
10
|
-
"rowAccessPolicyKw",
|
|
11
|
-
"ifNotExistsKw",
|
|
12
|
-
"name",
|
|
13
|
-
"onKw",
|
|
14
|
-
"table",
|
|
15
|
-
]),
|
|
16
|
-
...print("clauses"),
|
|
17
|
-
])),
|
|
18
|
-
row_access_policy_grant_clause: (print) => print.spaced(["grantToKw", "grantees"]),
|
|
19
|
-
row_access_policy_filter_clause: (print) => print.spaced(["filterUsingKw", "expr"]),
|
|
20
|
-
drop_row_access_policy_stmt: (print) => group(print.spaced([
|
|
21
|
-
"dropKw",
|
|
22
|
-
"allKw",
|
|
23
|
-
"rowAccessPolicyKw",
|
|
24
|
-
"ifExistsKw",
|
|
25
|
-
"name",
|
|
26
|
-
"onKw",
|
|
27
|
-
"table",
|
|
28
|
-
])),
|
|
29
|
-
// CAPACITY
|
|
30
|
-
create_capacity_stmt: (print) => group([
|
|
31
|
-
print.spaced(["createKw", "capacityKw", "name"]),
|
|
32
|
-
hardline,
|
|
33
|
-
print("options"),
|
|
34
|
-
]),
|
|
35
|
-
drop_capacity_stmt: (print) => group(print.spaced(["dropKw", "capacityKw", "ifExistsKw", "name"])),
|
|
36
|
-
// RESERVATION
|
|
37
|
-
create_reservation_stmt: (print) => group([
|
|
38
|
-
print.spaced(["createKw", "reservationKw", "name"]),
|
|
39
|
-
hardline,
|
|
40
|
-
print("options"),
|
|
41
|
-
]),
|
|
42
|
-
drop_reservation_stmt: (print) => group(print.spaced(["dropKw", "reservationKw", "ifExistsKw", "name"])),
|
|
43
|
-
// ASSIGNMENT
|
|
44
|
-
create_assignment_stmt: (print) => group([
|
|
45
|
-
print.spaced(["createKw", "assignmentKw", "name"]),
|
|
46
|
-
hardline,
|
|
47
|
-
print("options"),
|
|
48
|
-
]),
|
|
49
|
-
drop_assignment_stmt: (print) => group(print.spaced(["dropKw", "assignmentKw", "ifExistsKw", "name"])),
|
|
50
|
-
// ALTER ORGANIZATION
|
|
51
|
-
alter_organization_stmt: (print) => group(join(hardline, [print.spaced("alterOrganizationKw"), print("actions")])),
|
|
52
|
-
// ALTER PROJECT
|
|
53
|
-
alter_project_stmt: (print) => group(join(hardline, [
|
|
54
|
-
print.spaced(["alterProjectKw", "name"]),
|
|
55
|
-
print("actions"),
|
|
56
|
-
])),
|
|
57
|
-
alter_bi_capacity_stmt: (print) => group(join(hardline, [
|
|
58
|
-
print.spaced(["alterBiCapacityKw", "name"]),
|
|
59
|
-
print("actions"),
|
|
60
|
-
])),
|
|
61
|
-
alter_capacity_stmt: (print) => group(join(hardline, [
|
|
62
|
-
print.spaced(["alterCapacityKw", "name"]),
|
|
63
|
-
print("actions"),
|
|
64
|
-
])),
|
|
65
|
-
alter_reservation_stmt: (print) => group(join(hardline, [
|
|
66
|
-
print.spaced(["alterReservationKw", "name"]),
|
|
67
|
-
print("actions"),
|
|
68
|
-
])),
|
|
69
|
-
// ASSERT
|
|
70
|
-
assert_stmt: (print) => group(print.spaced(["assertKw", "expr", "as"])),
|
|
71
|
-
// EXPORT
|
|
72
|
-
export_data_stmt: (print) => group(join(hardline, [
|
|
73
|
-
print.spaced("exportDataKw"),
|
|
74
|
-
...print.spaced(["withConnection"]),
|
|
75
|
-
print.spaced("options"),
|
|
76
|
-
print.spaced("as"),
|
|
77
|
-
])),
|
|
78
|
-
// LOAD
|
|
79
|
-
load_data_stmt: (print) => group(join(hardline, [
|
|
80
|
-
print.spaced(["loadDataKw", "intoKw", "table", "columns"]),
|
|
81
|
-
...print("clauses"),
|
|
82
|
-
])),
|
|
83
|
-
from_files_options: (print) => print.spaced(["fromFilesKw", "options"]),
|
|
84
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { group } from "../../print_utils";
|
|
2
|
-
export const postgresqlMap = {
|
|
3
|
-
postgresql_operator_expr: (print) => print(["operatorKw", "expr"]),
|
|
4
|
-
postgresql_operator: (print) => print("operator"),
|
|
5
|
-
postgresql_operator_class: (print) => print.spaced(["name", "options"]),
|
|
6
|
-
postgresql_with_options: (print) => group(print.spaced(["withKw", "options"])),
|
|
7
|
-
postgresql_options: (print) => print.spaced(["optionsKw", "options"]),
|
|
8
|
-
postgresql_option_element: (print) => print.spaced(["name", "value"]),
|
|
9
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { group, join } from "../../print_utils";
|
|
2
|
-
export const sqliteMap = {
|
|
3
|
-
attach_database_stmt: (print) => group(print.spaced(["attachKw", "databaseKw", "file", "asKw", "schema"])),
|
|
4
|
-
detach_database_stmt: (print) => group(print.spaced(["detachKw", "databaseKw", "schema"])),
|
|
5
|
-
vacuum_stmt: (print) => group(print.spaced(["vacuumKw", "schema", "intoKw", "file"])),
|
|
6
|
-
pragma_stmt: (print) => group(print.spaced(["pragmaKw", "pragma"])),
|
|
7
|
-
pragma_assignment: (print) => join(" = ", print(["name", "value"])),
|
|
8
|
-
pragma_func_call: (print) => print(["name", "args"]),
|
|
9
|
-
};
|
package/dist/syntax/do.d.ts
DELETED
package/dist/syntax/do.js
DELETED
package/dist/syntax/domain.d.ts
DELETED
package/dist/syntax/domain.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { group, line, indent, join } from "../print_utils";
|
|
2
|
-
export const domainMap = {
|
|
3
|
-
create_domain_stmt: (print, node) => group([
|
|
4
|
-
print.spaced(["createDomainKw", "name", "asKw", "dataType"]),
|
|
5
|
-
node.constraints.length > 0
|
|
6
|
-
? indent([print.dynamicLine(), join(line, print("constraints"))])
|
|
7
|
-
: [],
|
|
8
|
-
]),
|
|
9
|
-
alter_domain_stmt: (print) => group(print.spaced(["alterDomainKw", "name", "action"])),
|
|
10
|
-
drop_domain_stmt: (print) => group(print.spaced(["dropDomainKw", "ifExistsKw", "domains", "behaviorKw"])),
|
|
11
|
-
};
|
package/dist/syntax/explain.d.ts
DELETED
package/dist/syntax/explain.js
DELETED
package/dist/syntax/expr.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AllExprNodes, Keyword } from "sql-parser-cst";
|
|
2
|
-
import { CstToDocMap } from "../CstToDocMap";
|
|
3
|
-
import { AllPrettierOptions } from "../options";
|
|
4
|
-
export declare const exprMap: CstToDocMap<AllExprNodes>;
|
|
5
|
-
export declare const printLiteral: <T>(node: Keyword, options: AllPrettierOptions<T>) => string;
|
package/dist/syntax/expr.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { join, line, softline, hardline, indent, group, stripTrailingHardline, } from "../print_utils";
|
|
2
|
-
import { isCreateTableStmt, isKeyword, isValuesClause, isEmpty, isArraySubscript, isParenExpr, isFuncArgs, isListExpr, isProgram, isSelectStmt, isCompoundSelectStmt, isBigqueryQuotedMemberExpr, isFuncCall, isMemberExpr, isCreateFunctionStmt, isAlterFunctionStmt, isAlterActionRename, isCreateProcedureStmt, isAlterProcedureStmt, isCreateTriggerStmt, isExecuteClause, isFunctionSignature, } from "../node_utils";
|
|
3
|
-
import { isString, last } from "../utils";
|
|
4
|
-
export const exprMap = {
|
|
5
|
-
list_expr: (print, node, path) => {
|
|
6
|
-
const parent = path.getParentNode();
|
|
7
|
-
const children = print("items").map((it) => group(it));
|
|
8
|
-
const lineType = isValuesClause(parent) ? hardline : line;
|
|
9
|
-
// When last item is type:empty, we're dealing with a trailing comma.
|
|
10
|
-
// Don't add a space (or newline) after it.
|
|
11
|
-
// We still want to print it though, as it might have comments attached.
|
|
12
|
-
if (isEmpty(last(node.items))) {
|
|
13
|
-
return [
|
|
14
|
-
join([",", lineType], children.slice(0, -1)),
|
|
15
|
-
",",
|
|
16
|
-
last(children),
|
|
17
|
-
];
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return join([",", lineType], children);
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
paren_expr: (print, node, path) => {
|
|
24
|
-
// discard unnecessary nested ((parentheses))
|
|
25
|
-
if (isParenExpr(node.expr)) {
|
|
26
|
-
return print("expr");
|
|
27
|
-
}
|
|
28
|
-
// Discard unnecessary parenthesis around function arguments
|
|
29
|
-
if (isListExpr(path.getParentNode(0)) &&
|
|
30
|
-
isFuncArgs(path.getParentNode(1)) &&
|
|
31
|
-
!isSelectStmt(node.expr) &&
|
|
32
|
-
!isCompoundSelectStmt(node.expr)) {
|
|
33
|
-
return print("expr");
|
|
34
|
-
}
|
|
35
|
-
const parent = path.getParentNode();
|
|
36
|
-
const lineStyle = isCreateTableStmt(parent) && print.dynamicLine() === hardline
|
|
37
|
-
? hardline
|
|
38
|
-
: softline;
|
|
39
|
-
return group(["(", indent([lineStyle, print("expr")]), lineStyle, ")"]);
|
|
40
|
-
},
|
|
41
|
-
binary_expr: (print, node) => {
|
|
42
|
-
if (isKeyword(node.operator) && isBooleanOp(node.operator)) {
|
|
43
|
-
return join(line, [print("left"), print.spaced(["operator", "right"])]);
|
|
44
|
-
}
|
|
45
|
-
if (node.operator === "") {
|
|
46
|
-
// String concatenation with whitespace (MySQL / MariaDB)
|
|
47
|
-
return print.spaced(["left", "right"]);
|
|
48
|
-
}
|
|
49
|
-
return print.spaced(["left", "operator", "right"]);
|
|
50
|
-
},
|
|
51
|
-
prefix_op_expr: (print, node) => (isString(node.operator) ? print : print.spaced)(["operator", "expr"]),
|
|
52
|
-
postfix_op_expr: (print) => print.spaced(["expr", "operator"]),
|
|
53
|
-
between_expr: (print) => print.spaced(["left", "betweenKw", "begin", "andKw", "end"]),
|
|
54
|
-
case_expr: (print) => [
|
|
55
|
-
print.spaced(["caseKw", "expr"]),
|
|
56
|
-
indent([hardline, join(hardline, print("clauses"))]),
|
|
57
|
-
hardline,
|
|
58
|
-
print("endKw"),
|
|
59
|
-
],
|
|
60
|
-
case_when: (print, node) => {
|
|
61
|
-
if (isProgram(node.result)) {
|
|
62
|
-
return [
|
|
63
|
-
print.spaced(["whenKw", "condition", "thenKw"]),
|
|
64
|
-
indent([hardline, stripTrailingHardline(print("result"))]),
|
|
65
|
-
];
|
|
66
|
-
}
|
|
67
|
-
return print.spaced(["whenKw", "condition", "thenKw", "result"]);
|
|
68
|
-
},
|
|
69
|
-
case_else: (print, node) => {
|
|
70
|
-
if (isProgram(node.result)) {
|
|
71
|
-
return [
|
|
72
|
-
print("elseKw"),
|
|
73
|
-
indent([hardline, stripTrailingHardline(print("result"))]),
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
return print.spaced(["elseKw", "result"]);
|
|
77
|
-
},
|
|
78
|
-
member_expr: (print, node) => isArraySubscript(node.property)
|
|
79
|
-
? print(["object", "property"])
|
|
80
|
-
: [print("object"), ".", print("property")],
|
|
81
|
-
bigquery_quoted_member_expr: (print) => ["`", print("expr"), "`"],
|
|
82
|
-
array_subscript: (print) => group(["[", indent([softline, print("expr")]), softline, "]"]),
|
|
83
|
-
array_subscript_specifier: (print) => print(["specifierKw", "args"]),
|
|
84
|
-
array_slice_specifier: (print) => [print("from"), ":", print("to")],
|
|
85
|
-
func_call: (print) => {
|
|
86
|
-
const fnCall = print(["name", "args"]);
|
|
87
|
-
const extras = print(["filter", "over"]);
|
|
88
|
-
if (extras.length > 1) {
|
|
89
|
-
return group([fnCall, indent([line, join(line, extras)])]);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
return group(join(" ", [fnCall, ...extras]));
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
func_args: (print, node) => join(line, [
|
|
96
|
-
...print(["distinctKw", "args"]),
|
|
97
|
-
...(node.nullHandlingKw ? print.spaced("nullHandlingKw") : []),
|
|
98
|
-
...print(["orderBy", "limit", "having"]),
|
|
99
|
-
]),
|
|
100
|
-
filter_arg: (print) => print.spaced(["filterKw", "where"]),
|
|
101
|
-
over_arg: (print) => print.spaced(["overKw", "window"]),
|
|
102
|
-
having_arg: (print) => print.spaced(["havingKw", "minMaxKw", "expr"]),
|
|
103
|
-
named_arg: (print) => group([
|
|
104
|
-
print("name"),
|
|
105
|
-
" ",
|
|
106
|
-
print("operator"),
|
|
107
|
-
indent([line, print("value")]),
|
|
108
|
-
]),
|
|
109
|
-
cast_expr: (print) => print(["castKw", "args"]),
|
|
110
|
-
cast_arg: (print) => print.spaced(["expr", "asKw", "dataType", "format"]),
|
|
111
|
-
cast_format: (print) => print.spaced(["formatKw", "string", "timezone"]),
|
|
112
|
-
cast_format_timezone: (print) => print.spaced(["atTimeZoneKw", "timezone"]),
|
|
113
|
-
cast_operator_expr: (print) => [
|
|
114
|
-
print("left"),
|
|
115
|
-
print("operator"),
|
|
116
|
-
print("right"),
|
|
117
|
-
],
|
|
118
|
-
string_with_charset: (print) => ["_", print(["charset", "string"])],
|
|
119
|
-
raise_expr: (print) => print(["raiseKw", "args"]),
|
|
120
|
-
raise_expr_type: (print) => print("typeKw"),
|
|
121
|
-
extract_expr: (print) => print(["extractKw", "args"]),
|
|
122
|
-
extract_from: (print) => print.spaced(["unit", "fromKw", "expr"]),
|
|
123
|
-
week_expr: (print) => print(["weekKw", "args"]),
|
|
124
|
-
interval_literal: (print) => print.spaced(["intervalKw", "precision", "value", "unit"]),
|
|
125
|
-
array_literal_expr: (print) => print(["arrayKw", "expr"]),
|
|
126
|
-
array_expr: (print) => group(["[", indent([softline, print("expr")]), softline, "]"]),
|
|
127
|
-
struct_expr: (print) => group(["(", indent([softline, print("expr")]), softline, ")"]),
|
|
128
|
-
typed_expr: (print) => print(["dataType", "expr"]),
|
|
129
|
-
row_constructor: (print) => print(["rowKw", "row"]),
|
|
130
|
-
array_constructor: (print) => print(["arrayKw", "expr"]),
|
|
131
|
-
quantifier_expr: (print) => print.spaced(["quantifierKw", "expr"]),
|
|
132
|
-
full_text_match_expr: (print) => print.spaced(["matchKw", "columns", "againstKw", "args"]),
|
|
133
|
-
full_text_match_args: (print) => print.spaced(["expr", "modifier"]),
|
|
134
|
-
/** cst-ignore: value */
|
|
135
|
-
number_literal: (print) => print("text"),
|
|
136
|
-
/** cst-ignore: value */
|
|
137
|
-
boolean_literal: (print, node, path, options) => printLiteral(node.valueKw, options),
|
|
138
|
-
/** cst-ignore: value */
|
|
139
|
-
string_literal: (print) => print("text"),
|
|
140
|
-
/** cst-ignore: value */
|
|
141
|
-
blob_literal: (print) => print("text"),
|
|
142
|
-
/** cst-ignore: value */
|
|
143
|
-
null_literal: (print, node, path, options) => printLiteral(node.nullKw, options),
|
|
144
|
-
numeric_literal: (print) => print.spaced(["numericKw", "string"]),
|
|
145
|
-
bignumeric_literal: (print) => print.spaced(["bignumericKw", "string"]),
|
|
146
|
-
date_literal: (print) => print.spaced(["dateKw", "string"]),
|
|
147
|
-
time_literal: (print) => print.spaced(["timeKw", "string"]),
|
|
148
|
-
datetime_literal: (print) => print.spaced(["datetimeKw", "string"]),
|
|
149
|
-
timestamp_literal: (print) => print.spaced(["timestampKw", "string"]),
|
|
150
|
-
json_literal: (print) => print.spaced(["jsonKw", "string"]),
|
|
151
|
-
jsonb_literal: (print) => print.spaced(["jsonbKw", "string"]),
|
|
152
|
-
/** cst-ignore: name */
|
|
153
|
-
identifier: (print, node, path, options) => {
|
|
154
|
-
if (isQuotedIdentifier(node) || isInsideBigqueryQuotedMemberExpr(path)) {
|
|
155
|
-
return print("text");
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
if (isFunctionName(node, path)) {
|
|
159
|
-
return printFunctionName(node, options);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
return printIdentifier(node, options);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
/** cst-ignore: name */
|
|
167
|
-
variable: (print, node, path, options) => isQuotedVariable(node) ? print("text") : printIdentifier(node, options),
|
|
168
|
-
parameter: (print, node, path, options) => isQuotedParameter(node) ? print("text") : printIdentifier(node, options),
|
|
169
|
-
};
|
|
170
|
-
export const printLiteral = (node, options) => {
|
|
171
|
-
switch (options.sqlLiteralCase) {
|
|
172
|
-
case "preserve":
|
|
173
|
-
return node.text;
|
|
174
|
-
case "upper":
|
|
175
|
-
return node.text.toUpperCase();
|
|
176
|
-
case "lower":
|
|
177
|
-
return node.text.toLowerCase();
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
const printIdentifier = (node, options) => {
|
|
181
|
-
switch (options.sqlIdentifierCase) {
|
|
182
|
-
case "preserve":
|
|
183
|
-
return node.text;
|
|
184
|
-
case "upper":
|
|
185
|
-
return node.text.toUpperCase();
|
|
186
|
-
case "lower":
|
|
187
|
-
return node.text.toLowerCase();
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
const printFunctionName = (node, options) => {
|
|
191
|
-
switch (options.sqlFunctionCase) {
|
|
192
|
-
case "preserve":
|
|
193
|
-
return node.text;
|
|
194
|
-
case "upper":
|
|
195
|
-
return node.text.toUpperCase();
|
|
196
|
-
case "lower":
|
|
197
|
-
return node.text.toLowerCase();
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
const isQuotedIdentifier = (node) => node.name !== node.text;
|
|
201
|
-
const isQuotedVariable = (node) => !(node.text === "@" + node.name || node.text === "@@" + node.name);
|
|
202
|
-
const isQuotedParameter = (node) => /`$/.test(node.text);
|
|
203
|
-
const isInsideBigqueryQuotedMemberExpr = (path) => path.ancestors.some(isBigqueryQuotedMemberExpr);
|
|
204
|
-
const isFunctionName = (node, path) => {
|
|
205
|
-
const parent = path.parent;
|
|
206
|
-
if (isFunctionContext(parent, path.grandparent)) {
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
if (isMemberExpr(parent) && parent.property === node) {
|
|
210
|
-
const [_, gp, ggp] = path.ancestors;
|
|
211
|
-
return isFunctionContext(gp, ggp);
|
|
212
|
-
}
|
|
213
|
-
return false;
|
|
214
|
-
};
|
|
215
|
-
const isFunctionContext = (node, parent) => {
|
|
216
|
-
return (isFuncCall(node) ||
|
|
217
|
-
isFunctionSignature(node) ||
|
|
218
|
-
isCreateFunctionStmt(node) ||
|
|
219
|
-
isCreateProcedureStmt(node) ||
|
|
220
|
-
(isAlterActionRename(node) &&
|
|
221
|
-
(isAlterFunctionStmt(parent) || isAlterProcedureStmt(parent))) ||
|
|
222
|
-
(isExecuteClause(node) && isCreateTriggerStmt(parent)));
|
|
223
|
-
};
|
|
224
|
-
const isBooleanOp = ({ name }) => name === "AND" || name === "OR";
|
package/dist/syntax/extension.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { group, indent, line } from "../print_utils";
|
|
2
|
-
export const extensionMap = {
|
|
3
|
-
create_extension_stmt: (print, node) => group([
|
|
4
|
-
print.spaced(["createExtensionKw", "ifNotExistsKw", "name"]),
|
|
5
|
-
node.clauses.length > 0
|
|
6
|
-
? indent([line, print.spaced(["withKw", "clauses"])])
|
|
7
|
-
: [],
|
|
8
|
-
]),
|
|
9
|
-
extension_cascade_clause: (print) => group(print.spaced(["cascadeKw"])),
|
|
10
|
-
extension_schema_clause: (print) => group(print.spaced(["schemaKw", "name"])),
|
|
11
|
-
extension_version_clause: (print) => group(print.spaced(["versionKw", "name"])),
|
|
12
|
-
drop_extension_stmt: (print) => group(print.spaced(["dropExtensionKw", "ifExistsKw", "names", "behaviorKw"])),
|
|
13
|
-
};
|
package/dist/syntax/frame.d.ts
DELETED
package/dist/syntax/frame.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { hardline } from "../print_utils";
|
|
2
|
-
export const frameMap = {
|
|
3
|
-
frame_clause: (print, node) => [
|
|
4
|
-
print.spaced(["unitKw", "extent"]),
|
|
5
|
-
node.exclusion ? [hardline, print("exclusion")] : [],
|
|
6
|
-
],
|
|
7
|
-
frame_bound_current_row: (print) => print.spaced("currentRowKw"),
|
|
8
|
-
frame_bound_preceding: (print) => print.spaced(["expr", "precedingKw"]),
|
|
9
|
-
frame_bound_following: (print) => print.spaced(["expr", "followingKw"]),
|
|
10
|
-
frame_unbounded: (print) => print.spaced("unboundedKw"),
|
|
11
|
-
frame_between: (print) => print.spaced(["betweenKw", "begin", "andKw", "end"]),
|
|
12
|
-
frame_exclusion: (print) => print.spaced(["excludeKw", "kindKw"]),
|
|
13
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { AllFunctionNodes, CreateFunctionStmt, CreateProcedureStmt } from "sql-parser-cst";
|
|
2
|
-
import { CstToDocMap } from "../CstToDocMap";
|
|
3
|
-
export declare const functionMap: CstToDocMap<AllFunctionNodes>;
|
|
4
|
-
export declare const hasOnlyAsClause: (node: CreateFunctionStmt | CreateProcedureStmt) => boolean;
|
package/dist/syntax/function.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { group, hardline, join } from "../print_utils";
|
|
2
|
-
import { isAsClause } from "../node_utils";
|
|
3
|
-
export const functionMap = {
|
|
4
|
-
create_function_stmt: (print, node) => group([
|
|
5
|
-
print.spaced([
|
|
6
|
-
"createKw",
|
|
7
|
-
"orReplaceKw",
|
|
8
|
-
"temporaryKw",
|
|
9
|
-
"tableKw",
|
|
10
|
-
"functionKw",
|
|
11
|
-
"ifNotExistsKw",
|
|
12
|
-
"name",
|
|
13
|
-
]),
|
|
14
|
-
print("params"),
|
|
15
|
-
hasOnlyAsClause(node)
|
|
16
|
-
? [" ", group(print("clauses"))]
|
|
17
|
-
: [
|
|
18
|
-
hardline,
|
|
19
|
-
join(hardline, print("clauses").map((cls) => group(cls))),
|
|
20
|
-
],
|
|
21
|
-
]),
|
|
22
|
-
function_signature: (print) => print(["name", "params"]),
|
|
23
|
-
function_param: (print) => print.spaced(["mode", "name", "dataType", "default"]),
|
|
24
|
-
function_param_default: (print) => print.spaced(["operator", "expr"]),
|
|
25
|
-
return_clause: (print) => print.spaced(["returnKw", "expr"]),
|
|
26
|
-
function_behavior_clause: (print) => print.spaced(["behaviorKw"]),
|
|
27
|
-
function_security_clause: (print) => print.spaced(["externalKw", "securityKw"]),
|
|
28
|
-
function_cost_clause: (print) => print.spaced(["costKw", "cost"]),
|
|
29
|
-
function_rows_clause: (print) => print.spaced(["rowsKw", "rows"]),
|
|
30
|
-
function_support_clause: (print) => print.spaced(["supportKw", "name"]),
|
|
31
|
-
function_window_clause: (print) => print.spaced("windowKw"),
|
|
32
|
-
function_transform_clause: (print) => print.spaced(["transformKw", "types"]),
|
|
33
|
-
transform_type: (print) => print.spaced(["forTypeKw", "dataType"]),
|
|
34
|
-
dynamically_loaded_function: (print) => join(", ", print(["objectFile", "symbol"])),
|
|
35
|
-
drop_function_stmt: (print) => group([
|
|
36
|
-
print.spaced([
|
|
37
|
-
"dropKw",
|
|
38
|
-
"tableKw",
|
|
39
|
-
"functionKw",
|
|
40
|
-
"ifExistsKw",
|
|
41
|
-
"signatures",
|
|
42
|
-
"behaviorKw",
|
|
43
|
-
]),
|
|
44
|
-
]),
|
|
45
|
-
// almost exact copy of alter_procedure_stmt
|
|
46
|
-
alter_function_stmt: (print, node) => group([
|
|
47
|
-
print.spaced(["alterKw", "functionKw"]),
|
|
48
|
-
" ",
|
|
49
|
-
print(["signature"]),
|
|
50
|
-
print.dynamicLine(),
|
|
51
|
-
join(print.dynamicLine(), print("actions")),
|
|
52
|
-
node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : [],
|
|
53
|
-
]),
|
|
54
|
-
};
|
|
55
|
-
export const hasOnlyAsClause = (node) => node.clauses.length === 1 && isAsClause(node.clauses[0]);
|
package/dist/syntax/index.d.ts
DELETED
package/dist/syntax/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { group, join } from "../print_utils";
|
|
2
|
-
export const indexMap = {
|
|
3
|
-
create_index_stmt: (print) => group(join(print.dynamicLine(), [
|
|
4
|
-
print.spaced([
|
|
5
|
-
"createKw",
|
|
6
|
-
"orReplaceKw",
|
|
7
|
-
"indexTypeKw",
|
|
8
|
-
"indexKw",
|
|
9
|
-
"concurrentlyKw",
|
|
10
|
-
"ifNotExistsKw",
|
|
11
|
-
"name",
|
|
12
|
-
"onKw",
|
|
13
|
-
"table",
|
|
14
|
-
"using",
|
|
15
|
-
"columns",
|
|
16
|
-
]),
|
|
17
|
-
...print("clauses"),
|
|
18
|
-
])),
|
|
19
|
-
index_specification: (print) => print.spaced(["expr", "opclass", "direction", "nullHandlingKw"]),
|
|
20
|
-
index_include_clause: (print) => print.spaced(["includeKw", "columns"]),
|
|
21
|
-
index_nulls_distinct_clause: (print) => print.spaced(["nullsDistinctKw"]),
|
|
22
|
-
index_nulls_not_distinct_clause: (print) => print.spaced(["nullsNotDistinctKw"]),
|
|
23
|
-
drop_index_stmt: (print) => group(print.spaced([
|
|
24
|
-
"dropKw",
|
|
25
|
-
"indexTypeKw",
|
|
26
|
-
"indexKw",
|
|
27
|
-
"concurrentlyKw",
|
|
28
|
-
"ifExistsKw",
|
|
29
|
-
"indexes",
|
|
30
|
-
"onKw",
|
|
31
|
-
"table",
|
|
32
|
-
"behaviorKw",
|
|
33
|
-
])),
|
|
34
|
-
verbose_all_columns: (print) => print.spaced("allColumnsKw"),
|
|
35
|
-
alter_index_stmt: (print) => group([
|
|
36
|
-
print.spaced(["alterKw", "indexKw", "ifExistsKw", "index"]),
|
|
37
|
-
print.dynamicLine(),
|
|
38
|
-
print("action"),
|
|
39
|
-
]),
|
|
40
|
-
alter_index_all_in_tablespace_stmt: (print) => group([
|
|
41
|
-
print.spaced([
|
|
42
|
-
"alterIndexKw",
|
|
43
|
-
"allInTablespaceKw",
|
|
44
|
-
"tablespace",
|
|
45
|
-
"ownedBy",
|
|
46
|
-
]),
|
|
47
|
-
print.dynamicLine(),
|
|
48
|
-
print("action"),
|
|
49
|
-
]),
|
|
50
|
-
reindex_stmt: (print) => group(print.spaced([
|
|
51
|
-
"reindexKw",
|
|
52
|
-
"options",
|
|
53
|
-
"targetKw",
|
|
54
|
-
"concurrentlyKw",
|
|
55
|
-
"name",
|
|
56
|
-
])),
|
|
57
|
-
reindex_option_concurrently: (print) => print.spaced(["concurrentlyKw", "value"]),
|
|
58
|
-
reindex_option_tablespace: (print) => print.spaced(["tablespaceKw", "name"]),
|
|
59
|
-
reindex_option_verbose: (print) => print.spaced(["verboseKw", "value"]),
|
|
60
|
-
};
|
package/dist/syntax/insert.d.ts
DELETED
package/dist/syntax/insert.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { join, group, indent } from "../print_utils";
|
|
2
|
-
export const insertMap = {
|
|
3
|
-
insert_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
|
|
4
|
-
insert_clause: (print, node) => group([
|
|
5
|
-
print.spaced(["insertKw", "modifiers", "orAction", "intoKw", "table"]),
|
|
6
|
-
node.columns ? indent([print.dynamicLine(), print("columns")]) : [],
|
|
7
|
-
]),
|
|
8
|
-
values_clause: (print) => group([print("valuesKw"), indent([print.dynamicLine(), print("values")])]),
|
|
9
|
-
or_alternate_action: (print) => print.spaced(["orKw", "actionKw"]),
|
|
10
|
-
default: (print) => print("defaultKw"),
|
|
11
|
-
default_values: (print) => print.spaced("defaultValuesKw"),
|
|
12
|
-
upsert_clause: (print) => print.spaced(["onConflictKw", "conflictTarget", "where", "doKw", "action"]),
|
|
13
|
-
conflict_target_on_constraint: (print) => print.spaced(["onConstraintKw", "constraint"]),
|
|
14
|
-
upsert_action_nothing: (print) => print("nothingKw"),
|
|
15
|
-
upsert_action_update: (print) => group([
|
|
16
|
-
print("updateKw"),
|
|
17
|
-
indent([
|
|
18
|
-
print.dynamicLine(),
|
|
19
|
-
join(print.dynamicLine(), print(["set", "where"])),
|
|
20
|
-
]),
|
|
21
|
-
]),
|
|
22
|
-
row_alias_clause: (print, node) => group([
|
|
23
|
-
print.spaced(["asKw", "rowAlias"]),
|
|
24
|
-
node.columnAliases
|
|
25
|
-
? indent([print.dynamicLine(), print("columnAliases")])
|
|
26
|
-
: [],
|
|
27
|
-
]),
|
|
28
|
-
on_duplicate_key_update_clause: (print) => group([
|
|
29
|
-
print.spaced("onDuplicateKeyUpdateKw"),
|
|
30
|
-
indent([print.dynamicLine(), print("assignments")]),
|
|
31
|
-
]),
|
|
32
|
-
overriding_clause: (print) => print.spaced("overridingKw"),
|
|
33
|
-
};
|
package/dist/syntax/merge.d.ts
DELETED