node-sql-parser
Advanced tools
Comparing version 4.12.0 to 4.13.0
@@ -1192,4 +1192,6 @@ | ||
export type func_call = trim_func_clause | { type: 'function'; name: string; args: expr_list; suffix: literal_string; } | { type: 'function'; name: string; args: expr_list; over?: over_partition; } | extract_func | { type: 'function'; name: string; over?: on_update_current_timestamp; } | { type: 'function'; name: string; args: expr_list; }; | ||
export type tablefunc_clause = { type: 'tablefunc'; name: crosstab; args: expr_list; as: func_call }; | ||
export type func_call = trim_func_clause | tablefunc_clause | { type: 'function'; name: string; args: expr_list; suffix: literal_string; } | { type: 'function'; name: string; args: expr_list; over?: over_partition; } | extract_func | { type: 'function'; name: string; over?: on_update_current_timestamp; } | { type: 'function'; name: string; args: expr_list; }; | ||
export type extract_filed = 'string'; | ||
@@ -1196,0 +1198,0 @@ |
@@ -29,4 +29,3 @@ (function (global, factory) { | ||
if (!exprList) return `[${(0, _column.columnsToSQL)(arrayPath)}]`; | ||
if (Array.isArray(exprList)) return `[${exprList.map(col => `(${(0, _column.columnsToSQL)(col)})`).filter(_util.hasVal).join(', ')}]`; | ||
const result = (0, _expr.exprToSQL)(exprList); | ||
const result = Array.isArray(exprList) ? exprList.map(col => `(${(0, _column.columnsToSQL)(col)})`).filter(_util.hasVal).join(', ') : (0, _expr.exprToSQL)(exprList); | ||
if (brackets) return `[${result}]`; | ||
@@ -33,0 +32,0 @@ return parentheses ? `(${result})` : result; |
@@ -211,2 +211,3 @@ (function (global, factory) { | ||
definer, | ||
if_not_exists: ifNotExists, | ||
keyword, | ||
@@ -228,3 +229,3 @@ recursive, | ||
const viewName = [(0, _util.identifierToSql)(db), (0, _util.identifierToSql)(name)].filter(_util.hasVal).join('.'); | ||
const sql = [(0, _util.toUpper)(type), (0, _util.toUpper)(replace), (0, _util.toUpper)(temporary), (0, _util.toUpper)(recursive), 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(', ')})`, withOptions && ['WITH', `(${withOptions.map(withOpt => (0, _util.commonTypeValue)(withOpt).join(' ')).join(', ')})`].join(' '), 'AS', (0, _union.unionToSQL)(select), (0, _util.toUpper)(withClause)]; | ||
const sql = [(0, _util.toUpper)(type), (0, _util.toUpper)(replace), (0, _util.toUpper)(temporary), (0, _util.toUpper)(recursive), algorithm && `ALGORITHM = ${(0, _util.toUpper)(algorithm)}`, definer, sqlSecurity && `SQL SECURITY ${(0, _util.toUpper)(sqlSecurity)}`, (0, _util.toUpper)(keyword), (0, _util.toUpper)(ifNotExists), viewName, columns && `(${columns.map(_util.columnIdentifierToSql).join(', ')})`, withOptions && ['WITH', `(${withOptions.map(withOpt => (0, _util.commonTypeValue)(withOpt).join(' ')).join(', ')})`].join(' '), 'AS', (0, _union.unionToSQL)(select), (0, _util.toUpper)(withClause)]; | ||
return sql.filter(_util.hasVal).join(' '); | ||
@@ -231,0 +232,0 @@ } |
@@ -35,2 +35,3 @@ (function (global, factory) { | ||
column_ref: _column.columnRefToSQL, | ||
column_definition: _column.columnDefinitionToSQL, | ||
datatype: _util.dataTypeToSQL, | ||
@@ -45,2 +46,3 @@ extract: _func.extractFunToSQL, | ||
struct: _arrayStruct.arrayStructExprToSQL, | ||
tablefunc: _func.tablefuncFunToSQL, | ||
tables: _tables.tablesToSQL, | ||
@@ -47,0 +49,0 @@ unnest: _tables.unnestToSQL, |
@@ -24,2 +24,3 @@ (function (global, factory) { | ||
_exports.funcToSQL = funcToSQL; | ||
_exports.tablefuncFunToSQL = tablefuncFunToSQL; | ||
function anyValueFuncToSQL(stmt) { | ||
@@ -145,2 +146,11 @@ const { | ||
} | ||
function tablefuncFunToSQL(expr) { | ||
const { | ||
as, | ||
name, | ||
args | ||
} = expr; | ||
const result = [`${name}(${(0, _expr.exprToSQL)(args).join(', ')})`, 'AS', funcToSQL(as)]; | ||
return result.join(' '); | ||
} | ||
}); |
{ | ||
"name": "node-sql-parser", | ||
"version": "4.12.0", | ||
"version": "4.13.0", | ||
"description": "simple node sql parser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -66,4 +66,10 @@ // Type definitions for node-sql-parser 1.0 | ||
} | ||
export interface Function { | ||
type: 'function'; | ||
name: string; | ||
args: expr_list; | ||
suffix?: any; | ||
} | ||
export interface Column { | ||
expr: ColumnRef | AggrFunc; | ||
expr: ColumnRef | AggrFunc | Function; | ||
as: string; | ||
@@ -88,2 +94,6 @@ } | ||
export type expr_list = { | ||
type: 'expr_list'; | ||
value: Expr[]; | ||
} | ||
export interface Select { | ||
@@ -90,0 +100,0 @@ with: With | null; |
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
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
57136517
33748