Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettier-plugin-sql-cst

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-sql-cst - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

dist/embed.js

5

dist/index.js

@@ -6,3 +6,3 @@ "use strict";

var printSql_1 = require("./printSql");
var embedJson_1 = require("./embedJson");
var embed_1 = require("./embed");
var utils_1 = require("./utils");

@@ -31,2 +31,3 @@ var transformCst_1 = require("./transform/transformCst");

filename: options.filepath,
paramTypes: options.sqlParamTypes,
}), text);

@@ -45,3 +46,3 @@ },

print: printSql_1.printSql,
embed: embedJson_1.embedJson,
embed: embed_1.embed,
printComment: function (path) {

@@ -48,0 +49,0 @@ return path.getValue().text;

4

dist/node_utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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;
exports.isLanguageClause = exports.isCreateFunctionStmt = 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");

@@ -22,1 +22,3 @@ var is = function (type) {

exports.isListExpr = is("list_expr");
exports.isCreateFunctionStmt = is("create_function_stmt");
exports.isLanguageClause = is("language_clause");

@@ -20,2 +20,11 @@ "use strict";

},
sqlParamTypes: {
type: "string",
array: true,
category: "SQL",
since: "0.7.0",
default: [{ value: [] }],
description: "Syntax for bound parameters",
// Possible values in array: "?" | "?nr" | ":name" | "$name" | "@name"
},
};
"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.bigqueryMap = void 0;
var print_utils_1 = require("../print_utils");
exports.bigqueryMap = {

@@ -9,2 +19,77 @@ bigquery_options: function (print) { return print(["optionsKw", "options"]); },

},
// ROW ACCESS POLICY
create_row_access_policy_stmt: function (print) {
return (0, print_utils_1.join)(print_utils_1.hardline, __spreadArray([
print.spaced([
"createKw",
"orReplaceKw",
"rowAccessPolicyKw",
"ifNotExistsKw",
"name",
"onKw",
"table",
])
], print("clauses"), true));
},
row_access_policy_grant_clause: function (print) {
return print.spaced(["grantToKw", "grantees"]);
},
row_access_policy_filter_clause: function (print) {
return print.spaced(["filterUsingKw", "expr"]);
},
drop_row_access_policy_stmt: function (print) {
return print.spaced([
"dropKw",
"allKw",
"rowAccessPolicyKw",
"ifExistsKw",
"name",
"onKw",
"table",
]);
},
// CAPACITY
create_capacity_stmt: function (print) { return [
print.spaced(["createKw", "capacityKw", "name"]),
print_utils_1.hardline,
print("options"),
]; },
drop_capacity_stmt: function (print) {
return print.spaced(["dropKw", "capacityKw", "ifExistsKw", "name"]);
},
// RESERVATION
create_reservation_stmt: function (print) { return [
print.spaced(["createKw", "reservationKw", "name"]),
print_utils_1.hardline,
print("options"),
]; },
drop_reservation_stmt: function (print) {
return print.spaced(["dropKw", "reservationKw", "ifExistsKw", "name"]);
},
// ASSIGNMENT
create_assignment_stmt: function (print) { return [
print.spaced(["createKw", "assignmentKw", "name"]),
print_utils_1.hardline,
print("options"),
]; },
drop_assignment_stmt: function (print) {
return print.spaced(["dropKw", "assignmentKw", "ifExistsKw", "name"]);
},
// ALTER ORGANIZATION
alter_organization_stmt: function (print) {
return (0, print_utils_1.join)(print_utils_1.hardline, [print.spaced("alterOrganizationKw"), print("actions")]);
},
// ALTER PROJECT
alter_project_stmt: function (print) {
return (0, print_utils_1.join)(print_utils_1.hardline, [
print.spaced(["alterProjectKw", "name"]),
print("actions"),
]);
},
alter_bi_capacity_stmt: function (print) {
return (0, print_utils_1.join)(print_utils_1.hardline, [
print.spaced(["alterBiCapacityKw", "name"]),
print("actions"),
]);
},
};

@@ -125,2 +125,3 @@ "use strict";

variable: function (print) { return print("text"); },
parameter: function (print) { return print("text"); },
};

@@ -127,0 +128,0 @@ var isBooleanOp = function (_a) {

@@ -30,4 +30,13 @@ "use strict";

drop_index_stmt: function (print) {
return print.spaced(["dropKw", "indexKw", "ifExistsKw", "indexes"]);
return print.spaced([
"dropKw",
"indexTypeKw",
"indexKw",
"ifExistsKw",
"indexes",
"onKw",
"table",
]);
},
verbose_all_columns: function (print) { return print.spaced("allColumnsKw"); },
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.procClauseMap = void 0;
var node_utils_1 = require("../node_utils");
var print_utils_1 = require("../print_utils");
exports.procClauseMap = {
as_clause: function (print) { return [print("asKw"), (0, print_utils_1.indent)([print_utils_1.hardline, print("expr")])]; },
returns_clause: function (print) { return print.spaced(["returnsKw", "dataType"]); },
determinism_clause: function (print) { return print.spaced("deterministicKw"); },
language_clause: function (print) { return print.spaced(["languageKw", "name"]); },
as_clause: function (print, node) {
if ((0, node_utils_1.isStringLiteral)(node.expr)) {
return print.spaced(["asKw", "expr"]);
}
return [print("asKw"), (0, print_utils_1.indent)([print_utils_1.hardline, print("expr")])];
},
with_connection_clause: function (print) {

@@ -8,0 +17,0 @@ return print.spaced(["withConnectionKw", "connection"]);

@@ -28,7 +28,11 @@ "use strict";

var frame_1 = require("./frame");
var function_1 = require("./function");
var index_1 = require("./index");
var insert_1 = require("./insert");
var merge_1 = require("./merge");
var procedural_language_1 = require("./procedural_language");
var procedure_1 = require("./procedure");
var proc_clause_1 = require("./proc_clause");
var program_1 = require("./program");
var schema_1 = require("./schema");
var select_1 = require("./select");

@@ -41,2 +45,2 @@ var sqlite_1 = require("./sqlite");

var view_1 = require("./view");
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({}, alias_1.aliasMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), bigquery_1.bigqueryMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), delete_1.deleteMap), drop_table_1.dropTableMap), explain_1.explainMap), expr_1.exprMap), frame_1.frameMap), index_1.indexMap), insert_1.insertMap), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), program_1.programMap), select_1.selectMap), sqlite_1.sqliteMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), update_1.updateMap), view_1.viewMap);
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({}, alias_1.aliasMap), alter_table_1.alterTableMap), analyze_1.analyzeMap), base_1.baseMap), bigquery_1.bigqueryMap), constraint_1.constraintMap), create_table_1.createTableMap), data_type_1.dataTypeMap), 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), proc_clause_1.procClauseMap), procedural_language_1.proceduralLanguageMap), procedure_1.procedureMap), program_1.programMap), schema_1.schemaMap), select_1.selectMap), sqlite_1.sqliteMap), transaction_1.transactionMap), trigger_1.triggerMap), truncate_1.truncateMap), update_1.updateMap), view_1.viewMap);

@@ -27,2 +27,7 @@ "use strict";

},
alter_view_stmt: function (print) { return [
print.spaced(["alterKw", "materializedKw", "viewKw", "ifExistsKw", "name"]),
print_utils_1.hardline,
(0, print_utils_1.join)(print_utils_1.hardline, print("actions")),
]; },
};
{
"name": "prettier-plugin-sql-cst",
"version": "0.6.0",
"version": "0.7.0",
"description": "Prettier plugin for SQL",

@@ -32,3 +32,3 @@ "author": "Rene Saarsoo <nene@triin.net>",

"prettier": "^2.8.2",
"sql-parser-cst": "^0.13.0"
"sql-parser-cst": "^0.14.0"
},

@@ -35,0 +35,0 @@ "devDependencies": {

@@ -99,17 +99,10 @@ # 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)

| `sqlKeywordCase` | `upper` | Converts SQL keywords to `upper` or `lower` case, or `preserve` existing. |
| `sqlParamTypes` | `[]` | Array of bound parameter types: `?`, `?nr`, `:name`, `@name`, `$name`. |
## Limitations and development status
Currently this plugin supports full **SQLite** syntax.
It also supports most of the **BigQuery** syntax.
Specifically the formatting of the following BigQuery SQL statements is fully implemented:
Currently this plugin supports two SQL dialects:
- SELECT
- UPDATE
- INSERT
- DELETE
- TRUNCATE
- CREATE / DROP / ALTER TABLE
- CREATE / DROP VIEW
- transactions (BEGIN, COMMIT, ROLLBACK)
- **SQLite** - full support.
- **BigQuery** - most of the common SQL syntax is supported (see [#2][] for implementation progress).

@@ -123,1 +116,2 @@ [prettier]: https://prettier.io/

[STYLE_GUIDE]: ./STYLE_GUIDE.md
[#2]: https://github.com/nene/prettier-plugin-sql-cst/issues/2
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc