prettier-plugin-sql-cst 0.21.0 → 0.22.1
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 +2 -11
- package/dist/index.d.ts +0 -1
- package/dist/index.js +11 -24
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -119,6 +119,7 @@ The plugin provides the following parsers:
|
|
|
119
119
|
- `sqlite`
|
|
120
120
|
- `bigquery`
|
|
121
121
|
- `postgresql` (**experimental! expect crashes**)
|
|
122
|
+
- `plpgsql` (**experimental! expect crashes**)
|
|
122
123
|
- `mysql` (**experimental! expect crashes**)
|
|
123
124
|
- `mariadb` (**experimental! expect crashes**)
|
|
124
125
|
|
|
@@ -210,17 +211,6 @@ There are also several SQL-specific options:
|
|
|
210
211
|
|
|
211
212
|
_Since 0.13.0_
|
|
212
213
|
|
|
213
|
-
- **`sqlAcceptUnsupportedGrammar`**: `boolean` (default `false`)
|
|
214
|
-
|
|
215
|
-
Normally when the plugin encounters SQL syntax it doesn't support
|
|
216
|
-
it will throw an error and won't format anything at all.
|
|
217
|
-
With this option enabled, it will skip over SQL statements it doesn't recognize, leaving them as-is.
|
|
218
|
-
|
|
219
|
-
**Deprecated:** Use conditional comments `/* sql-parser-cst-disable */` and
|
|
220
|
-
`/* sql-parser-cst-enable */` instead.
|
|
221
|
-
|
|
222
|
-
_Since 0.12.0_
|
|
223
|
-
|
|
224
214
|
- **`sqlExperimentalPlpgsql`**: `boolean` (default `false`)
|
|
225
215
|
|
|
226
216
|
When enabled, the plugin will attempt to format PL/pgSQL function bodies.
|
|
@@ -269,6 +259,7 @@ Currently this plugin supports two SQL dialects:
|
|
|
269
259
|
It also has experimental support for the following dialects:
|
|
270
260
|
|
|
271
261
|
- PostgreSQL
|
|
262
|
+
- PL/pgSQL
|
|
272
263
|
- MySQL
|
|
273
264
|
- MariaDB
|
|
274
265
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ interface SqlPluginOptions {
|
|
|
10
10
|
sqlParamTypes: NonNullable<ParserOptions["paramTypes"]>;
|
|
11
11
|
sqlCanonicalSyntax: boolean;
|
|
12
12
|
sqlFinalSemicolon: boolean;
|
|
13
|
-
sqlAcceptUnsupportedGrammar: boolean;
|
|
14
13
|
sqlExperimentalPlpgsql: boolean;
|
|
15
14
|
}
|
|
16
15
|
declare const options: SupportOptions;
|
package/dist/index.js
CHANGED
|
@@ -1082,6 +1082,11 @@ var otherClausesMap = {
|
|
|
1082
1082
|
cluster_by_clause: (print) => group([print.spaced("clusterByKw"), indent([line, print("columns")])]),
|
|
1083
1083
|
// RETURNING clause
|
|
1084
1084
|
returning_clause: (print) => group([print("returningKw"), indent([line, print("columns")])]),
|
|
1085
|
+
// INTO clause
|
|
1086
|
+
into_variables_clause: (print) => group([
|
|
1087
|
+
print.spaced(["intoKw", "strictKw"]),
|
|
1088
|
+
indent([line, print("variables")])
|
|
1089
|
+
]),
|
|
1085
1090
|
as_clause: (print, node) => {
|
|
1086
1091
|
if (isStringLiteral(node.expr) || isDynamicallyLoadedFunction(node.expr)) {
|
|
1087
1092
|
return group(print.spaced(["asKw", "expr"]));
|
|
@@ -1200,7 +1205,6 @@ var preparedStatementsMap = {
|
|
|
1200
1205
|
print("executeKw"),
|
|
1201
1206
|
indent([line, print.separated(line, ["expr", "using"])])
|
|
1202
1207
|
]),
|
|
1203
|
-
execute_into_clause: (print) => print.spaced(["intoKw", "variables"]),
|
|
1204
1208
|
execute_using_clause: (print) => group([print("usingKw"), indent([line, print("values")])]),
|
|
1205
1209
|
// PREPARE
|
|
1206
1210
|
prepare_stmt: (print) => group(
|
|
@@ -1227,11 +1231,8 @@ var proceduralLanguageMap = {
|
|
|
1227
1231
|
chevron_label: (print) => ["<<", print("label"), ">>"],
|
|
1228
1232
|
// BEGIN .. END
|
|
1229
1233
|
block_stmt: (print, node) => group([
|
|
1230
|
-
stripTrailingHardline(print("
|
|
1231
|
-
[
|
|
1232
|
-
node.declareClause ? hardline : [],
|
|
1233
|
-
print.spaced(["beginKw", "atomicKw"])
|
|
1234
|
-
],
|
|
1234
|
+
stripTrailingHardline(print("declare")),
|
|
1235
|
+
[node.declare ? hardline : [], print.spaced(["beginKw", "atomicKw"])],
|
|
1235
1236
|
node.program.statements.length > 0 ? indent([hardline, stripTrailingHardline(print("program"))]) : print("program"),
|
|
1236
1237
|
node.exception ? [hardline, print("exception")] : [],
|
|
1237
1238
|
hardline,
|
|
@@ -1247,6 +1248,7 @@ var proceduralLanguageMap = {
|
|
|
1247
1248
|
])
|
|
1248
1249
|
),
|
|
1249
1250
|
declare_init: (print) => print.spaced(["operator", "expr"]),
|
|
1251
|
+
declare_alias_stmt: (print) => group(print.spaced(["newName", "aliasForKw", "oldName"])),
|
|
1250
1252
|
// EXCEPTION
|
|
1251
1253
|
exception_clause: (print, node) => {
|
|
1252
1254
|
if (node.clauses.length === 1) {
|
|
@@ -1707,7 +1709,6 @@ var selectMap = {
|
|
|
1707
1709
|
},
|
|
1708
1710
|
// INTO clause
|
|
1709
1711
|
into_table_clause: (print) => print.spaced(["intoKw", "kind", "tableKw", "name"]),
|
|
1710
|
-
into_variables_clause: (print) => group([print("intoKw"), indent([line, print("variables")])]),
|
|
1711
1712
|
into_dumpfile_clause: (print) => print.spaced(["intoDumpfileKw", "filename"]),
|
|
1712
1713
|
into_outfile_clause: (print, node) => {
|
|
1713
1714
|
const hasOptions = node.charset || node.fields || node.lines;
|
|
@@ -1904,11 +1905,6 @@ var typeMap = {
|
|
|
1904
1905
|
drop_type_stmt: (print) => group(print.spaced(["dropTypeKw", "ifExistsKw", "types", "behaviorKw"]))
|
|
1905
1906
|
};
|
|
1906
1907
|
|
|
1907
|
-
// src/syntax/unsupported_grammar.ts
|
|
1908
|
-
var unsupportedGrammarMap = {
|
|
1909
|
-
unsupported_grammar_stmt: (print) => group(print("text"))
|
|
1910
|
-
};
|
|
1911
|
-
|
|
1912
1908
|
// src/syntax/update.ts
|
|
1913
1909
|
var updateMap = {
|
|
1914
1910
|
update_stmt: (print) => group(join(print.dynamicLine(), print("clauses"))),
|
|
@@ -2142,7 +2138,6 @@ var transformMap = {
|
|
|
2142
2138
|
...triggerMap,
|
|
2143
2139
|
...truncateMap,
|
|
2144
2140
|
...typeMap,
|
|
2145
|
-
...unsupportedGrammarMap,
|
|
2146
2141
|
...updateMap,
|
|
2147
2142
|
...viewMap,
|
|
2148
2143
|
...bigqueryMap,
|
|
@@ -2204,10 +2199,10 @@ function printNode(path, options2, print) {
|
|
|
2204
2199
|
var printComment = (path) => {
|
|
2205
2200
|
const node = path.node;
|
|
2206
2201
|
if (node.type === "line_comment") {
|
|
2207
|
-
if (/^--[^ \t]/.test(node.text)) {
|
|
2202
|
+
if (/^--[^ \t-]/.test(node.text)) {
|
|
2208
2203
|
return node.text.replace(/^--/, "-- ");
|
|
2209
2204
|
}
|
|
2210
|
-
if (/^#[^ \t
|
|
2205
|
+
if (/^#[^ \t!#]/.test(node.text)) {
|
|
2211
2206
|
return node.text.replace(/^#/, "# ");
|
|
2212
2207
|
}
|
|
2213
2208
|
}
|
|
@@ -2648,13 +2643,6 @@ var options = {
|
|
|
2648
2643
|
description: "Enforces a semicolon at the end of last SQL statement"
|
|
2649
2644
|
// Since 0.13.0
|
|
2650
2645
|
},
|
|
2651
|
-
sqlAcceptUnsupportedGrammar: {
|
|
2652
|
-
type: "boolean",
|
|
2653
|
-
category: "SQL",
|
|
2654
|
-
default: false,
|
|
2655
|
-
description: "Skips formatting unsupported SQL statements instead of exiting with an error"
|
|
2656
|
-
// Since 0.12.0
|
|
2657
|
-
},
|
|
2658
2646
|
sqlExperimentalPlpgsql: {
|
|
2659
2647
|
type: "boolean",
|
|
2660
2648
|
category: "SQL",
|
|
@@ -2704,8 +2692,7 @@ var createParser = (dialect) => ({
|
|
|
2704
2692
|
includeRange: true,
|
|
2705
2693
|
includeComments: true,
|
|
2706
2694
|
filename: options2.filepath,
|
|
2707
|
-
paramTypes: options2.sqlParamTypes
|
|
2708
|
-
acceptUnsupportedGrammar: options2.sqlAcceptUnsupportedGrammar
|
|
2695
|
+
paramTypes: options2.sqlParamTypes
|
|
2709
2696
|
}),
|
|
2710
2697
|
text,
|
|
2711
2698
|
options2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sql-cst",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"description": "Prettier plugin for SQL",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Barna Magyarkuti <bmagyarkuti@gmail.com>",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"prettier": "^3.0.3",
|
|
42
|
-
"sql-parser-cst": "^0.
|
|
42
|
+
"sql-parser-cst": "^0.42.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/jest": "^30.0.0",
|