prettier-plugin-sql-cst 0.9.0 → 0.9.2
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
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Node } from "sql-parser-cst";
|
|
2
2
|
import { Parser, Printer, SupportLanguage } from "prettier";
|
|
3
3
|
export { options } from "./options";
|
|
4
|
+
export type { SqlPluginOptions } from "./options";
|
|
4
5
|
export declare const languages: SupportLanguage[];
|
|
5
6
|
export declare const parsers: Record<string, Parser<Node>>;
|
|
6
7
|
export declare const printers: Record<string, Printer>;
|
package/dist/syntax/data_type.js
CHANGED
|
@@ -5,7 +5,7 @@ var utils_1 = require("../utils");
|
|
|
5
5
|
var print_utils_1 = require("../print_utils");
|
|
6
6
|
exports.dataTypeMap = {
|
|
7
7
|
// print single-word types as `TYPE(10)` and multi-word types as `MY TYPE (10)`
|
|
8
|
-
|
|
8
|
+
named_data_type: function (print, node) {
|
|
9
9
|
return ((0, utils_1.isArray)(node.nameKw) ? print.spaced : print)(["nameKw", "params"]);
|
|
10
10
|
},
|
|
11
11
|
generic_type_params: function (print) {
|
package/dist/syntax/insert.js
CHANGED
|
@@ -3,13 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.insertMap = void 0;
|
|
4
4
|
var print_utils_1 = require("../print_utils");
|
|
5
5
|
exports.insertMap = {
|
|
6
|
-
insert_stmt: function (print
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
insert_stmt: function (print, node) {
|
|
7
|
+
// When there's a columns clause, we want to indent it,
|
|
8
|
+
// but that only works when there's a newline inside it.
|
|
9
|
+
// So we have to avoid adding a newline before columns clause.
|
|
10
|
+
var columnsClauseIndex = node.clauses.findIndex(function (clause) { return clause.type === "insert_columns_clause"; });
|
|
11
|
+
if (columnsClauseIndex !== -1) {
|
|
12
|
+
var printedClauses = print("clauses");
|
|
13
|
+
var before = printedClauses.slice(0, columnsClauseIndex);
|
|
14
|
+
var columnsClause = printedClauses[columnsClauseIndex];
|
|
15
|
+
var after = printedClauses.slice(columnsClauseIndex + 1);
|
|
16
|
+
return [
|
|
17
|
+
(0, print_utils_1.join)(print_utils_1.hardline, before),
|
|
18
|
+
columnsClause,
|
|
19
|
+
after.length > 0 ? [print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, after)] : [],
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return (0, print_utils_1.join)(print_utils_1.hardline, print("clauses"));
|
|
24
|
+
}
|
|
12
25
|
},
|
|
26
|
+
insert_clause: function (print) {
|
|
27
|
+
return (0, print_utils_1.group)([print.spaced(["insertKw", "orAction", "intoKw", "table"])]);
|
|
28
|
+
},
|
|
29
|
+
insert_columns_clause: function (print) { return (0, print_utils_1.indent)([print_utils_1.hardline, print("columns")]); },
|
|
13
30
|
values_clause: function (print) {
|
|
14
31
|
return (0, print_utils_1.group)([print("valuesKw"), (0, print_utils_1.indent)([print_utils_1.hardline, print("values")])]);
|
|
15
32
|
},
|
package/dist/syntax/truncate.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.truncateMap = void 0;
|
|
4
4
|
exports.truncateMap = {
|
|
5
|
-
truncate_stmt: function (print) { return print.spaced(["
|
|
5
|
+
truncate_stmt: function (print) { return print.spaced(["truncateKw", "tableKw", "table"]); },
|
|
6
6
|
};
|
|
@@ -9,7 +9,7 @@ var stripTrailingCommas = function (cst) {
|
|
|
9
9
|
// Trailing comma is represented as an empty element at the end of column list
|
|
10
10
|
var removeLastEmptyColumn = (0, sql_parser_cst_1.cstVisitor)({
|
|
11
11
|
select_clause: function (node) {
|
|
12
|
-
if ((0, node_utils_1.isEmpty)((0, utils_1.last)(node.columns.items))) {
|
|
12
|
+
if (node.columns && (0, node_utils_1.isEmpty)((0, utils_1.last)(node.columns.items))) {
|
|
13
13
|
node.columns.items = node.columns.items.slice(0, -1);
|
|
14
14
|
}
|
|
15
15
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sql-cst",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Prettier plugin for SQL",
|
|
5
5
|
"author": "Rene Saarsoo <nene@triin.net>",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"prettier": "^3.0.3",
|
|
34
|
-
"sql-parser-cst": "^0.
|
|
34
|
+
"sql-parser-cst": "^0.19.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jest": "^29.2.5",
|