prettier-plugin-sql-cst 0.10.0 → 0.10.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/README.md +15 -0
- package/dist/PrintFn.d.ts +2 -0
- package/dist/printSql.js +3 -2
- package/dist/syntax/alias.js +1 -1
- package/dist/syntax/constraint.js +1 -1
- package/dist/syntax/delete.js +1 -1
- package/dist/syntax/{bigquery.d.ts → dialects/bigquery.d.ts} +1 -1
- package/dist/syntax/{bigquery.js → dialects/bigquery.js} +1 -1
- package/dist/syntax/{mysql.d.ts → dialects/mysql.d.ts} +1 -1
- package/dist/syntax/{mysql.js → dialects/mysql.js} +1 -1
- package/dist/syntax/dialects/postgresql.d.ts +3 -0
- package/dist/syntax/dialects/postgresql.js +7 -0
- package/dist/syntax/{sqlite.d.ts → dialects/sqlite.d.ts} +1 -1
- package/dist/syntax/{sqlite.js → dialects/sqlite.js} +1 -1
- package/dist/syntax/expr.d.ts +1 -1
- package/dist/syntax/insert.js +6 -2
- package/dist/syntax/merge.js +7 -14
- package/dist/syntax/other_clauses.d.ts +3 -0
- package/dist/syntax/other_clauses.js +18 -0
- package/dist/syntax/rename_table.d.ts +3 -0
- package/dist/syntax/rename_table.js +13 -0
- package/dist/syntax/select.js +60 -33
- package/dist/syntax/transformMap.d.ts +1 -1
- package/dist/syntax/transformMap.js +7 -4
- package/dist/syntax/trigger.js +1 -1
- package/dist/syntax/truncate.js +14 -1
- package/dist/syntax/update.js +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -103,6 +103,20 @@ There are also some SQL-specific options:
|
|
|
103
103
|
| `sqlKeywordCase` | `upper` | Converts SQL keywords to `upper` or `lower` case, or `preserve` existing. |
|
|
104
104
|
| `sqlParamTypes` | `[]` | Array of bound parameter types: `?`, `?nr`, `:name`, `@name`, `$name`. |
|
|
105
105
|
|
|
106
|
+
## FAQ
|
|
107
|
+
|
|
108
|
+
### The SQL dialect I'm using is not supported. Can you add support for it?
|
|
109
|
+
|
|
110
|
+
Support for new SQL dialects depends on these dialects being supported by [sql-parser-cst][].
|
|
111
|
+
If you really want to, you can open a new issue for that in the parser repo.
|
|
112
|
+
But be aware that implementing parser support for new dialects takes a lot of work.
|
|
113
|
+
As long as the ongoing implementation of PostgreSQL, MySQL and MariaDB is not finished,
|
|
114
|
+
it's unlikely that work on any other dialect will start.
|
|
115
|
+
|
|
116
|
+
### How can I format SQL strings inside JavaScript files?
|
|
117
|
+
|
|
118
|
+
Use [prettier-plugin-embed][] together with `prettier-plugin-sql-cst`.
|
|
119
|
+
|
|
106
120
|
## Limitations and development status
|
|
107
121
|
|
|
108
122
|
Currently this plugin supports two SQL dialects:
|
|
@@ -132,4 +146,5 @@ Though the general principles should be mostly in place by now.
|
|
|
132
146
|
[useTabs]: https://prettier.io/docs/en/options.html#tabs
|
|
133
147
|
[sql-parser-cst]: https://github.com/nene/sql-parser-cst
|
|
134
148
|
[wadler-prettier]: http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
|
|
149
|
+
[prettier-plugin-embed]: https://github.com/Sec-ant/prettier-plugin-embed
|
|
135
150
|
[STYLE_GUIDE]: ./STYLE_GUIDE.md
|
package/dist/PrintFn.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type PrintFn<T, K = PrintableKey<T>> = {
|
|
|
8
8
|
(path: K[]): Doc[];
|
|
9
9
|
spaced(path: K): Doc[];
|
|
10
10
|
spaced(path: K[]): Doc[];
|
|
11
|
+
separated(separator: Doc, path: K): Doc[];
|
|
12
|
+
separated(separator: Doc, path: K[]): Doc[];
|
|
11
13
|
};
|
|
12
14
|
export type PrintableKey<T> = Exclude<keyof T, ReservedKey>;
|
|
13
15
|
type ReservedKey = "type" | "range" | "leading" | "trailing";
|
package/dist/printSql.js
CHANGED
|
@@ -28,7 +28,7 @@ function createPrintFn(path, oldPrint) {
|
|
|
28
28
|
return oldPrint(selector);
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
cachedPrintFn.
|
|
31
|
+
cachedPrintFn.separated = function (separator, selector) {
|
|
32
32
|
var node = path.getValue();
|
|
33
33
|
var docs = (0, utils_1.arrayWrap)(selector)
|
|
34
34
|
.filter(function (sel) { return (0, utils_1.isDefined)(node[sel]); })
|
|
@@ -43,8 +43,9 @@ function createPrintFn(path, oldPrint) {
|
|
|
43
43
|
var sel = _a[0], doc = _a[1];
|
|
44
44
|
return ((0, utils_1.isArray)(node[sel]) ? (0, print_utils_1.join)(" ", doc) : doc);
|
|
45
45
|
});
|
|
46
|
-
return docs.length > 0 ? [(0, print_utils_1.join)(
|
|
46
|
+
return docs.length > 0 ? [(0, print_utils_1.join)(separator, docs)] : [];
|
|
47
47
|
};
|
|
48
|
+
cachedPrintFn.spaced = function (selector) { return cachedPrintFn.separated(" ", selector); };
|
|
48
49
|
return cachedPrintFn;
|
|
49
50
|
}
|
|
50
51
|
function printNode(path, options, print) {
|
package/dist/syntax/alias.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.aliasMap = void 0;
|
|
4
4
|
exports.aliasMap = {
|
|
5
|
-
alias: function (print) { return print.spaced(["expr", "asKw", "alias"]); },
|
|
5
|
+
alias: function (print) { return print.spaced(["expr", "asKw", "alias", "columnAliases"]); },
|
|
6
6
|
};
|
|
@@ -24,7 +24,7 @@ exports.constraintMap = {
|
|
|
24
24
|
},
|
|
25
25
|
constraint_default: function (print) { return (0, print_utils_1.group)(print.spaced(["defaultKw", "expr"])); },
|
|
26
26
|
constraint_primary_key: function (print) {
|
|
27
|
-
return (0, print_utils_1.group)(print.spaced(["primaryKeyKw", "
|
|
27
|
+
return (0, print_utils_1.group)(print.spaced(["primaryKeyKw", "direction", "columns", "onConflict"]));
|
|
28
28
|
},
|
|
29
29
|
constraint_unique: function (print) {
|
|
30
30
|
return (0, print_utils_1.group)(print.spaced(["uniqueKw", "columns", "onConflict"]));
|
package/dist/syntax/delete.js
CHANGED
|
@@ -5,6 +5,6 @@ var print_utils_1 = require("../print_utils");
|
|
|
5
5
|
exports.deleteMap = {
|
|
6
6
|
delete_stmt: function (print) { return (0, print_utils_1.join)(print_utils_1.hardline, print("clauses")); },
|
|
7
7
|
delete_clause: function (print) {
|
|
8
|
-
return print.spaced(["deleteKw", "
|
|
8
|
+
return print.spaced(["deleteKw", "modifiers", "fromKw", "tables"]);
|
|
9
9
|
},
|
|
10
10
|
};
|
|
@@ -10,7 +10,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.bigqueryMap = void 0;
|
|
13
|
-
var print_utils_1 = require("
|
|
13
|
+
var print_utils_1 = require("../../print_utils");
|
|
14
14
|
exports.bigqueryMap = {
|
|
15
15
|
bigquery_options: function (print) { return print.spaced(["optionsKw", "options"]); },
|
|
16
16
|
bigquery_option_default_collate: function (print) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postgresqlMap = void 0;
|
|
4
|
+
exports.postgresqlMap = {
|
|
5
|
+
postgresql_operator_expr: function (print) { return print(["operatorKw", "expr"]); },
|
|
6
|
+
postgresql_operator: function (print) { return print("operator"); },
|
|
7
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sqliteMap = void 0;
|
|
4
|
-
var print_utils_1 = require("
|
|
4
|
+
var print_utils_1 = require("../../print_utils");
|
|
5
5
|
exports.sqliteMap = {
|
|
6
6
|
attach_database_stmt: function (print) {
|
|
7
7
|
return print.spaced(["attachKw", "databaseKw", "file", "asKw", "schema"]);
|
package/dist/syntax/expr.d.ts
CHANGED
package/dist/syntax/insert.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.insertMap = {
|
|
|
6
6
|
insert_stmt: function (print) { return (0, print_utils_1.join)(print_utils_1.hardline, print("clauses")); },
|
|
7
7
|
insert_clause: function (print, node) {
|
|
8
8
|
return (0, print_utils_1.group)([
|
|
9
|
-
print.spaced(["insertKw", "
|
|
9
|
+
print.spaced(["insertKw", "modifiers", "orAction", "intoKw", "table"]),
|
|
10
10
|
node.columns ? (0, print_utils_1.indent)([print_utils_1.hardline, print("columns")]) : [],
|
|
11
11
|
]);
|
|
12
12
|
},
|
|
@@ -17,7 +17,10 @@ exports.insertMap = {
|
|
|
17
17
|
default: function (print) { return print("defaultKw"); },
|
|
18
18
|
default_values: function (print) { return print.spaced("defaultValuesKw"); },
|
|
19
19
|
upsert_clause: function (print) {
|
|
20
|
-
return print.spaced(["onConflictKw", "
|
|
20
|
+
return print.spaced(["onConflictKw", "conflictTarget", "where", "doKw", "action"]);
|
|
21
|
+
},
|
|
22
|
+
conflict_target_on_constraint: function (print) {
|
|
23
|
+
return print.spaced(["onConstraintKw", "constraint"]);
|
|
21
24
|
},
|
|
22
25
|
upsert_action_nothing: function (print) { return print("nothingKw"); },
|
|
23
26
|
upsert_action_update: function (print) { return [
|
|
@@ -32,4 +35,5 @@ exports.insertMap = {
|
|
|
32
35
|
print.spaced("onDuplicateKeyUpdateKw"),
|
|
33
36
|
(0, print_utils_1.indent)([print_utils_1.hardline, print("assignments")]),
|
|
34
37
|
]; },
|
|
38
|
+
overriding_clause: function (print) { return print.spaced("overridingKw"); },
|
|
35
39
|
};
|
package/dist/syntax/merge.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.mergeMap = void 0;
|
|
13
4
|
var print_utils_1 = require("../print_utils");
|
|
14
5
|
exports.mergeMap = {
|
|
15
|
-
merge_stmt: function (print) {
|
|
16
|
-
|
|
6
|
+
merge_stmt: function (print) { return (0, print_utils_1.join)(print_utils_1.line, print("clauses")); },
|
|
7
|
+
merge_clause: function (print) {
|
|
8
|
+
return (0, print_utils_1.join)(print_utils_1.line, [
|
|
17
9
|
print.spaced(["mergeKw", "intoKw", "target"]),
|
|
18
10
|
print.spaced(["usingKw", "source"]),
|
|
19
|
-
(0, print_utils_1.group)([print("onKw"), (0, print_utils_1.indent)([print_utils_1.line, print("condition")])])
|
|
20
|
-
]
|
|
11
|
+
(0, print_utils_1.group)([print("onKw"), (0, print_utils_1.indent)([print_utils_1.line, print("condition")])]),
|
|
12
|
+
]);
|
|
21
13
|
},
|
|
22
14
|
merge_when_clause: function (print, node) { return [
|
|
23
15
|
(0, print_utils_1.group)([
|
|
@@ -35,8 +27,9 @@ exports.mergeMap = {
|
|
|
35
27
|
node.columns ? (0, print_utils_1.indent)([print_utils_1.hardline, print("columns")]) : [],
|
|
36
28
|
]),
|
|
37
29
|
print_utils_1.line,
|
|
38
|
-
(0, print_utils_1.
|
|
30
|
+
(0, print_utils_1.join)(print_utils_1.hardline, print("clauses")),
|
|
39
31
|
]; },
|
|
40
32
|
merge_action_insert_row_clause: function (print) { return print("rowKw"); },
|
|
41
33
|
merge_action_update: function (print) { return print.spaced(["updateKw", "set"]); },
|
|
34
|
+
merge_action_do_nothing: function (print) { return print.spaced(["doNothingKw"]); },
|
|
42
35
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.otherClausesMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.otherClausesMap = {
|
|
6
|
+
// CLUSTER BY clause
|
|
7
|
+
cluster_by_clause: function (print) {
|
|
8
|
+
return (0, print_utils_1.group)([print.spaced("clusterByKw"), (0, print_utils_1.indent)([print_utils_1.line, print("columns")])]);
|
|
9
|
+
},
|
|
10
|
+
// RETURNING clause
|
|
11
|
+
returning_clause: function (print) {
|
|
12
|
+
return (0, print_utils_1.group)([print("returningKw"), (0, print_utils_1.indent)([print_utils_1.line, print("columns")])]);
|
|
13
|
+
},
|
|
14
|
+
// WHERE CURRENT OF clause
|
|
15
|
+
where_current_of_clause: function (print) {
|
|
16
|
+
return print.spaced(["whereCurrentOfKw", "cursor"]);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renameTableMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
5
|
+
exports.renameTableMap = {
|
|
6
|
+
rename_table_stmt: function (print) {
|
|
7
|
+
return (0, print_utils_1.group)([
|
|
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"]); },
|
|
13
|
+
};
|
package/dist/syntax/select.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
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
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.selectMap = void 0;
|
|
13
4
|
var utils_1 = require("../utils");
|
|
@@ -27,19 +18,51 @@ exports.selectMap = {
|
|
|
27
18
|
(0, print_utils_1.indent)([print_utils_1.line, print("tables")]),
|
|
28
19
|
]);
|
|
29
20
|
},
|
|
30
|
-
common_table_expr: function (print) { return [
|
|
21
|
+
common_table_expr: function (print, node) { return [
|
|
31
22
|
print(["table", "columns"]),
|
|
32
23
|
" ",
|
|
33
24
|
print.spaced(["asKw", "materializedKw", "expr"]),
|
|
25
|
+
(0, print_utils_1.group)([
|
|
26
|
+
node.search || node.cycle
|
|
27
|
+
? (0, print_utils_1.indent)([print_utils_1.line, print.separated(print_utils_1.line, ["search", "cycle"])])
|
|
28
|
+
: [],
|
|
29
|
+
]),
|
|
34
30
|
]; },
|
|
31
|
+
cte_search_clause: function (print) {
|
|
32
|
+
return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, [
|
|
33
|
+
[print.spaced("searchKw"), (0, print_utils_1.group)((0, print_utils_1.indent)([print_utils_1.line, print("columns")]))],
|
|
34
|
+
print.spaced(["setKw", "resultColumn"]),
|
|
35
|
+
]));
|
|
36
|
+
},
|
|
37
|
+
cte_cycle_clause: function (print, node) {
|
|
38
|
+
return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.line, [
|
|
39
|
+
[print("cycleKw"), (0, print_utils_1.group)((0, print_utils_1.indent)([print_utils_1.line, print("columns")]))],
|
|
40
|
+
print.spaced(["setKw", "resultColumn"]),
|
|
41
|
+
node.values ? print("values") : undefined,
|
|
42
|
+
print.spaced(["usingKw", "pathColumn"]),
|
|
43
|
+
].filter(utils_1.isDefined)));
|
|
44
|
+
},
|
|
45
|
+
cte_cycle_clause_values: function (print) {
|
|
46
|
+
return (0, print_utils_1.join)(print_utils_1.line, [
|
|
47
|
+
print.spaced(["toKw", "markValue"]),
|
|
48
|
+
print.spaced(["defaultKw", "defaultValue"]),
|
|
49
|
+
]);
|
|
50
|
+
},
|
|
35
51
|
// SELECT clause
|
|
36
52
|
select_clause: function (print, node, path, opts) {
|
|
37
53
|
return (0, print_utils_1.group)([
|
|
38
|
-
print.spaced(["selectKw", "
|
|
54
|
+
print.spaced(["selectKw", "modifiers"]),
|
|
39
55
|
node.columns ? (0, print_utils_1.indent)([print_utils_1.line, print("columns")]) : [],
|
|
40
56
|
(0, print_utils_1.containsNewline)(node, opts) ? print_utils_1.breakParent : [],
|
|
41
57
|
]);
|
|
42
58
|
},
|
|
59
|
+
select_all: function (print) { return print.spaced(["allKw"]); },
|
|
60
|
+
select_distinct: function (print) { return print.spaced(["distinctKw"]); },
|
|
61
|
+
select_distinct_on: function (print) {
|
|
62
|
+
return (0, print_utils_1.group)([print.spaced(["distinctOnKw", "columns"])]);
|
|
63
|
+
},
|
|
64
|
+
select_as_struct: function (print) { return print.spaced(["asStructKw"]); },
|
|
65
|
+
select_as_value: function (print) { return print.spaced(["asValueKw"]); },
|
|
43
66
|
except_columns: function (print) { return print.spaced(["expr", "exceptKw", "columns"]); },
|
|
44
67
|
replace_columns: function (print) { return print.spaced(["expr", "replaceKw", "columns"]); },
|
|
45
68
|
// FROM clause
|
|
@@ -68,6 +91,8 @@ exports.selectMap = {
|
|
|
68
91
|
},
|
|
69
92
|
join_on_specification: function (print) { return (0, print_utils_1.group)(print.spaced(["onKw", "expr"])); },
|
|
70
93
|
join_using_specification: function (print) { return (0, print_utils_1.group)(print.spaced(["usingKw", "expr"])); },
|
|
94
|
+
table_with_inheritance: function (print) { return [print("table"), " ", "*"]; },
|
|
95
|
+
table_without_inheritance: function (print) { return print.spaced(["onlyKw", "table"]); },
|
|
71
96
|
indexed_table: function (print) { return print.spaced(["table", "indexedByKw", "index"]); },
|
|
72
97
|
not_indexed_table: function (print) { return print.spaced(["table", "notIndexedKw"]); },
|
|
73
98
|
unnest_expr: function (print) { return print(["unnestKw", "expr"]); },
|
|
@@ -97,9 +122,15 @@ exports.selectMap = {
|
|
|
97
122
|
]));
|
|
98
123
|
},
|
|
99
124
|
tablesample_expr: function (print) {
|
|
100
|
-
return (0, print_utils_1.group)([
|
|
125
|
+
return (0, print_utils_1.group)([
|
|
126
|
+
print("left"),
|
|
127
|
+
print_utils_1.line,
|
|
128
|
+
print.spaced(["tablesampleKw", "method", "args", "repeatable"]),
|
|
129
|
+
]);
|
|
101
130
|
},
|
|
131
|
+
tablesample_method: function (print) { return print.spaced(["methodKw"]); },
|
|
102
132
|
tablesample_percent: function (print) { return print.spaced(["percent", "percentKw"]); },
|
|
133
|
+
tablesample_repeatable: function (print) { return print.spaced(["repeatableKw", "seed"]); },
|
|
103
134
|
for_system_time_as_of_expr: function (print) {
|
|
104
135
|
return (0, print_utils_1.group)([print("left"), print_utils_1.line, print.spaced(["forSystemTimeAsOfKw", "expr"])]);
|
|
105
136
|
},
|
|
@@ -108,6 +139,11 @@ exports.selectMap = {
|
|
|
108
139
|
},
|
|
109
140
|
dual_table: function (print) { return print("dualKw"); },
|
|
110
141
|
lateral_derived_table: function (print) { return print.spaced(["lateralKw", "expr"]); },
|
|
142
|
+
rows_from_expr: function (print) { return print.spaced(["rowsFromKw", "expr"]); },
|
|
143
|
+
with_ordinality_expr: function (print) { return print.spaced(["expr", "withOrdinalityKw"]); },
|
|
144
|
+
func_call_with_column_definitions: function (print) {
|
|
145
|
+
return print.spaced(["funcCall", "asKw", "columns"]);
|
|
146
|
+
},
|
|
111
147
|
// WHERE clause
|
|
112
148
|
where_clause: function (print) {
|
|
113
149
|
return (0, print_utils_1.group)([print("whereKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
|
|
@@ -116,30 +152,29 @@ exports.selectMap = {
|
|
|
116
152
|
order_by_clause: function (print, node) {
|
|
117
153
|
return (0, print_utils_1.group)([
|
|
118
154
|
print.spaced("orderByKw"),
|
|
119
|
-
(0, print_utils_1.indent)([
|
|
120
|
-
print_utils_1.line,
|
|
121
|
-
(0, print_utils_1.join)(print_utils_1.line, __spreadArray([
|
|
122
|
-
print("specifications")
|
|
123
|
-
], (node.withRollupKw ? print.spaced("withRollupKw") : []), true)),
|
|
124
|
-
]),
|
|
155
|
+
(0, print_utils_1.indent)([print_utils_1.line, print.separated(print_utils_1.line, ["specifications", "withRollupKw"])]),
|
|
125
156
|
]);
|
|
126
157
|
},
|
|
127
158
|
sort_specification: function (print) {
|
|
128
|
-
return print.spaced(["expr", "
|
|
159
|
+
return print.spaced(["expr", "direction", "nullHandlingKw"]);
|
|
160
|
+
},
|
|
161
|
+
sort_direction_asc: function (print) { return print("ascKw"); },
|
|
162
|
+
sort_direction_desc: function (print) { return print("descKw"); },
|
|
163
|
+
sort_direction_using_operator: function (print) {
|
|
164
|
+
return print.spaced(["usingKw", "operator"]);
|
|
129
165
|
},
|
|
130
166
|
// GROUP BY clause
|
|
131
167
|
group_by_clause: function (print, node) {
|
|
132
168
|
return (0, print_utils_1.group)([
|
|
133
169
|
print.spaced(["groupByKw", "distinctKw"]),
|
|
134
|
-
(0, print_utils_1.indent)([
|
|
135
|
-
print_utils_1.line,
|
|
136
|
-
(0, print_utils_1.join)(print_utils_1.line, __spreadArray([
|
|
137
|
-
print("columns")
|
|
138
|
-
], (node.withRollupKw ? print.spaced("withRollupKw") : []), true)),
|
|
139
|
-
]),
|
|
170
|
+
(0, print_utils_1.indent)([print_utils_1.line, print.separated(print_utils_1.line, ["columns", "withRollupKw"])]),
|
|
140
171
|
]);
|
|
141
172
|
},
|
|
142
173
|
group_by_rollup: function (print) { return print(["rollupKw", "columns"]); },
|
|
174
|
+
group_by_cube: function (print) { return print(["cubeKw", "columns"]); },
|
|
175
|
+
group_by_grouping_sets: function (print) {
|
|
176
|
+
return print.spaced(["groupingSetsKw", "columns"]);
|
|
177
|
+
},
|
|
143
178
|
// PARTITION BY clause
|
|
144
179
|
partition_by_clause: function (print) {
|
|
145
180
|
return (0, print_utils_1.group)([
|
|
@@ -147,10 +182,6 @@ exports.selectMap = {
|
|
|
147
182
|
(0, print_utils_1.indent)([print_utils_1.line, print("specifications")]),
|
|
148
183
|
]);
|
|
149
184
|
},
|
|
150
|
-
// CLUSTER BY clause
|
|
151
|
-
cluster_by_clause: function (print) {
|
|
152
|
-
return (0, print_utils_1.group)([print.spaced("clusterByKw"), (0, print_utils_1.indent)([print_utils_1.line, print("columns")])]);
|
|
153
|
-
},
|
|
154
185
|
// HAVING clause
|
|
155
186
|
having_clause: function (print) {
|
|
156
187
|
return (0, print_utils_1.group)([print("havingKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
|
|
@@ -159,10 +190,6 @@ exports.selectMap = {
|
|
|
159
190
|
qualify_clause: function (print) {
|
|
160
191
|
return (0, print_utils_1.group)([print("qualifyKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]);
|
|
161
192
|
},
|
|
162
|
-
// RETURNING clause
|
|
163
|
-
returning_clause: function (print) {
|
|
164
|
-
return (0, print_utils_1.group)([print("returningKw"), (0, print_utils_1.indent)([print_utils_1.line, print("columns")])]);
|
|
165
|
-
},
|
|
166
193
|
// LIMIT clause
|
|
167
194
|
limit_clause: function (print, node) {
|
|
168
195
|
return (0, print_utils_1.group)([
|
|
@@ -16,7 +16,6 @@ var alias_1 = require("./alias");
|
|
|
16
16
|
var alter_table_1 = require("./alter_table");
|
|
17
17
|
var analyze_1 = require("./analyze");
|
|
18
18
|
var base_1 = require("./base");
|
|
19
|
-
var bigquery_1 = require("./bigquery");
|
|
20
19
|
var constraint_1 = require("./constraint");
|
|
21
20
|
var create_table_1 = require("./create_table");
|
|
22
21
|
var data_type_1 = require("./data_type");
|
|
@@ -30,7 +29,8 @@ var function_1 = require("./function");
|
|
|
30
29
|
var index_1 = require("./index");
|
|
31
30
|
var insert_1 = require("./insert");
|
|
32
31
|
var merge_1 = require("./merge");
|
|
33
|
-
var
|
|
32
|
+
var other_clauses_1 = require("./other_clauses");
|
|
33
|
+
var rename_table_1 = require("./rename_table");
|
|
34
34
|
var prepared_statements_1 = require("./prepared_statements");
|
|
35
35
|
var procedural_language_1 = require("./procedural_language");
|
|
36
36
|
var procedure_1 = require("./procedure");
|
|
@@ -38,10 +38,13 @@ var proc_clause_1 = require("./proc_clause");
|
|
|
38
38
|
var program_1 = require("./program");
|
|
39
39
|
var schema_1 = require("./schema");
|
|
40
40
|
var select_1 = require("./select");
|
|
41
|
-
var sqlite_1 = require("./sqlite");
|
|
42
41
|
var transaction_1 = require("./transaction");
|
|
43
42
|
var trigger_1 = require("./trigger");
|
|
44
43
|
var truncate_1 = require("./truncate");
|
|
45
44
|
var update_1 = require("./update");
|
|
46
45
|
var view_1 = require("./view");
|
|
47
|
-
|
|
46
|
+
var bigquery_1 = require("./dialects/bigquery");
|
|
47
|
+
var mysql_1 = require("./dialects/mysql");
|
|
48
|
+
var sqlite_1 = require("./dialects/sqlite");
|
|
49
|
+
var postgresql_1 = require("./dialects/postgresql");
|
|
50
|
+
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(__assign(__assign(__assign(__assign({}, alias_1.aliasMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), 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), other_clauses_1.otherClausesMap), prepared_statements_1.preparedStatementsMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), procedure_1.procedureMap), program_1.programMap), rename_table_1.renameTableMap), schema_1.schemaMap), select_1.selectMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), update_1.updateMap), view_1.viewMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), sqlite_1.sqliteMap);
|
package/dist/syntax/trigger.js
CHANGED
|
@@ -22,7 +22,7 @@ exports.triggerMap = {
|
|
|
22
22
|
"name",
|
|
23
23
|
]),
|
|
24
24
|
print("event")
|
|
25
|
-
],
|
|
25
|
+
], print.spaced(["forEachRowKw"]), true), print(["condition"]), true), [
|
|
26
26
|
print("body"),
|
|
27
27
|
], false));
|
|
28
28
|
},
|
package/dist/syntax/truncate.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.truncateMap = void 0;
|
|
4
|
+
var print_utils_1 = require("../print_utils");
|
|
4
5
|
exports.truncateMap = {
|
|
5
|
-
truncate_stmt: function (print) {
|
|
6
|
+
truncate_stmt: function (print) {
|
|
7
|
+
return (0, print_utils_1.group)([
|
|
8
|
+
print.spaced(["truncateKw", "tableKw"]),
|
|
9
|
+
(0, print_utils_1.indent)([
|
|
10
|
+
print_utils_1.line,
|
|
11
|
+
print.separated(print_utils_1.line, [
|
|
12
|
+
"tables",
|
|
13
|
+
"restartOrContinueKw",
|
|
14
|
+
"cascadeOrRestrictKw",
|
|
15
|
+
]),
|
|
16
|
+
]),
|
|
17
|
+
]);
|
|
18
|
+
},
|
|
6
19
|
};
|
package/dist/syntax/update.js
CHANGED
|
@@ -5,7 +5,7 @@ var print_utils_1 = require("../print_utils");
|
|
|
5
5
|
exports.updateMap = {
|
|
6
6
|
update_stmt: function (print) { return (0, print_utils_1.join)(print_utils_1.hardline, print("clauses")); },
|
|
7
7
|
update_clause: function (print) {
|
|
8
|
-
return print.spaced(["updateKw", "
|
|
8
|
+
return print.spaced(["updateKw", "modifiers", "orAction", "tables"]);
|
|
9
9
|
},
|
|
10
10
|
set_clause: function (print, node) {
|
|
11
11
|
if (node.assignments.items.length > 1) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sql-cst",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Prettier plugin for SQL",
|
|
5
5
|
"author": "Rene Saarsoo <nene@triin.net>",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"clean": "rm -rf dist",
|
|
23
23
|
"build": "yarn clean && tsc",
|
|
24
24
|
"test": "yarn node --experimental-vm-modules $(yarn bin jest)",
|
|
25
|
-
"pretty": "prettier -w src/ test/"
|
|
25
|
+
"pretty": "prettier -w src/ test/",
|
|
26
|
+
"ts:check": "tsc --noEmit"
|
|
26
27
|
},
|
|
27
28
|
"keywords": [
|
|
28
29
|
"prettier",
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
],
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"prettier": "^3.0.3",
|
|
34
|
-
"sql-parser-cst": "^0.
|
|
35
|
+
"sql-parser-cst": "^0.22.1"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/jest": "^29.2.5",
|