prettier-plugin-sql-cst 0.5.0 → 0.6.0
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/README.md +0 -1
- package/dist/node_utils.js +4 -1
- package/dist/syntax/create_table.js +2 -0
- package/dist/syntax/expr.js +14 -1
- package/dist/syntax/sqlite.js +0 -6
- package/dist/syntax/trigger.js +10 -5
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/node_utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAsClause = exports.isArraySubscript = exports.isStringLiteral = exports.isJsonLiteral = exports.isEmpty = exports.isKeyword = exports.isCreateTableStmt = exports.isFuncCall = exports.isValuesClause = void 0;
|
|
3
|
+
exports.isListExpr = exports.isParenExpr = exports.isAsClause = exports.isArraySubscript = exports.isStringLiteral = exports.isJsonLiteral = exports.isEmpty = exports.isKeyword = exports.isCreateTableStmt = exports.isFuncArgs = exports.isFuncCall = exports.isValuesClause = void 0;
|
|
4
4
|
var utils_1 = require("./utils");
|
|
5
5
|
var is = function (type) {
|
|
6
6
|
return function (node) {
|
|
@@ -9,6 +9,7 @@ var is = function (type) {
|
|
|
9
9
|
};
|
|
10
10
|
exports.isValuesClause = is("values_clause");
|
|
11
11
|
exports.isFuncCall = is("func_call");
|
|
12
|
+
exports.isFuncArgs = is("func_args");
|
|
12
13
|
exports.isCreateTableStmt = is("create_table_stmt");
|
|
13
14
|
exports.isKeyword = is("keyword");
|
|
14
15
|
exports.isEmpty = is("empty");
|
|
@@ -16,3 +17,5 @@ exports.isJsonLiteral = is("json_literal");
|
|
|
16
17
|
exports.isStringLiteral = is("string_literal");
|
|
17
18
|
exports.isArraySubscript = is("array_subscript");
|
|
18
19
|
exports.isAsClause = is("as_clause");
|
|
20
|
+
exports.isParenExpr = is("paren_expr");
|
|
21
|
+
exports.isListExpr = is("list_expr");
|
|
@@ -25,6 +25,7 @@ exports.createTableMap = {
|
|
|
25
25
|
"temporaryKw",
|
|
26
26
|
"externalKw",
|
|
27
27
|
"snapshotKw",
|
|
28
|
+
"virtualKw",
|
|
28
29
|
"tableKw",
|
|
29
30
|
"ifNotExistsKw",
|
|
30
31
|
"name",
|
|
@@ -44,6 +45,7 @@ exports.createTableMap = {
|
|
|
44
45
|
with_partition_columns_clause: function (print) {
|
|
45
46
|
return print.spaced(["withPartitionColumnsKw", "columns"]);
|
|
46
47
|
},
|
|
48
|
+
create_table_using_clause: function (print) { return print.spaced(["usingKw", "module"]); },
|
|
47
49
|
};
|
|
48
50
|
var printClauses = function (print, node) {
|
|
49
51
|
if (node.clauses.length === 1 && (0, node_utils_1.isAsClause)(node.clauses[0])) {
|
package/dist/syntax/expr.js
CHANGED
|
@@ -33,6 +33,15 @@ exports.exprMap = {
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
paren_expr: function (print, node, path) {
|
|
36
|
+
// discard unnecessary nested ((parentheses))
|
|
37
|
+
if ((0, node_utils_1.isParenExpr)(node.expr)) {
|
|
38
|
+
return print("expr");
|
|
39
|
+
}
|
|
40
|
+
// Discard unnecessary parenthesis around function arguments
|
|
41
|
+
if ((0, node_utils_1.isListExpr)(path.getParentNode(0)) &&
|
|
42
|
+
(0, node_utils_1.isFuncArgs)(path.getParentNode(1))) {
|
|
43
|
+
return print("expr");
|
|
44
|
+
}
|
|
36
45
|
var parent = path.getParentNode();
|
|
37
46
|
var lineStyle = (0, node_utils_1.isCreateTableStmt)(parent) ? print_utils_1.hardline : print_utils_1.softline;
|
|
38
47
|
return (0, print_utils_1.group)(["(", (0, print_utils_1.indent)([lineStyle, print("expr")]), lineStyle, ")"]);
|
|
@@ -84,8 +93,11 @@ exports.exprMap = {
|
|
|
84
93
|
filter_arg: function (print) { return print.spaced(["filterKw", "where"]); },
|
|
85
94
|
over_arg: function (print) { return print.spaced(["overKw", "window"]); },
|
|
86
95
|
cast_expr: function (print) { return print(["castKw", "args"]); },
|
|
87
|
-
cast_arg: function (print) { return print.spaced(["expr", "asKw", "dataType"]); },
|
|
96
|
+
cast_arg: function (print) { return print.spaced(["expr", "asKw", "dataType", "format"]); },
|
|
97
|
+
cast_format: function (print) { return print.spaced(["formatKw", "string", "timezone"]); },
|
|
98
|
+
cast_format_timezone: function (print) { return print.spaced(["atTimeZoneKw", "timezone"]); },
|
|
88
99
|
raise_expr: function (print) { return print(["raiseKw", "args"]); },
|
|
100
|
+
raise_expr_type: function (print) { return print("typeKw"); },
|
|
89
101
|
interval_expr: function (print) { return print.spaced(["intervalKw", "expr", "unit"]); },
|
|
90
102
|
interval_unit_range: function (print) {
|
|
91
103
|
return print.spaced(["fromUnitKw", "toKw", "toUnitKw"]);
|
|
@@ -109,6 +121,7 @@ exports.exprMap = {
|
|
|
109
121
|
timestamp_literal: function (print) { return print.spaced(["timestampKw", "string"]); },
|
|
110
122
|
json_literal: function (print) { return print.spaced(["jsonKw", "string"]); },
|
|
111
123
|
identifier: function (print) { return print("text"); },
|
|
124
|
+
variable: function (print) { return print("text"); },
|
|
112
125
|
};
|
|
113
126
|
var isBooleanOp = function (_a) {
|
|
114
127
|
var name = _a.name;
|
package/dist/syntax/sqlite.js
CHANGED
|
@@ -16,10 +16,4 @@ exports.sqliteMap = {
|
|
|
16
16
|
pragma_stmt: function (print) { return print.spaced(["pragmaKw", "pragma"]); },
|
|
17
17
|
pragma_assignment: function (print) { return (0, print_utils_1.join)(" = ", print(["name", "value"])); },
|
|
18
18
|
pragma_func_call: function (print) { return print(["name", "args"]); },
|
|
19
|
-
create_virtual_table_stmt: function (print) {
|
|
20
|
-
return (0, print_utils_1.join)(print_utils_1.hardline, [
|
|
21
|
-
print.spaced(["createVirtualTableKw", "ifNotExistsKw", "name"]),
|
|
22
|
-
print.spaced(["usingKw", "module"]),
|
|
23
|
-
]);
|
|
24
|
-
},
|
|
25
19
|
};
|
package/dist/syntax/trigger.js
CHANGED
|
@@ -21,15 +21,20 @@ exports.triggerMap = {
|
|
|
21
21
|
"ifNotExistsKw",
|
|
22
22
|
"name",
|
|
23
23
|
]),
|
|
24
|
-
|
|
24
|
+
print("event")
|
|
25
25
|
], (node.forEachRowKw ? [print.spaced(["forEachRowKw"])] : []), true), (node.condition ? [print(["condition"])] : []), true), [
|
|
26
26
|
print("body"),
|
|
27
27
|
], false));
|
|
28
28
|
},
|
|
29
|
-
trigger_event: function (print
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
trigger_event: function (print) {
|
|
30
|
+
return (0, print_utils_1.group)([
|
|
31
|
+
print.spaced(["timeKw", "eventKw", "ofKw"]),
|
|
32
|
+
(0, print_utils_1.indent)([
|
|
33
|
+
print_utils_1.line,
|
|
34
|
+
(0, print_utils_1.join)(print_utils_1.line, __spreadArray(__spreadArray([], print(["columns"]), true), [print.spaced(["onKw", "table"])], false)),
|
|
35
|
+
]),
|
|
36
|
+
]);
|
|
37
|
+
},
|
|
33
38
|
trigger_condition: function (print) {
|
|
34
39
|
return (0, print_utils_1.group)([print("whenKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
|
|
35
40
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sql-cst",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Prettier plugin for SQL",
|
|
5
5
|
"author": "Rene Saarsoo <nene@triin.net>",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"prettier": "^2.8.2",
|
|
32
|
-
"sql-parser-cst": "^0.
|
|
32
|
+
"sql-parser-cst": "^0.13.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jest": "^29.2.5",
|