prettier-plugin-sql-cst
Advanced tools
Comparing version 0.5.0 to 0.6.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isAsClause = exports.isArraySubscript = exports.isStringLiteral = exports.isJsonLiteral = exports.isEmpty = exports.isKeyword = exports.isCreateTableStmt = exports.isFuncCall = exports.isValuesClause = void 0; | ||
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; | ||
var utils_1 = require("./utils"); | ||
@@ -12,2 +12,3 @@ var is = function (type) { | ||
exports.isFuncCall = is("func_call"); | ||
exports.isFuncArgs = is("func_args"); | ||
exports.isCreateTableStmt = is("create_table_stmt"); | ||
@@ -20,1 +21,3 @@ exports.isKeyword = is("keyword"); | ||
exports.isAsClause = is("as_clause"); | ||
exports.isParenExpr = is("paren_expr"); | ||
exports.isListExpr = is("list_expr"); |
@@ -28,2 +28,3 @@ "use strict"; | ||
"snapshotKw", | ||
"virtualKw", | ||
"tableKw", | ||
@@ -48,2 +49,3 @@ "ifNotExistsKw", | ||
}, | ||
create_table_using_clause: function (print) { return print.spaced(["usingKw", "module"]); }, | ||
}; | ||
@@ -50,0 +52,0 @@ var printClauses = function (print, node) { |
@@ -36,2 +36,11 @@ "use strict"; | ||
paren_expr: function (print, node, path) { | ||
// discard unnecessary nested ((parentheses)) | ||
if ((0, node_utils_1.isParenExpr)(node.expr)) { | ||
return print("expr"); | ||
} | ||
// Discard unnecessary parenthesis around function arguments | ||
if ((0, node_utils_1.isListExpr)(path.getParentNode(0)) && | ||
(0, node_utils_1.isFuncArgs)(path.getParentNode(1))) { | ||
return print("expr"); | ||
} | ||
var parent = path.getParentNode(); | ||
@@ -88,4 +97,7 @@ var lineStyle = (0, node_utils_1.isCreateTableStmt)(parent) ? print_utils_1.hardline : print_utils_1.softline; | ||
cast_expr: function (print) { return print(["castKw", "args"]); }, | ||
cast_arg: function (print) { return print.spaced(["expr", "asKw", "dataType"]); }, | ||
cast_arg: function (print) { return print.spaced(["expr", "asKw", "dataType", "format"]); }, | ||
cast_format: function (print) { return print.spaced(["formatKw", "string", "timezone"]); }, | ||
cast_format_timezone: function (print) { return print.spaced(["atTimeZoneKw", "timezone"]); }, | ||
raise_expr: function (print) { return print(["raiseKw", "args"]); }, | ||
raise_expr_type: function (print) { return print("typeKw"); }, | ||
interval_expr: function (print) { return print.spaced(["intervalKw", "expr", "unit"]); }, | ||
@@ -114,2 +126,3 @@ interval_unit_range: function (print) { | ||
identifier: function (print) { return print("text"); }, | ||
variable: function (print) { return print("text"); }, | ||
}; | ||
@@ -116,0 +129,0 @@ var isBooleanOp = function (_a) { |
@@ -19,8 +19,2 @@ "use strict"; | ||
pragma_func_call: function (print) { return print(["name", "args"]); }, | ||
create_virtual_table_stmt: function (print) { | ||
return (0, print_utils_1.join)(print_utils_1.hardline, [ | ||
print.spaced(["createVirtualTableKw", "ifNotExistsKw", "name"]), | ||
print.spaced(["usingKw", "module"]), | ||
]); | ||
}, | ||
}; |
@@ -24,3 +24,3 @@ "use strict"; | ||
]), | ||
(0, print_utils_1.group)([print("event"), (0, print_utils_1.indent)([print_utils_1.line, print.spaced(["onKw", "table"])])]) | ||
print("event") | ||
], (node.forEachRowKw ? [print.spaced(["forEachRowKw"])] : []), true), (node.condition ? [print(["condition"])] : []), true), [ | ||
@@ -30,6 +30,11 @@ print("body"), | ||
}, | ||
trigger_event: function (print, node) { return [ | ||
print.spaced(["timeKw", "eventKw", "ofKw"]), | ||
node.columns ? (0, print_utils_1.indent)([print_utils_1.line, print("columns")]) : [], | ||
]; }, | ||
trigger_event: function (print) { | ||
return (0, print_utils_1.group)([ | ||
print.spaced(["timeKw", "eventKw", "ofKw"]), | ||
(0, print_utils_1.indent)([ | ||
print_utils_1.line, | ||
(0, print_utils_1.join)(print_utils_1.line, __spreadArray(__spreadArray([], print(["columns"]), true), [print.spaced(["onKw", "table"])], false)), | ||
]), | ||
]); | ||
}, | ||
trigger_condition: function (print) { | ||
@@ -36,0 +41,0 @@ return (0, print_utils_1.group)([print("whenKw"), (0, print_utils_1.indent)([print_utils_1.line, print("expr")])]); |
{ | ||
"name": "prettier-plugin-sql-cst", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Prettier plugin for SQL", | ||
@@ -32,3 +32,3 @@ "author": "Rene Saarsoo <nene@triin.net>", | ||
"prettier": "^2.8.2", | ||
"sql-parser-cst": "^0.12.0" | ||
"sql-parser-cst": "^0.13.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "devDependencies": { |
@@ -52,3 +52,2 @@ # Prettier plugin SQL-CST [![npm version](https://img.shields.io/npm/v/prettier-plugin-sql-cst)](https://www.npmjs.com/package/prettier-plugin-sql-cst) ![build status](https://github.com/nene/prettier-plugin-sql-cst/actions/workflows/build.yml/badge.svg) | ||
and concentrates mainly on the layout of whitespace. | ||
For example it does not add/remove paratheses. | ||
@@ -55,0 +54,0 @@ See [STYLE_GUIDE][] for overview of the SQL formatting style used. |
92784
1222
122
+ Addedsql-parser-cst@0.13.0(transitive)
- Removedsql-parser-cst@0.12.1(transitive)
Updatedsql-parser-cst@^0.13.0