prettier-plugin-sql-cst 0.6.0 → 0.8.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 +8 -11
- package/dist/embed.js +13 -0
- package/dist/embedJs.js +53 -0
- package/dist/index.js +5 -5
- package/dist/node_utils.js +4 -1
- package/dist/options.js +9 -0
- package/dist/printComment.js +16 -0
- package/dist/print_utils.js +8 -1
- package/dist/syntax/bigquery.js +116 -1
- package/dist/syntax/dcl.js +20 -0
- package/dist/syntax/expr.js +17 -2
- package/dist/syntax/function.js +32 -0
- package/dist/syntax/index.js +10 -1
- package/dist/syntax/merge.js +42 -0
- package/dist/syntax/prepared_statements.js +25 -0
- package/dist/syntax/proc_clause.js +10 -1
- package/dist/syntax/procedural_language.js +108 -1
- package/dist/syntax/procedure.js +22 -0
- package/dist/syntax/program.js +10 -4
- package/dist/syntax/schema.js +28 -0
- package/dist/syntax/transformMap.js +7 -1
- package/dist/syntax/view.js +5 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -96,21 +96,17 @@ There are also some SQL-specific options:
|
|
|
96
96
|
| API Option | Default | Description |
|
|
97
97
|
| ---------------- | :-----: | ------------------------------------------------------------------------- |
|
|
98
98
|
| `sqlKeywordCase` | `upper` | Converts SQL keywords to `upper` or `lower` case, or `preserve` existing. |
|
|
99
|
+
| `sqlParamTypes` | `[]` | Array of bound parameter types: `?`, `?nr`, `:name`, `@name`, `$name`. |
|
|
99
100
|
|
|
100
101
|
## Limitations and development status
|
|
101
102
|
|
|
102
|
-
Currently this plugin supports
|
|
103
|
-
It also supports most of the **BigQuery** syntax.
|
|
104
|
-
Specifically the formatting of the following BigQuery SQL statements is fully implemented:
|
|
103
|
+
Currently this plugin supports two SQL dialects:
|
|
105
104
|
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
- CREATE / DROP / ALTER TABLE
|
|
112
|
-
- CREATE / DROP VIEW
|
|
113
|
-
- transactions (BEGIN, COMMIT, ROLLBACK)
|
|
105
|
+
- **SQLite** - full support.
|
|
106
|
+
- **BigQuery** - full support.
|
|
107
|
+
|
|
108
|
+
The specifics of the [SQL formatting style][STYLE_GUIDE] are still very much subject to change.
|
|
109
|
+
Though the general principles should be mostly in place by now.
|
|
114
110
|
|
|
115
111
|
[prettier]: https://prettier.io/
|
|
116
112
|
[printWidth]: https://prettier.io/docs/en/options.html#print-width
|
|
@@ -119,3 +115,4 @@ Specifically the formatting of the following BigQuery SQL statements is fully im
|
|
|
119
115
|
[sql-parser-cst]: https://github.com/nene/sql-parser-cst
|
|
120
116
|
[wadler-prettier]: http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
|
|
121
117
|
[STYLE_GUIDE]: ./STYLE_GUIDE.md
|
|
118
|
+
[#2]: https://github.com/nene/prettier-plugin-sql-cst/issues/2
|
package/dist/embed.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.embed = void 0;
|
|
4
|
+
var embedJs_1 = require("./embedJs");
|
|
5
|
+
var embedJson_1 = require("./embedJson");
|
|
6
|
+
var embed = function () {
|
|
7
|
+
var args = [];
|
|
8
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9
|
+
args[_i] = arguments[_i];
|
|
10
|
+
}
|
|
11
|
+
return embedJson_1.embedJson.apply(void 0, args) || embedJs_1.embedJs.apply(void 0, args);
|
|
12
|
+
};
|
|
13
|
+
exports.embed = embed;
|
package/dist/embedJs.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.embedJs = void 0;
|
|
15
|
+
var node_utils_1 = require("./node_utils");
|
|
16
|
+
var print_utils_1 = require("./print_utils");
|
|
17
|
+
var embedJs = function (path, print, textToDoc, options) {
|
|
18
|
+
var node = path.getValue();
|
|
19
|
+
var parent = path.getParentNode(0);
|
|
20
|
+
var grandParent = path.getParentNode(1);
|
|
21
|
+
if ((0, node_utils_1.isStringLiteral)(node) &&
|
|
22
|
+
(0, node_utils_1.isAsClause)(parent) &&
|
|
23
|
+
(0, node_utils_1.isCreateFunctionStmt)(grandParent) &&
|
|
24
|
+
grandParent.clauses.some(isJavaScriptLanguageClause)) {
|
|
25
|
+
var quotes = detectQuotes(node.value);
|
|
26
|
+
if (!quotes) {
|
|
27
|
+
// Give up for now. Don't format JavaScript inside the string.
|
|
28
|
+
// Perhaps tackle this corner-case in the future.
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
var js = textToDoc(node.value, __assign(__assign({}, options), { parser: "babel" }));
|
|
32
|
+
return [
|
|
33
|
+
quotes[0],
|
|
34
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(js)]),
|
|
35
|
+
print_utils_1.hardline,
|
|
36
|
+
quotes[1],
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
41
|
+
exports.embedJs = embedJs;
|
|
42
|
+
var isJavaScriptLanguageClause = function (clause) { return (0, node_utils_1.isLanguageClause)(clause) && clause.name.name === "js"; };
|
|
43
|
+
// Whether to quote the code with single- or double-quotes.
|
|
44
|
+
// Returns undefined when neither can be used without escaping.
|
|
45
|
+
var detectQuotes = function (js) {
|
|
46
|
+
if (!/'''/.test(js)) {
|
|
47
|
+
return ["r'''", "'''"];
|
|
48
|
+
}
|
|
49
|
+
if (!/"""/.test(js)) {
|
|
50
|
+
return ['r"""', '"""'];
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printers = exports.parsers = exports.languages = exports.options = void 0;
|
|
4
4
|
var sql_parser_cst_1 = require("sql-parser-cst");
|
|
5
5
|
var printSql_1 = require("./printSql");
|
|
6
|
-
var
|
|
6
|
+
var printComment_1 = require("./printComment");
|
|
7
|
+
var embed_1 = require("./embed");
|
|
7
8
|
var utils_1 = require("./utils");
|
|
8
9
|
var transformCst_1 = require("./transform/transformCst");
|
|
9
10
|
var options_1 = require("./options");
|
|
@@ -27,6 +28,7 @@ var createParser = function (dialect) { return ({
|
|
|
27
28
|
includeRange: true,
|
|
28
29
|
includeComments: true,
|
|
29
30
|
filename: options.filepath,
|
|
31
|
+
paramTypes: options.sqlParamTypes,
|
|
30
32
|
}), text);
|
|
31
33
|
},
|
|
32
34
|
astFormat: "sql-cst",
|
|
@@ -40,10 +42,8 @@ exports.parsers = {
|
|
|
40
42
|
exports.printers = {
|
|
41
43
|
"sql-cst": {
|
|
42
44
|
print: printSql_1.printSql,
|
|
43
|
-
embed:
|
|
44
|
-
printComment:
|
|
45
|
-
return path.getValue().text;
|
|
46
|
-
},
|
|
45
|
+
embed: embed_1.embed,
|
|
46
|
+
printComment: printComment_1.printComment,
|
|
47
47
|
canAttachComment: utils_1.isNode,
|
|
48
48
|
isBlockComment: function (node) { return node.type === "block_comment"; },
|
|
49
49
|
},
|
package/dist/node_utils.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.isLanguageClause = exports.isCreateFunctionStmt = exports.isListExpr = exports.isParenExpr = exports.isAsClause = exports.isArraySubscript = exports.isStringLiteral = exports.isJsonLiteral = exports.isEmpty = exports.isKeyword = exports.isCreateTableStmt = exports.isFuncArgs = exports.isFuncCall = exports.isValuesClause = exports.isProgram = void 0;
|
|
4
4
|
var utils_1 = require("./utils");
|
|
5
5
|
var is = function (type) {
|
|
6
6
|
return function (node) {
|
|
7
7
|
return (0, utils_1.isObject)(node) && node.type === type;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
+
exports.isProgram = is("program");
|
|
10
11
|
exports.isValuesClause = is("values_clause");
|
|
11
12
|
exports.isFuncCall = is("func_call");
|
|
12
13
|
exports.isFuncArgs = is("func_args");
|
|
@@ -19,3 +20,5 @@ exports.isArraySubscript = is("array_subscript");
|
|
|
19
20
|
exports.isAsClause = is("as_clause");
|
|
20
21
|
exports.isParenExpr = is("paren_expr");
|
|
21
22
|
exports.isListExpr = is("list_expr");
|
|
23
|
+
exports.isCreateFunctionStmt = is("create_function_stmt");
|
|
24
|
+
exports.isLanguageClause = is("language_clause");
|
package/dist/options.js
CHANGED
|
@@ -17,4 +17,13 @@ exports.options = {
|
|
|
17
17
|
{ value: "lower", description: "forces all keywords to lowercase" },
|
|
18
18
|
],
|
|
19
19
|
},
|
|
20
|
+
sqlParamTypes: {
|
|
21
|
+
type: "string",
|
|
22
|
+
array: true,
|
|
23
|
+
category: "SQL",
|
|
24
|
+
since: "0.7.0",
|
|
25
|
+
default: [{ value: [] }],
|
|
26
|
+
description: "Syntax for bound parameters",
|
|
27
|
+
// Possible values in array: "?" | "?nr" | ":name" | "$name" | "@name"
|
|
28
|
+
},
|
|
20
29
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printComment = void 0;
|
|
4
|
+
var printComment = function (path) {
|
|
5
|
+
var node = path.getValue();
|
|
6
|
+
if (node.type === "line_comment") {
|
|
7
|
+
if (/^--[^ \t]/.test(node.text)) {
|
|
8
|
+
return node.text.replace(/^--/, "-- ");
|
|
9
|
+
}
|
|
10
|
+
if (/^#[^ \t!]/.test(node.text)) {
|
|
11
|
+
return node.text.replace(/^#/, "# ");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return node.text;
|
|
15
|
+
};
|
|
16
|
+
exports.printComment = printComment;
|
package/dist/print_utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.containsNewline = exports.join = exports.stripTrailingHardline = exports.breakParent = exports.ifBreak = exports.lineSuffix = exports.group = exports.indent = exports.softline = exports.hardline = exports.line = void 0;
|
|
4
|
+
exports.hasEmptyLineBetweenNodes = exports.containsNewline = exports.join = exports.stripTrailingHardline = exports.breakParent = exports.ifBreak = exports.lineSuffix = exports.group = exports.indent = exports.softline = exports.hardline = exports.line = void 0;
|
|
5
5
|
var prettier_1 = require("prettier");
|
|
6
6
|
var utils_1 = require("./utils");
|
|
7
7
|
exports.line = (_a = prettier_1.doc.builders, _a.line), exports.hardline = _a.hardline, exports.softline = _a.softline, exports.indent = _a.indent, exports.group = _a.group, exports.lineSuffix = _a.lineSuffix, exports.ifBreak = _a.ifBreak, exports.breakParent = _a.breakParent;
|
|
@@ -20,3 +20,10 @@ var containsNewline = function (node, opts) {
|
|
|
20
20
|
return prettier_1.util.hasNewlineInRange(opts.originalText, node.range[0], node.range[1]);
|
|
21
21
|
};
|
|
22
22
|
exports.containsNewline = containsNewline;
|
|
23
|
+
var hasEmptyLineBetweenNodes = function (node1, node2, opts) {
|
|
24
|
+
if (!node1.range || !node2.range) {
|
|
25
|
+
throw new Error("emptyLineBetweenNodes() expects Nodes with range info");
|
|
26
|
+
}
|
|
27
|
+
return /\n[ \t]*\r?\n/.test(opts.originalText.slice(node1.range[1], node2.range[0]));
|
|
28
|
+
};
|
|
29
|
+
exports.hasEmptyLineBetweenNodes = hasEmptyLineBetweenNodes;
|
package/dist/syntax/bigquery.js
CHANGED
|
@@ -1,9 +1,124 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.bigqueryMap = void 0;
|
|
13
|
+
var print_utils_1 = require("../print_utils");
|
|
4
14
|
exports.bigqueryMap = {
|
|
5
|
-
bigquery_options: function (print) { return print(["optionsKw", "options"]); },
|
|
15
|
+
bigquery_options: function (print) { return print.spaced(["optionsKw", "options"]); },
|
|
6
16
|
bigquery_option_default_collate: function (print) {
|
|
7
17
|
return print.spaced(["defaultCollateKw", "collation"]);
|
|
8
18
|
},
|
|
19
|
+
// ROW ACCESS POLICY
|
|
20
|
+
create_row_access_policy_stmt: function (print) {
|
|
21
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
|
|
22
|
+
print.spaced([
|
|
23
|
+
"createKw",
|
|
24
|
+
"orReplaceKw",
|
|
25
|
+
"rowAccessPolicyKw",
|
|
26
|
+
"ifNotExistsKw",
|
|
27
|
+
"name",
|
|
28
|
+
"onKw",
|
|
29
|
+
"table",
|
|
30
|
+
])
|
|
31
|
+
], print("clauses"), true));
|
|
32
|
+
},
|
|
33
|
+
row_access_policy_grant_clause: function (print) {
|
|
34
|
+
return print.spaced(["grantToKw", "grantees"]);
|
|
35
|
+
},
|
|
36
|
+
row_access_policy_filter_clause: function (print) {
|
|
37
|
+
return print.spaced(["filterUsingKw", "expr"]);
|
|
38
|
+
},
|
|
39
|
+
drop_row_access_policy_stmt: function (print) {
|
|
40
|
+
return print.spaced([
|
|
41
|
+
"dropKw",
|
|
42
|
+
"allKw",
|
|
43
|
+
"rowAccessPolicyKw",
|
|
44
|
+
"ifExistsKw",
|
|
45
|
+
"name",
|
|
46
|
+
"onKw",
|
|
47
|
+
"table",
|
|
48
|
+
]);
|
|
49
|
+
},
|
|
50
|
+
// CAPACITY
|
|
51
|
+
create_capacity_stmt: function (print) { return [
|
|
52
|
+
print.spaced(["createKw", "capacityKw", "name"]),
|
|
53
|
+
print_utils_1.hardline,
|
|
54
|
+
print("options"),
|
|
55
|
+
]; },
|
|
56
|
+
drop_capacity_stmt: function (print) {
|
|
57
|
+
return print.spaced(["dropKw", "capacityKw", "ifExistsKw", "name"]);
|
|
58
|
+
},
|
|
59
|
+
// RESERVATION
|
|
60
|
+
create_reservation_stmt: function (print) { return [
|
|
61
|
+
print.spaced(["createKw", "reservationKw", "name"]),
|
|
62
|
+
print_utils_1.hardline,
|
|
63
|
+
print("options"),
|
|
64
|
+
]; },
|
|
65
|
+
drop_reservation_stmt: function (print) {
|
|
66
|
+
return print.spaced(["dropKw", "reservationKw", "ifExistsKw", "name"]);
|
|
67
|
+
},
|
|
68
|
+
// ASSIGNMENT
|
|
69
|
+
create_assignment_stmt: function (print) { return [
|
|
70
|
+
print.spaced(["createKw", "assignmentKw", "name"]),
|
|
71
|
+
print_utils_1.hardline,
|
|
72
|
+
print("options"),
|
|
73
|
+
]; },
|
|
74
|
+
drop_assignment_stmt: function (print) {
|
|
75
|
+
return print.spaced(["dropKw", "assignmentKw", "ifExistsKw", "name"]);
|
|
76
|
+
},
|
|
77
|
+
// ALTER ORGANIZATION
|
|
78
|
+
alter_organization_stmt: function (print) {
|
|
79
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, [print.spaced("alterOrganizationKw"), print("actions")]);
|
|
80
|
+
},
|
|
81
|
+
// ALTER PROJECT
|
|
82
|
+
alter_project_stmt: function (print) {
|
|
83
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, [
|
|
84
|
+
print.spaced(["alterProjectKw", "name"]),
|
|
85
|
+
print("actions"),
|
|
86
|
+
]);
|
|
87
|
+
},
|
|
88
|
+
alter_bi_capacity_stmt: function (print) {
|
|
89
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, [
|
|
90
|
+
print.spaced(["alterBiCapacityKw", "name"]),
|
|
91
|
+
print("actions"),
|
|
92
|
+
]);
|
|
93
|
+
},
|
|
94
|
+
alter_capacity_stmt: function (print) {
|
|
95
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, [
|
|
96
|
+
print.spaced(["alterCapacityKw", "name"]),
|
|
97
|
+
print("actions"),
|
|
98
|
+
]);
|
|
99
|
+
},
|
|
100
|
+
alter_reservation_stmt: function (print) {
|
|
101
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, [
|
|
102
|
+
print.spaced(["alterReservationKw", "name"]),
|
|
103
|
+
print("actions"),
|
|
104
|
+
]);
|
|
105
|
+
},
|
|
106
|
+
// ASSERT
|
|
107
|
+
assert_stmt: function (print) { return print.spaced(["assertKw", "expr", "as"]); },
|
|
108
|
+
// EXPORT
|
|
109
|
+
export_data_stmt: function (print) {
|
|
110
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray(__spreadArray([
|
|
111
|
+
print.spaced("exportDataKw")
|
|
112
|
+
], print.spaced(["withConnection"]), true), [
|
|
113
|
+
print.spaced("options"),
|
|
114
|
+
print.spaced("as"),
|
|
115
|
+
], false));
|
|
116
|
+
},
|
|
117
|
+
// LOAD
|
|
118
|
+
load_data_stmt: function (print) {
|
|
119
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
|
|
120
|
+
print.spaced(["loadDataKw", "intoKw", "table", "columns"])
|
|
121
|
+
], print("clauses"), true));
|
|
122
|
+
},
|
|
123
|
+
from_files_options: function (print) { return print.spaced(["fromFilesKw", "options"]); },
|
|
9
124
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dclMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.dclMap = {
|
|
6
|
+
grant_stmt: function (print) {
|
|
7
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, [
|
|
8
|
+
(0, print_utils_1.group)([print("grantKw"), (0, print_utils_1.indent)([print_utils_1.line, print("roles")])]),
|
|
9
|
+
(0, print_utils_1.group)(print.spaced(["onKw", "resourceType", "resourceName"])),
|
|
10
|
+
(0, print_utils_1.group)([print("toKw"), (0, print_utils_1.indent)([print_utils_1.line, print("users")])]),
|
|
11
|
+
]);
|
|
12
|
+
},
|
|
13
|
+
revoke_stmt: function (print) {
|
|
14
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, [
|
|
15
|
+
(0, print_utils_1.group)([print("revokeKw"), (0, print_utils_1.indent)([print_utils_1.line, print("roles")])]),
|
|
16
|
+
(0, print_utils_1.group)(print.spaced(["onKw", "resourceType", "resourceName"])),
|
|
17
|
+
(0, print_utils_1.group)([print("fromKw"), (0, print_utils_1.indent)([print_utils_1.line, print("users")])]),
|
|
18
|
+
]);
|
|
19
|
+
},
|
|
20
|
+
};
|
package/dist/syntax/expr.js
CHANGED
|
@@ -65,10 +65,24 @@ exports.exprMap = {
|
|
|
65
65
|
print_utils_1.hardline,
|
|
66
66
|
print("endKw"),
|
|
67
67
|
]; },
|
|
68
|
-
case_when: function (print) {
|
|
68
|
+
case_when: function (print, node) {
|
|
69
|
+
if ((0, node_utils_1.isProgram)(node.result)) {
|
|
70
|
+
return [
|
|
71
|
+
print.spaced(["whenKw", "condition", "thenKw"]),
|
|
72
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("result"))]),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
69
75
|
return print.spaced(["whenKw", "condition", "thenKw", "result"]);
|
|
70
76
|
},
|
|
71
|
-
case_else: function (print
|
|
77
|
+
case_else: function (print, node) {
|
|
78
|
+
if ((0, node_utils_1.isProgram)(node.result)) {
|
|
79
|
+
return [
|
|
80
|
+
print("elseKw"),
|
|
81
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("result"))]),
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
return print.spaced(["elseKw", "result"]);
|
|
85
|
+
},
|
|
72
86
|
member_expr: function (print, node) {
|
|
73
87
|
return (0, node_utils_1.isArraySubscript)(node.property)
|
|
74
88
|
? print(["object", "property"])
|
|
@@ -122,6 +136,7 @@ exports.exprMap = {
|
|
|
122
136
|
json_literal: function (print) { return print.spaced(["jsonKw", "string"]); },
|
|
123
137
|
identifier: function (print) { return print("text"); },
|
|
124
138
|
variable: function (print) { return print("text"); },
|
|
139
|
+
parameter: function (print) { return print("text"); },
|
|
125
140
|
};
|
|
126
141
|
var isBooleanOp = function (_a) {
|
|
127
142
|
var name = _a.name;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functionMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
var node_utils_1 = require("../node_utils");
|
|
6
|
+
exports.functionMap = {
|
|
7
|
+
create_function_stmt: function (print, node) { return [
|
|
8
|
+
print.spaced([
|
|
9
|
+
"createKw",
|
|
10
|
+
"orReplaceKw",
|
|
11
|
+
"temporaryKw",
|
|
12
|
+
"tableKw",
|
|
13
|
+
"functionKw",
|
|
14
|
+
"ifNotExistsKw",
|
|
15
|
+
"name",
|
|
16
|
+
]),
|
|
17
|
+
print("params"),
|
|
18
|
+
hasOnlyAsClause(node)
|
|
19
|
+
? [" ", (0, print_utils_1.group)(print("clauses"))]
|
|
20
|
+
: [
|
|
21
|
+
print_utils_1.hardline,
|
|
22
|
+
(0, print_utils_1.join)(print_utils_1.hardline, print("clauses").map(function (cls) { return (0, print_utils_1.group)(cls); })),
|
|
23
|
+
],
|
|
24
|
+
]; },
|
|
25
|
+
function_param: function (print) { return print.spaced(["name", "dataType"]); },
|
|
26
|
+
drop_function_stmt: function (print) {
|
|
27
|
+
return print.spaced(["dropKw", "tableKw", "functionKw", "ifExistsKw", "name"]);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
var hasOnlyAsClause = function (node) {
|
|
31
|
+
return node.clauses.length === 1 && (0, node_utils_1.isAsClause)(node.clauses[0]);
|
|
32
|
+
};
|
package/dist/syntax/index.js
CHANGED
|
@@ -27,6 +27,15 @@ exports.indexMap = {
|
|
|
27
27
|
], (node.clauses.length > 0 ? [(0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))] : []), true));
|
|
28
28
|
},
|
|
29
29
|
drop_index_stmt: function (print) {
|
|
30
|
-
return print.spaced([
|
|
30
|
+
return print.spaced([
|
|
31
|
+
"dropKw",
|
|
32
|
+
"indexTypeKw",
|
|
33
|
+
"indexKw",
|
|
34
|
+
"ifExistsKw",
|
|
35
|
+
"indexes",
|
|
36
|
+
"onKw",
|
|
37
|
+
"table",
|
|
38
|
+
]);
|
|
31
39
|
},
|
|
40
|
+
verbose_all_columns: function (print) { return print.spaced("allColumnsKw"); },
|
|
32
41
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
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.mergeMap = void 0;
|
|
13
|
+
var print_utils_1 = require("../print_utils");
|
|
14
|
+
exports.mergeMap = {
|
|
15
|
+
merge_stmt: function (print) {
|
|
16
|
+
return (0, print_utils_1.join)(print_utils_1.line, __spreadArray([
|
|
17
|
+
print.spaced(["mergeKw", "intoKw", "target"]),
|
|
18
|
+
print.spaced(["usingKw", "source"]),
|
|
19
|
+
(0, print_utils_1.group)([print("onKw"), (0, print_utils_1.indent)([print_utils_1.line, print("condition")])])
|
|
20
|
+
], print("clauses").map(function (clause) { return (0, print_utils_1.group)(clause); }), true));
|
|
21
|
+
},
|
|
22
|
+
merge_when_clause: function (print, node) { return [
|
|
23
|
+
(0, print_utils_1.group)([
|
|
24
|
+
print.spaced(["whenKw", "matchedKw", "byKw"]),
|
|
25
|
+
node.condition ? (0, print_utils_1.indent)([print_utils_1.line, print("condition")]) : [],
|
|
26
|
+
[print_utils_1.line, print("thenKw")],
|
|
27
|
+
]),
|
|
28
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.group)(print("action"))]),
|
|
29
|
+
]; },
|
|
30
|
+
merge_when_condition: function (print) { return print.spaced(["andKw", "expr"]); },
|
|
31
|
+
merge_action_delete: function (print) { return print("deleteKw"); },
|
|
32
|
+
merge_action_insert: function (print, node) { return [
|
|
33
|
+
(0, print_utils_1.group)([
|
|
34
|
+
print("insertKw"),
|
|
35
|
+
node.columns ? (0, print_utils_1.indent)([print_utils_1.hardline, print("columns")]) : [],
|
|
36
|
+
]),
|
|
37
|
+
print_utils_1.line,
|
|
38
|
+
(0, print_utils_1.group)(print("values")),
|
|
39
|
+
]; },
|
|
40
|
+
merge_action_insert_row_clause: function (print) { return print("rowKw"); },
|
|
41
|
+
merge_action_update: function (print) { return print.spaced(["updateKw", "set"]); },
|
|
42
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
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.preparedStatementsMap = void 0;
|
|
13
|
+
var print_utils_1 = require("../print_utils");
|
|
14
|
+
exports.preparedStatementsMap = {
|
|
15
|
+
execute_stmt: function (print) {
|
|
16
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
|
|
17
|
+
(0, print_utils_1.group)([
|
|
18
|
+
print.spaced(["executeKw", "immediateKw"]),
|
|
19
|
+
(0, print_utils_1.indent)([print_utils_1.line, print("expr")]),
|
|
20
|
+
])
|
|
21
|
+
], print(["into", "using"]).map(function (clause) { return (0, print_utils_1.group)(clause); }), true));
|
|
22
|
+
},
|
|
23
|
+
execute_into_clause: function (print) { return print.spaced(["intoKw", "variables"]); },
|
|
24
|
+
execute_using_clause: function (print) { return print.spaced(["usingKw", "values"]); },
|
|
25
|
+
};
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.procClauseMap = void 0;
|
|
4
|
+
var node_utils_1 = require("../node_utils");
|
|
4
5
|
var print_utils_1 = require("../print_utils");
|
|
5
6
|
exports.procClauseMap = {
|
|
6
|
-
|
|
7
|
+
returns_clause: function (print) { return print.spaced(["returnsKw", "dataType"]); },
|
|
8
|
+
determinism_clause: function (print) { return print.spaced("deterministicKw"); },
|
|
9
|
+
language_clause: function (print) { return print.spaced(["languageKw", "name"]); },
|
|
10
|
+
as_clause: function (print, node) {
|
|
11
|
+
if ((0, node_utils_1.isStringLiteral)(node.expr)) {
|
|
12
|
+
return print.spaced(["asKw", "expr"]);
|
|
13
|
+
}
|
|
14
|
+
return [print("asKw"), (0, print_utils_1.indent)([print_utils_1.hardline, print("expr")])];
|
|
15
|
+
},
|
|
7
16
|
with_connection_clause: function (print) {
|
|
8
17
|
return print.spaced(["withConnectionKw", "connection"]);
|
|
9
18
|
},
|
|
@@ -1,12 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.proceduralLanguageMap = void 0;
|
|
4
13
|
var print_utils_1 = require("../print_utils");
|
|
5
14
|
exports.proceduralLanguageMap = {
|
|
6
|
-
|
|
15
|
+
// BEGIN .. END
|
|
16
|
+
block_stmt: function (print, node) { return [
|
|
7
17
|
print("beginKw"),
|
|
8
18
|
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
|
|
19
|
+
node.exception ? [print_utils_1.hardline, print("exception")] : [],
|
|
9
20
|
print_utils_1.hardline,
|
|
10
21
|
print("endKw"),
|
|
11
22
|
]; },
|
|
23
|
+
exception_clause: function (print) { return [
|
|
24
|
+
print.spaced(["exceptionKw", "whenKw", "condition", "thenKw"]),
|
|
25
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
|
|
26
|
+
]; },
|
|
27
|
+
error_category: function (print) { return print("errorKw"); },
|
|
28
|
+
// DECLARE
|
|
29
|
+
declare_stmt: function (print) {
|
|
30
|
+
return (0, print_utils_1.join)(" ", __spreadArray([
|
|
31
|
+
print("declareKw"),
|
|
32
|
+
(0, print_utils_1.group)(print("names"))
|
|
33
|
+
], print.spaced(["dataType", "default"]), true));
|
|
34
|
+
},
|
|
35
|
+
declare_default: function (print) { return print.spaced(["defaultKw", "expr"]); },
|
|
36
|
+
// SET
|
|
37
|
+
set_stmt: function (print) { return print.spaced(["setKw", "assignments"]); },
|
|
38
|
+
// IF
|
|
39
|
+
if_stmt: function (print) {
|
|
40
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray(__spreadArray([], print("clauses"), true), [print.spaced("endIfKw")], false));
|
|
41
|
+
},
|
|
42
|
+
if_clause: function (print) { return [
|
|
43
|
+
(0, print_utils_1.group)([
|
|
44
|
+
print("ifKw"),
|
|
45
|
+
(0, print_utils_1.indent)([print_utils_1.line, print("condition")]),
|
|
46
|
+
print_utils_1.line,
|
|
47
|
+
print("thenKw"),
|
|
48
|
+
]),
|
|
49
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("consequent"))]),
|
|
50
|
+
]; },
|
|
51
|
+
elseif_clause: function (print) { return [
|
|
52
|
+
(0, print_utils_1.group)([
|
|
53
|
+
print("elseifKw"),
|
|
54
|
+
(0, print_utils_1.indent)([print_utils_1.line, print("condition")]),
|
|
55
|
+
print_utils_1.line,
|
|
56
|
+
print("thenKw"),
|
|
57
|
+
]),
|
|
58
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("consequent"))]),
|
|
59
|
+
]; },
|
|
60
|
+
else_clause: function (print) { return [
|
|
61
|
+
print("elseKw"),
|
|
62
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("consequent"))]),
|
|
63
|
+
]; },
|
|
64
|
+
// CASE
|
|
65
|
+
case_stmt: function (print) { return [
|
|
66
|
+
print.spaced(["caseKw", "expr"]),
|
|
67
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))]),
|
|
68
|
+
print_utils_1.hardline,
|
|
69
|
+
print.spaced("endCaseKw"),
|
|
70
|
+
]; },
|
|
71
|
+
// LOOP
|
|
72
|
+
loop_stmt: function (print) { return [
|
|
73
|
+
print("loopKw"),
|
|
74
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
|
|
75
|
+
print_utils_1.hardline,
|
|
76
|
+
print.spaced("endLoopKw"),
|
|
77
|
+
]; },
|
|
78
|
+
// REPEAT
|
|
79
|
+
repeat_stmt: function (print) { return [
|
|
80
|
+
print("repeatKw"),
|
|
81
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
|
|
82
|
+
print_utils_1.hardline,
|
|
83
|
+
print.spaced(["untilKw", "condition", "endRepeatKw"]),
|
|
84
|
+
]; },
|
|
85
|
+
// WHILE
|
|
86
|
+
while_stmt: function (print) { return [
|
|
87
|
+
print.spaced(["whileKw", "condition", "doKw"]),
|
|
88
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
|
|
89
|
+
print_utils_1.hardline,
|
|
90
|
+
print.spaced("endWhileKw"),
|
|
91
|
+
]; },
|
|
92
|
+
// FOR .. IN
|
|
93
|
+
for_stmt: function (print) { return [
|
|
94
|
+
print.spaced(["forKw", "left", "inKw", "right", "doKw"]),
|
|
95
|
+
(0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
|
|
96
|
+
print_utils_1.hardline,
|
|
97
|
+
print.spaced("endForKw"),
|
|
98
|
+
]; },
|
|
99
|
+
// BREAK/CONTINUE
|
|
100
|
+
break_stmt: function (print) { return print.spaced(["breakKw", "label"]); },
|
|
101
|
+
continue_stmt: function (print) { return print.spaced(["continueKw", "label"]); },
|
|
102
|
+
labeled_stmt: function (print, node) { return [
|
|
103
|
+
print("beginLabel"),
|
|
104
|
+
": ",
|
|
105
|
+
print("statement"),
|
|
106
|
+
node.endLabel ? [" ", print(["endLabel"])] : [],
|
|
107
|
+
]; },
|
|
108
|
+
// CALL
|
|
109
|
+
call_stmt: function (print) { return print.spaced(["callKw", "func"]); },
|
|
110
|
+
// RETURN
|
|
111
|
+
return_stmt: function (print) { return print("returnKw"); },
|
|
112
|
+
// RAISE
|
|
113
|
+
raise_stmt: function (print) { return print.spaced(["raiseKw", "message"]); },
|
|
114
|
+
raise_message: function (print) { return [
|
|
115
|
+
print.spaced("usingMessageKw"),
|
|
116
|
+
" = ",
|
|
117
|
+
print("string"),
|
|
118
|
+
]; },
|
|
12
119
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.procedureMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.procedureMap = {
|
|
6
|
+
create_procedure_stmt: function (print, node) { return [
|
|
7
|
+
print.spaced([
|
|
8
|
+
"createKw",
|
|
9
|
+
"orReplaceKw",
|
|
10
|
+
"procedureKw",
|
|
11
|
+
"ifNotExistsKw",
|
|
12
|
+
"name",
|
|
13
|
+
]),
|
|
14
|
+
print("params"),
|
|
15
|
+
print_utils_1.hardline,
|
|
16
|
+
(0, print_utils_1.join)(print_utils_1.hardline, print("clauses").map(function (clause) { return (0, print_utils_1.group)(clause); })),
|
|
17
|
+
]; },
|
|
18
|
+
procedure_param: function (print) { return print.spaced(["mode", "name", "dataType"]); },
|
|
19
|
+
drop_procedure_stmt: function (print) {
|
|
20
|
+
return print.spaced(["dropKw", "procedureKw", "ifExistsKw", "name"]);
|
|
21
|
+
},
|
|
22
|
+
};
|
package/dist/syntax/program.js
CHANGED
|
@@ -3,19 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.programMap = void 0;
|
|
4
4
|
var print_utils_1 = require("../print_utils");
|
|
5
5
|
exports.programMap = {
|
|
6
|
-
program: function (print, node) {
|
|
6
|
+
program: function (print, node, path, options) {
|
|
7
7
|
return print("statements").map(function (doc, i) {
|
|
8
|
-
return printStatement(doc, i, node.statements);
|
|
8
|
+
return printStatement(doc, i, node.statements, options);
|
|
9
9
|
});
|
|
10
10
|
},
|
|
11
11
|
};
|
|
12
|
-
var printStatement = function (doc, i, statements) {
|
|
12
|
+
var printStatement = function (doc, i, statements, options) {
|
|
13
|
+
var prevNode = statements[i - 1];
|
|
13
14
|
var node = statements[i];
|
|
14
15
|
if (i === 0) {
|
|
15
16
|
return doc;
|
|
16
17
|
}
|
|
17
18
|
else if (node.type !== "empty") {
|
|
18
|
-
|
|
19
|
+
if ((0, print_utils_1.hasEmptyLineBetweenNodes)(prevNode, node, options)) {
|
|
20
|
+
return [";", print_utils_1.hardline, print_utils_1.hardline, doc];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return [";", print_utils_1.hardline, doc];
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
else {
|
|
21
27
|
return [";", print_utils_1.hardline, doc];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
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.schemaMap = void 0;
|
|
13
|
+
var print_utils_1 = require("../print_utils");
|
|
14
|
+
exports.schemaMap = {
|
|
15
|
+
create_schema_stmt: function (print) {
|
|
16
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
|
|
17
|
+
print.spaced(["createSchemaKw", "ifNotExistsKw", "name"])
|
|
18
|
+
], print("options"), true));
|
|
19
|
+
},
|
|
20
|
+
drop_schema_stmt: function (print) {
|
|
21
|
+
return print.spaced(["dropSchemaKw", "ifExistsKw", "name", "behaviorKw"]);
|
|
22
|
+
},
|
|
23
|
+
alter_schema_stmt: function (print) {
|
|
24
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
|
|
25
|
+
print.spaced(["alterSchemaKw", "ifExistsKw", "name"])
|
|
26
|
+
], print("actions"), true));
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -20,16 +20,22 @@ var bigquery_1 = require("./bigquery");
|
|
|
20
20
|
var constraint_1 = require("./constraint");
|
|
21
21
|
var create_table_1 = require("./create_table");
|
|
22
22
|
var data_type_1 = require("./data_type");
|
|
23
|
+
var dcl_1 = require("./dcl");
|
|
23
24
|
var delete_1 = require("./delete");
|
|
24
25
|
var drop_table_1 = require("./drop_table");
|
|
25
26
|
var explain_1 = require("./explain");
|
|
26
27
|
var expr_1 = require("./expr");
|
|
27
28
|
var frame_1 = require("./frame");
|
|
29
|
+
var function_1 = require("./function");
|
|
28
30
|
var index_1 = require("./index");
|
|
29
31
|
var insert_1 = require("./insert");
|
|
32
|
+
var merge_1 = require("./merge");
|
|
33
|
+
var prepared_statements_1 = require("./prepared_statements");
|
|
30
34
|
var procedural_language_1 = require("./procedural_language");
|
|
35
|
+
var procedure_1 = require("./procedure");
|
|
31
36
|
var proc_clause_1 = require("./proc_clause");
|
|
32
37
|
var program_1 = require("./program");
|
|
38
|
+
var schema_1 = require("./schema");
|
|
33
39
|
var select_1 = require("./select");
|
|
34
40
|
var sqlite_1 = require("./sqlite");
|
|
35
41
|
var transaction_1 = require("./transaction");
|
|
@@ -37,4 +43,4 @@ var trigger_1 = require("./trigger");
|
|
|
37
43
|
var truncate_1 = require("./truncate");
|
|
38
44
|
var update_1 = require("./update");
|
|
39
45
|
var view_1 = require("./view");
|
|
40
|
-
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({}, alias_1.aliasMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), bigquery_1.bigqueryMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), delete_1.deleteMap), drop_table_1.dropTableMap), explain_1.explainMap), expr_1.exprMap), frame_1.frameMap), index_1.indexMap), insert_1.insertMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), program_1.programMap), select_1.selectMap), sqlite_1.sqliteMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), update_1.updateMap), view_1.viewMap);
|
|
46
|
+
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({}, alias_1.aliasMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), bigquery_1.bigqueryMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), dcl_1.dclMap), delete_1.deleteMap), drop_table_1.dropTableMap), explain_1.explainMap), expr_1.exprMap), frame_1.frameMap), function_1.functionMap), index_1.indexMap), insert_1.insertMap), merge_1.mergeMap), prepared_statements_1.preparedStatementsMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), procedure_1.procedureMap), program_1.programMap), schema_1.schemaMap), select_1.selectMap), sqlite_1.sqliteMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), update_1.updateMap), view_1.viewMap);
|
package/dist/syntax/view.js
CHANGED
|
@@ -24,4 +24,9 @@ exports.viewMap = {
|
|
|
24
24
|
drop_view_stmt: function (print) {
|
|
25
25
|
return print.spaced(["dropKw", "materializedKw", "viewKw", "ifExistsKw", "views"]);
|
|
26
26
|
},
|
|
27
|
+
alter_view_stmt: function (print) { return [
|
|
28
|
+
print.spaced(["alterKw", "materializedKw", "viewKw", "ifExistsKw", "name"]),
|
|
29
|
+
print_utils_1.hardline,
|
|
30
|
+
(0, print_utils_1.join)(print_utils_1.hardline, print("actions")),
|
|
31
|
+
]; },
|
|
27
32
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sql-cst",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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.14.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jest": "^29.2.5",
|