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

node-sql-parser

Package Overview
Dependencies
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-sql-parser - npm Package Compare versions

Comparing version 4.0.8 to 4.1.0

2

ast/postgresql.ts

@@ -865,3 +865,3 @@

export type distinct_args = { distinct: 'DISTINCT'; expr: column_ref; } | { distinct: 'DISTINCT'; expr: expr; orderby?: order_by_clause; };
export type distinct_args = { distinct: 'DISTINCT'; expr: column_ref; } | { distinct: 'DISTINCT'; expr: expr; orderby?: order_by_clause; parentheses: boolean };

@@ -868,0 +868,0 @@

@@ -34,4 +34,12 @@ (function (global, factory) {

if (args.distinct) {
const separator = args.expr.parentheses ? '' : ' ';
str = ['DISTINCT', str].join(separator);
let separator = ' ';
const distinctSQL = ['DISTINCT', '', str];
if (args.parentheses) {
separator = '';
distinctSQL[1] = '(';
distinctSQL.push(')');
}
str = distinctSQL.filter(_util.hasVal).join(separator);
}

@@ -38,0 +46,0 @@

(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "./expr"], factory);
define(["exports", "./expr", "./util"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("./expr"));
factory(exports, require("./expr"), require("./util"));
} else {

@@ -10,6 +10,6 @@ var mod = {

};
factory(mod.exports, global.expr);
factory(mod.exports, global.expr, global.util);
global.binary = mod.exports;
}
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr, _util) {
"use strict";

@@ -52,5 +52,5 @@

const str = [(0, _expr.exprToSQL)(expr.left), operator, rstr].join(' ');
const str = [(0, _expr.exprToSQL)(expr.left), operator, rstr].filter(_util.hasVal).join(' ');
return expr.parentheses ? `(${str})` : str;
}
});

@@ -34,2 +34,3 @@ (function (global, factory) {

column_ref: _column.columnRefToSQL,
datatype: _util.dataTypeToSQL,
extract: _func.extractFunToSQL,

@@ -36,0 +37,0 @@ function: _func.funcToSQL,

@@ -19,2 +19,3 @@ (function (global, factory) {

});
_exports.selectIntoToSQL = selectIntoToSQL;
_exports.selectToSQL = selectToSQL;

@@ -33,2 +34,27 @@

}
function selectIntoToSQL(into) {
if (!into) return;
const {
position
} = into;
if (!position) return;
const {
keyword,
expr
} = into;
const result = [];
const intoType = (0, _util.toUpper)(keyword);
switch (intoType) {
case 'VAR':
result.push(expr.map(_expr.varToSQL).join(', '));
break;
default:
result.push(intoType, (0, _expr.exprToSQL)(expr));
}
return result.filter(_util.hasVal).join(' ');
}
/**

@@ -60,2 +86,3 @@ * @param {Object} stmt

having,
into = {},
limit,

@@ -73,5 +100,12 @@ options,

if (Array.isArray(options)) clauses.push(options.join(' '));
clauses.push(distinctToSQL(distinct), (0, _column.columnsToSQL)(columns, from)); // FROM + joins
clauses.push(distinctToSQL(distinct), (0, _column.columnsToSQL)(columns, from));
const {
position
} = into;
let intoSQL = '';
if (position) intoSQL = (0, _util.commonOptionConnector)('INTO', selectIntoToSQL, into);
if (position === 'column') clauses.push(intoSQL); // FROM + joins
clauses.push((0, _util.commonOptionConnector)('FROM', _tables.tablesToSQL, from));
if (position === 'from') clauses.push(intoSQL);
const {

@@ -89,2 +123,3 @@ keyword,

clauses.push((0, _util.toUpper)(forUpdate));
if (position === 'end') clauses.push(intoSQL);
const sql = clauses.filter(_util.hasVal).join(' ');

@@ -91,0 +126,0 @@ return parentheses ? `(${sql})` : sql;

(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "./expr", "./insert", "./util"], factory);
define(["exports", "./binary", "./column", "./expr", "./insert", "./util"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("./expr"), require("./insert"), require("./util"));
factory(exports, require("./binary"), require("./column"), require("./expr"), require("./insert"), require("./util"));
} else {

@@ -10,6 +10,6 @@ var mod = {

};
factory(mod.exports, global.expr, global.insert, global.util);
factory(mod.exports, global.binary, global.column, global.expr, global.insert, global.util);
global.tables = mod.exports;
}
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr, _insert, _util) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _binary, _column, _expr, _insert, _util) {
"use strict";

@@ -20,2 +20,3 @@

});
_exports.operatorToSQL = operatorToSQL;
_exports.tablesToSQL = tablesToSQL;

@@ -37,2 +38,31 @@ _exports.tableOptionToSQL = tableOptionToSQL;

function pivotOperatorToSQL(operator) {
const {
as,
column,
expr,
in_expr,
type
} = operator;
const result = [(0, _expr.exprToSQL)(expr), 'FOR', (0, _column.columnRefToSQL)(column), (0, _binary.binaryToSQL)(in_expr)];
const sql = [`${(0, _util.toUpper)(type)}(${result.join(' ')})`];
if (as) sql.push('AS', (0, _util.identifierToSql)(as));
return sql.join(' ');
}
function operatorToSQL(operator) {
if (!operator) return;
const {
type
} = operator;
switch (type) {
case 'pivot':
return pivotOperatorToSQL(operator);
default:
return '';
}
}
function tableToSQL(tableInfo) {

@@ -45,2 +75,3 @@ if ((0, _util.toUpper)(tableInfo.type) === 'UNNEST') return unnestToSQL(tableInfo);

expr,
operator,
schema,

@@ -56,6 +87,9 @@ tablesample

parentheses,
values
values,
prefix
} = expr;
const valueSQL = [parentheses && '(', '', parentheses && ')'];
valueSQL[1] = `${(0, _util.commonOptionConnector)('VALUES', _insert.valuesToSQL, values)}`;
let valuesExpr = (0, _insert.valuesToSQL)(values);
if (prefix) valuesExpr = valuesExpr.split('(').slice(1).map(val => `${(0, _util.toUpper)(prefix)}(${val}`).join('');
valueSQL[1] = `VALUES ${valuesExpr}`;
tableName = valueSQL.filter(_util.hasVal).join('');

@@ -66,3 +100,3 @@ }

const str = [database, schemaStr, tableName].filter(_util.hasVal).join('.');
const result = [str];
const result = [str, operatorToSQL(operator)];

@@ -75,3 +109,3 @@ if (tablesample) {

if (as) result.push('AS', (0, _util.identifierToSql)(as));
return result.join(' ');
return result.filter(_util.hasVal).join(' ');
}

@@ -78,0 +112,0 @@ /**

@@ -29,2 +29,3 @@ (function (global, factory) {

_exports.createValueExpr = createValueExpr;
_exports.dataTypeToSQL = dataTypeToSQL;
_exports.escape = escape;

@@ -365,2 +366,17 @@ _exports.literalToSQL = literalToSQL;

function dataTypeToSQL(expr) {
const {
dataType,
length,
parentheses,
scale,
suffix
} = expr;
let str = '';
if (length != null) str = scale ? `${length}, ${scale}` : length;
if (parentheses) str = `(${str})`;
if (suffix && suffix.length) str += ` ${suffix.join(' ')}`;
return `${dataType}${str}`;
}
function arrayStructTypeToSQL(expr) {

@@ -367,0 +383,0 @@ if (!expr) return;

{
"name": "node-sql-parser",
"version": "4.0.8",
"version": "4.1.0",
"description": "simple node sql parser",

@@ -5,0 +5,0 @@ "main": "index.js",

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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