New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flora-sql-parser

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flora-sql-parser - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

39

lib/sql.js

@@ -7,3 +7,3 @@ 'use strict';

'\0': '\\0',
'\'': '\\\'',
"'": "\\'",
'"': '\\"',

@@ -42,3 +42,3 @@ '\b': '\\b',

/* nothing */
} else if (type === 'string') value = '\'' + escape(value) + '\'';
} else if (type === 'string') value = "'" + escape(value) + "'";
else if (type === 'bool') value = value ? 'TRUE' : 'FALSE';

@@ -140,3 +140,3 @@ else if (type === 'null') value = 'NULL';

return columns
.map((column) => {
.map(column => {
let str = exprToSQL(column.expr);

@@ -173,6 +173,6 @@

str = (joinExpr.join && joinExpr.join !== null) ? ' ' + joinExpr.join + ' ' : str = ', ';
str = joinExpr.join && joinExpr.join !== null ? ' ' + joinExpr.join + ' ' : (str = ', ');
if (joinExpr.table) {
if (joinExpr.db !== null) str += (joinExpr.db + '.');
if (joinExpr.db !== null) str += joinExpr.db + '.';
str += identifierToSql(joinExpr.table);

@@ -197,8 +197,14 @@ } else {

function withToSql(withExpr) {
return 'WITH ' + (withExpr[0].recursive ? 'RECURSIVE ' : '') + withExpr.map((cte) => {
const name = `"${cte.name}"`;
const columns = Array.isArray(cte.columns) ? '(' + cte.columns.join(', ') + ')' : '';
return (
'WITH ' +
(withExpr[0].recursive ? 'RECURSIVE ' : '') +
withExpr
.map(cte => {
const name = `"${cte.name}"`;
const columns = Array.isArray(cte.columns) ? '(' + cte.columns.join(', ') + ')' : '';
return name + columns + ' AS (' + exprToSQL(cte.stmt) + ')';
}).join(', ');
return name + columns + ' AS (' + exprToSQL(cte.stmt) + ')';
})
.join(', ')
);
}

@@ -234,6 +240,7 @@

if (has(stmt, 'where') && stmt.where !== null) clauses.push('WHERE ' + exprToSQL(stmt.where));
if (Array.isArray(stmt.groupby)) clauses.push('GROUP BY', getExprListSQL(stmt.groupby).join(', '));
if (Array.isArray(stmt.groupby) && stmt.groupby.length > 0)
clauses.push('GROUP BY', getExprListSQL(stmt.groupby).join(', '));
if (has(stmt, 'having') && stmt.having !== null) clauses.push('HAVING ' + exprToSQL(stmt.having));
if (Array.isArray(stmt.orderby)) {
if (Array.isArray(stmt.orderby) && stmt.orderby.length > 0) {
const orderExpressions = stmt.orderby.map(expr => exprToSQL(expr.expr) + ' ' + expr.type);

@@ -270,3 +277,3 @@ clauses.push('ORDER BY', orderExpressions.join(', '));

column_ref: columnRefToSQL,
expr_list: (expr) => {
expr_list: expr => {
const str = getExprListSQL(expr.value);

@@ -276,6 +283,4 @@ return !expr.parentheses ? str : `(${str})`;

function: funcToSQL,
select: (expr) => {
const str = typeof expr._next !== 'object'
? selectToSQL(expr)
: unionToSQL(expr);
select: expr => {
const str = typeof expr._next !== 'object' ? selectToSQL(expr) : unionToSQL(expr);
return !expr.parentheses ? str : `(${str})`;

@@ -282,0 +287,0 @@ },

@@ -34,3 +34,3 @@ 'use strict';

expr.left = left && left.type ? expr.left = left : createValueExpr(left);
expr.left = left && left.type ? (expr.left = left) : createValueExpr(left);

@@ -43,5 +43,3 @@ if (operator === 'BETWEEN') {

} else {
expr.right = right && right.type
? expr.right = right
: expr.right = createValueExpr(right);
expr.right = right && right.type ? (expr.right = right) : (expr.right = createValueExpr(right));
}

@@ -61,7 +59,7 @@

Object.keys(ast)
.filter((key) => {
.filter(key => {
const value = ast[key];
return Array.isArray(value) || (typeof value === 'object' && value !== null);
})
.forEach((key) => {
.forEach(key => {
const expr = ast[key];

@@ -68,0 +66,0 @@

{
"name": "flora-sql-parser",
"version": "0.8.0",
"version": "0.8.1",
"description": "Parse SQL (select) statements into abstract syntax tree (AST) and convert ASTs back to SQL.",

@@ -58,8 +58,9 @@ "main": "index.js",

"eslint": "^5.8.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-prettier": "^3.0.0",
"mocha": "^5.2.0",
"pegjs": "^0.10.0",
"pre-commit": "^1.2.2"
"pre-commit": "^1.2.2",
"prettier": "^1.15.2"
}
}

Sorry, the diff of this file is too big to display

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