prettier-plugin-sql-cst
Advanced tools
Comparing version 0.11.7 to 0.11.8
@@ -94,2 +94,42 @@ "use strict"; | ||
}, | ||
alter_action_add_enum_value: function (print) { | ||
return print.spaced(["addValueKw", "ifNotExistsKw", "value", "position"]); | ||
}, | ||
alter_action_add_enum_value_position: function (print) { | ||
return print.spaced(["positionKw", "value"]); | ||
}, | ||
alter_action_rename_enum_value: function (print) { | ||
return print.spaced(["renameValueKw", "oldValue", "toKw", "newValue"]); | ||
}, | ||
alter_action_add_attribute: function (print) { | ||
return print.spaced([ | ||
"addAttributeKw", | ||
"name", | ||
"dataType", | ||
"constraint", | ||
"behaviorKw", | ||
]); | ||
}, | ||
alter_action_drop_attribute: function (print) { | ||
return print.spaced(["dropAttributeKw", "ifExistsKw", "name", "behaviorKw"]); | ||
}, | ||
alter_action_alter_attribute: function (print) { | ||
return print.spaced([ | ||
"alterAttributeKw", | ||
"name", | ||
"setDataTypeKw", | ||
"dataType", | ||
"constraint", | ||
"behaviorKw", | ||
]); | ||
}, | ||
alter_action_rename_attribute: function (print) { | ||
return print.spaced([ | ||
"renameAttributeKw", | ||
"oldName", | ||
"toKw", | ||
"newName", | ||
"behaviorKw", | ||
]); | ||
}, | ||
// ALTER COLUMN | ||
@@ -96,0 +136,0 @@ alter_action_alter_column: function (print) { |
@@ -9,3 +9,3 @@ "use strict"; | ||
named_data_type: function (print, node) { | ||
return ((0, utils_1.isArray)(node.nameKw) ? print.spaced : print)(["nameKw", "params"]); | ||
return ((0, utils_1.isArray)(node.name) ? print.spaced : print)(["name", "params"]); | ||
}, | ||
@@ -12,0 +12,0 @@ array_data_type: function (print) { return print(["dataType", "bounds"]); }, |
@@ -131,3 +131,7 @@ "use strict"; | ||
cast_format_timezone: function (print) { return print.spaced(["atTimeZoneKw", "timezone"]); }, | ||
cast_operator_expr: function (print) { return [print("expr"), "::", print("dataType")]; }, | ||
cast_operator_expr: function (print) { return [ | ||
print("left"), | ||
print("operator"), | ||
print("right"), | ||
]; }, | ||
string_with_charset: function (print) { return ["_", print(["charset", "string"])]; }, | ||
@@ -134,0 +138,0 @@ raise_expr: function (print) { return print(["raiseKw", "args"]); }, |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.functionMap = { | ||
/** cst-ignore: behaviorKw */ | ||
create_function_stmt: function (print, node) { return [ | ||
@@ -69,3 +68,2 @@ print.spaced([ | ||
reset_parameter_clause: function (print) { return print.spaced(["resetKw", "name"]); }, | ||
/** cst-ignore: name */ | ||
reset_all_parameters_clause: function (print) { return print.spaced("resetAllKw"); }, | ||
@@ -72,0 +70,0 @@ }; |
@@ -25,2 +25,3 @@ "use strict"; | ||
var delete_1 = require("./delete"); | ||
var domain_1 = require("./domain"); | ||
var drop_table_1 = require("./drop_table"); | ||
@@ -47,2 +48,3 @@ var explain_1 = require("./explain"); | ||
var truncate_1 = require("./truncate"); | ||
var type_1 = require("./type"); | ||
var update_1 = require("./update"); | ||
@@ -54,2 +56,2 @@ var view_1 = require("./view"); | ||
var postgresql_1 = require("./dialects/postgresql"); | ||
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(__assign(__assign({}, alias_1.aliasMap), alter_action_1.alterActionMap), 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), sequence_1.sequenceMap), 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); | ||
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(__assign(__assign(__assign(__assign({}, alias_1.aliasMap), alter_action_1.alterActionMap), 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), domain_1.domainMap), 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), sequence_1.sequenceMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), type_1.typeMap), update_1.updateMap), view_1.viewMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), sqlite_1.sqliteMap); |
{ | ||
"name": "prettier-plugin-sql-cst", | ||
"version": "0.11.7", | ||
"version": "0.11.8", | ||
"description": "Prettier plugin for SQL", | ||
@@ -39,3 +39,3 @@ "contributors": [ | ||
"prettier": "^3.0.3", | ||
"sql-parser-cst": "^0.28.1" | ||
"sql-parser-cst": "^0.29.1" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
@@ -63,2 +63,6 @@ # 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) | ||
npm install --save-dev prettier prettier-plugin-sql-cst | ||
# or | ||
pnpm add --save-dev prettier prettier-plugin-sql-cst | ||
# or | ||
yarn add --dev prettier prettier-plugin-sql-cst | ||
``` | ||
@@ -76,6 +80,7 @@ | ||
You can override this behavior with a prettier configuration: | ||
You can override this behavior with a prettier configuration in `.prettierrc.json` file: | ||
```json | ||
{ | ||
"plugins": ["prettier-plugin-sql-cst"], | ||
"overrides": [ | ||
@@ -90,2 +95,18 @@ { | ||
Or you could also store it inside your `package.json`: | ||
```json | ||
{ | ||
"prettier": { | ||
"plugins": ["prettier-plugin-sql-cst"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.sql"], | ||
"options": { "parser": "bigquery" } | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
The plugin provides the following parsers: | ||
@@ -110,2 +131,19 @@ | ||
## Usage inside VSCode | ||
To use this plugin inside VSCode, | ||
install the [Prettier VSCode](https://github.com/prettier/prettier-vscode?tab=readme-ov-file#installation) extension. | ||
Follow [Prettier VSCode docs](https://github.com/prettier/prettier-vscode?tab=readme-ov-file#default-formatter) | ||
to configure it as the default formatter. | ||
You might also need to configure | ||
[prettier.documentSelectors](https://github.com/prettier/prettier-vscode?tab=readme-ov-file#prettierdocumentselectors) | ||
to enable Prettier for `*.sql` files. | ||
To see what Prettier is, or is not doing - open the VSCode Output window and select the Prettier dropdown. | ||
On format, the window should show your `inferredParser`. It should reconfirm that by showing `"parser": "sqlite"` | ||
(or whichever perser you have configured inside your prettier config `overrides` section) | ||
and `plugins` with the path to this package. If you don't see that part, Prettier not using this package. | ||
## FAQ | ||
@@ -112,0 +150,0 @@ |
181248
125
3056
190
+ Addedsql-parser-cst@0.29.1(transitive)
- Removedsql-parser-cst@0.28.1(transitive)
Updatedsql-parser-cst@^0.29.1