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

node-sql-parser

Package Overview
Dependencies
Maintainers
1
Versions
171
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.6.6 to 4.7.0

57

ast/postgresql.ts

@@ -135,3 +135,2 @@

export type column_order = {
column: expr;
collate: collate_expr;

@@ -204,6 +203,6 @@ opclass: ident;

type: 'drop';
prefix?: 'CONCURRENTLY';
keyword: string;
name: column_ref;
table: table_name;
options?: drop_index_opt;
options?: 'cascade' | 'restrict';
}

@@ -238,3 +237,3 @@

export type alter_action = ALTER_ADD_COLUMN | ALTER_DROP_COLUMN | ALTER_ADD_INDEX_OR_KEY | ALTER_ADD_FULLETXT_SPARITAL_INDEX | ALTER_RENAME_TABLE | ALTER_ALGORITHM | ALTER_LOCK;
export type alter_action = ALTER_ADD_COLUMN | ALTER_ADD_CONSTRAINT | ALTER_DROP_COLUMN | ALTER_ADD_INDEX_OR_KEY | ALTER_ADD_FULLETXT_SPARITAL_INDEX | ALTER_RENAME_TABLE | ALTER_ALGORITHM | ALTER_LOCK;

@@ -262,2 +261,11 @@

export type ALTER_ADD_CONSTRAINT = {
action: 'add';
create_definitions: create_db_definition;
resource: 'constraint';
type: 'alter';
};
export type ALTER_ADD_INDEX_OR_KEY = {

@@ -359,2 +367,4 @@ action: 'add';

export type reference_definition = {

@@ -365,5 +375,6 @@ definition: cte_column_definition;

match: 'match full' | 'match partial' | 'match simple';
on_delete?: on_reference;
on_update?: on_reference;
};
on_action: [on_reference?];
} | {
on_action: [on_reference];
};

@@ -641,5 +652,7 @@ export type on_reference = { type: 'on delete' | 'on update'; value: reference_option; };

export interface update_stmt_node {
with?: with_clause;
type: 'update';
table: table_ref_list;
set: set_list;
from?: from_clause;
where?: where_clause;

@@ -809,3 +822,3 @@ returning?: returning_stmt;

export type multiplicative_operator = "*" | "/" | "%";
export type multiplicative_operator = "*" | "/" | "%" | "||";

@@ -1240,2 +1253,26 @@ export type primary = cast_expr | literal | aggr_func | window_func | func_call | case_expr | interval_expr | column_ref | param | or_and_where_expr | var_decl | { type: 'origin'; value: string; };

type KW_OID = never;
type KW_REGCLASS = never;
type KW_REGCOLLATION = never;
type KW_REGCONFIG = never;
type KW_REGDICTIONARY = never;
type KW_REGNAMESPACE = never;
type KW_REGOPER = never;
type KW_REGOPERATOR = never;
type KW_REGPROC = never;
type KW_REGPROCEDURE = never;
type KW_REGROLE = never;
type KW_REGTYPE = never;
type KW_CURRENT_DATE = never;

@@ -1462,2 +1499,6 @@

export type oid_type = data_type;
export type timezone = string[];;

@@ -1464,0 +1505,0 @@

16

lib/aggregation.js

@@ -32,16 +32,10 @@ (function (global, factory) {

const overStr = (0, _over.overToSQL)(over);
let separator = ' ';
if (args.distinct) {
let separator = ' ';
const distinctSQL = ['DISTINCT', '', str];
if (args.parentheses) {
separator = '';
distinctSQL[1] = '(';
distinctSQL.push(')');
}
str = distinctSQL.filter(_util.hasVal).join(separator);
if (args.parentheses) {
separator = '';
str = `(${str})`;
}
if (args.distinct) str = ['DISTINCT', str].join(separator);
if (args.orderby) str = `${str} ${(0, _expr.orderOrPartitionByToSQL)(args.orderby, 'order by')}`;

@@ -48,0 +42,0 @@ if (args.separator) str = [str, (0, _util.toUpper)(args.separator.keyword), (0, _util.literalToSQL)(args.separator.value)].filter(_util.hasVal).join(' ');

@@ -51,3 +51,4 @@ (function (global, factory) {

suffix,
order_by
order_by,
subFields = []
} = expr;

@@ -63,2 +64,3 @@ let str = column === '*' ? '*' : columnOffsetToSQL(column, isDual);

str = [str, ...subFields].join('.');
const result = [str, (0, _util.commonOptionConnector)('AS', _expr.exprToSQL, as), arrows.map((arrow, index) => (0, _util.commonOptionConnector)(arrow, _util.literalToSQL, properties[index])).join(' ')];

@@ -95,4 +97,3 @@ if (collate) result.push((0, _util.commonTypeValue)(collate).join(' '));

table,
on_delete: onDelete,
on_update: onUpdate
on_action: onAction
} = referenceDefinition;

@@ -103,4 +104,3 @@ reference.push((0, _util.toUpper)(keyword));

reference.push((0, _util.toUpper)(match));
reference.push(...(0, _util.commonTypeValue)(onDelete));
reference.push(...(0, _util.commonTypeValue)(onUpdate));
onAction.map(onRef => reference.push(...(0, _util.commonTypeValue)(onRef)));
return reference.filter(_util.hasVal);

@@ -150,5 +150,9 @@ }

opclass,
order
order_by
} = columnOrder;
const result = [(0, _expr.exprToSQL)(column), (0, _util.commonOptionConnector)(collate && collate.type, _util.identifierToSql, collate && collate.value), opclass, (0, _util.toUpper)(order), (0, _util.toUpper)(nulls)];
const result = [(0, _expr.exprToSQL)(typeof column === 'string' ? {
type: 'column_ref',
table: columnOrder.table,
column
} : columnOrder), (0, _util.commonOptionConnector)(collate && collate.type, _util.identifierToSql, collate && collate.value), opclass, (0, _util.toUpper)(order_by), (0, _util.toUpper)(nulls)];
return result.filter(_util.hasVal).join(' ');

@@ -155,0 +159,0 @@ }

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

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

};
factory(mod.exports, global.alter, global.column, global.create, global.util, global.expr, global.tables);
factory(mod.exports, global.column, global.create, global.util, global.expr, global.tables);
global.command = mod.exports;
}
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _alter, _column, _create, _util, _expr, _tables) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _column, _create, _util, _expr, _tables) {
"use strict";

@@ -50,2 +50,8 @@

case 'trigger':
clauses.push([name[0].schema ? `${(0, _util.identifierToSql)(name[0].schema)}.` : '', (0, _util.identifierToSql)(name[0].trigger)].filter(_util.hasVal).join(''));
break;
case 'database':
case 'schema':
case 'procedure':

@@ -55,4 +61,8 @@ clauses.push((0, _util.identifierToSql)(name));

case 'view':
clauses.push((0, _tables.tablesToSQL)(name), stmt.options && stmt.options.map(_expr.exprToSQL).filter(_util.hasVal).join(' '));
break;
case 'index':
clauses.push((0, _column.columnRefToSQL)(name), 'ON', (0, _tables.tableToSQL)(stmt.table), stmt.options && stmt.options.map(_alter.alterExprToSQL).filter(_util.hasVal).join(' '));
clauses.push((0, _column.columnRefToSQL)(name), ...(stmt.table ? ['ON', (0, _tables.tableToSQL)(stmt.table)] : []), stmt.options && stmt.options.map(_expr.exprToSQL).filter(_util.hasVal).join(' '));
break;

@@ -59,0 +69,0 @@

(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "./alter", "./expr", "./index-definition", "./column", "./constrain", "./func", "./tables", "./union", "./util"], factory);
define(["exports", "./alter", "./expr", "./index-definition", "./column", "./constrain", "./func", "./tables", "./update", "./union", "./util"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("./alter"), require("./expr"), require("./index-definition"), require("./column"), require("./constrain"), require("./func"), require("./tables"), require("./union"), require("./util"));
factory(exports, require("./alter"), require("./expr"), require("./index-definition"), require("./column"), require("./constrain"), require("./func"), require("./tables"), require("./update"), require("./union"), require("./util"));
} else {

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

};
factory(mod.exports, global.alter, global.expr, global.indexDefinition, global.column, global.constrain, global.func, global.tables, global.union, global.util);
factory(mod.exports, global.alter, global.expr, global.indexDefinition, global.column, global.constrain, global.func, global.tables, global.update, global.union, global.util);
global.create = mod.exports;
}
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _alter, _expr, _indexDefinition, _column, _constrain, _func, _tables, _union, _util) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _alter, _expr, _indexDefinition, _column, _constrain, _func, _tables, _update, _union, _util) {
"use strict";

@@ -88,2 +88,27 @@

const {
definer,
for_each: forEach,
keyword,
type,
table,
if_not_exists: ife,
trigger,
trigger_event: triggerEvent,
trigger_order: triggerOrder,
trigger_time: triggerTime,
trigger_body: triggerBody
} = stmt;
const sql = [(0, _util.toUpper)(type), definer, (0, _util.toUpper)(keyword), (0, _util.toUpper)(ife), (0, _util.identifierToSql)(trigger), (0, _util.toUpper)(triggerTime), (0, _util.toUpper)(triggerEvent), 'ON', (0, _tables.tableToSQL)(table), (0, _util.toUpper)(forEach), triggerOrder && `${(0, _util.toUpper)(triggerOrder.keyword)} ${(0, _util.identifierToSql)(triggerOrder.trigger)}`];
switch (triggerBody.type) {
case 'set':
sql.push((0, _util.commonOptionConnector)('SET', _update.setToSQL, triggerBody.trigger));
break;
}
return sql.filter(_util.hasVal).join(' ');
}
function createConstraintTriggerToSQL(stmt) {
const {
constraint,

@@ -208,3 +233,3 @@ constraint_kw: constraintKw,

const viewName = [(0, _util.identifierToSql)(db), (0, _util.identifierToSql)(name)].filter(_util.hasVal).join('.');
const sql = [(0, _util.toUpper)(type), (0, _util.toUpper)(replace), algorithm && `ALGORITHM = ${(0, _util.toUpper)(algorithm)}`, definer && `DEFINER = ${definer}`, sqlSecurity && `SQL SECURITY ${(0, _util.toUpper)(sqlSecurity)}`, (0, _util.toUpper)(keyword), viewName, columns && `(${columns.map(_util.columnIdentifierToSql).join(', ')})`, 'AS', (0, _union.unionToSQL)(select), (0, _util.toUpper)(withClause)];
const sql = [(0, _util.toUpper)(type), (0, _util.toUpper)(replace), algorithm && `ALGORITHM = ${(0, _util.toUpper)(algorithm)}`, definer, sqlSecurity && `SQL SECURITY ${(0, _util.toUpper)(sqlSecurity)}`, (0, _util.toUpper)(keyword), viewName, columns && `(${columns.map(_util.columnIdentifierToSql).join(', ')})`, 'AS', (0, _union.unionToSQL)(select), (0, _util.toUpper)(withClause)];
return sql.filter(_util.hasVal).join(' ');

@@ -225,3 +250,3 @@ }

case 'trigger':
sql = createTriggerToSQL(stmt);
sql = stmt.resource === 'constraint' ? createConstraintTriggerToSQL(stmt) : createTriggerToSQL(stmt);
break;

@@ -228,0 +253,0 @@

@@ -31,3 +31,3 @@ (function (global, factory) {

} = indexType;
return [keyword.toUpperCase(), type.toUpperCase()];
return [keyword.toUpperCase(), (0, _util.toUpper)(type)];
}

@@ -93,3 +93,5 @@

index_options: indexOptions = [],
definition
definition,
on,
with: withExpr
} = indexDefinition;

@@ -105,2 +107,4 @@ const dataType = [];

dataType.push(indexOptionListToSQL(indexOptions).join(' '));
if (withExpr) dataType.push(`WITH (${indexOptionListToSQL(withExpr).join(', ')})`);
if (on) dataType.push(`ON [${on}]`);
return dataType;

@@ -107,0 +111,0 @@ }

@@ -76,2 +76,7 @@ (function (global, factory) {

case 'COLUMNS':
case 'INDEXES':
str = (0, _util.commonOptionConnector)('FROM', _tables.tablesToSQL, showExpr.from);
break;
case 'GRANTS':

@@ -82,3 +87,3 @@ str = showGrantsForUser(showExpr);

case 'CREATE':
str = (0, _util.commonOptionConnector)('', _tables.tableToSQL, showExpr.view);
str = (0, _util.commonOptionConnector)('', _tables.tableToSQL, showExpr[suffix]);
break;

@@ -85,0 +90,0 @@

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

const {
from,
table,

@@ -62,5 +63,5 @@ set,

} = stmt;
const clauses = [(0, _with.withToSQL)(withInfo), 'UPDATE', (0, _tables.tablesToSQL)(table), (0, _util.commonOptionConnector)('SET', setToSQL, set), (0, _util.commonOptionConnector)('WHERE', _expr.exprToSQL, where), (0, _expr.orderOrPartitionByToSQL)(orderby, 'order by'), (0, _limit.limitToSQL)(limit), (0, _util.returningToSQL)(returning)];
const clauses = [(0, _with.withToSQL)(withInfo), 'UPDATE', (0, _tables.tablesToSQL)(table), (0, _util.commonOptionConnector)('SET', setToSQL, set), (0, _util.commonOptionConnector)('FROM', _tables.tablesToSQL, from), (0, _util.commonOptionConnector)('WHERE', _expr.exprToSQL, where), (0, _expr.orderOrPartitionByToSQL)(orderby, 'order by'), (0, _limit.limitToSQL)(limit), (0, _util.returningToSQL)(returning)];
return clauses.filter(_util.hasVal).join(' ');
}
});
{
"name": "node-sql-parser",
"version": "4.6.6",
"version": "4.7.0",
"description": "simple node sql parser",

@@ -83,3 +83,3 @@ "main": "index.js",

"pre-commit": "^1.2.2",
"rimraf": "^3.0.2",
"rimraf": "^5.0.1",
"source-map-support": "^0.5.19",

@@ -86,0 +86,0 @@ "tinyify": "^4.0.0",

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

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