node-sql-parser
Advanced tools
Comparing version 1.6.6 to 1.6.7
@@ -73,5 +73,5 @@ // Type definitions for node-sql-parser 1.0 | ||
export interface Update { | ||
type: 'udpate'; | ||
type: 'update'; | ||
db: string | null; | ||
table: string; | ||
table: Array<From | Dual> | null; | ||
set: SetList[]; | ||
@@ -82,3 +82,3 @@ where: any; | ||
type: 'delete'; | ||
tables: any; | ||
table: any; | ||
from: Array<From | Dual>; | ||
@@ -85,0 +85,0 @@ where: any; |
@@ -13,3 +13,13 @@ "use strict"; | ||
const str = expr.target.length ? `(${expr.target.length})` : ''; | ||
return `CAST(${(0, _expr.exprToSQL)(expr.expr)} AS ${expr.target.dataType}${str})`; | ||
let prefix = (0, _expr.exprToSQL)(expr.expr); | ||
let symbol = '::'; | ||
let suffix = ''; | ||
if (expr.symbol === 'as') { | ||
prefix = `CAST(${prefix}`; | ||
suffix = ')'; | ||
symbol = ` ${expr.symbol.toUpperCase()} `; | ||
} | ||
return `${prefix}${symbol}${expr.target.dataType}${str}${suffix}`; | ||
} | ||
@@ -16,0 +26,0 @@ |
@@ -14,3 +14,6 @@ "use strict"; | ||
var _select = require("./select"); | ||
function valuesToSQL(values) { | ||
if (values.type === 'select') return (0, _select.selectToSQL)(values); | ||
const clauses = values.map(_expr.exprToSQL); | ||
@@ -29,5 +32,5 @@ return `(${clauses.join('),(')})`; | ||
if (Array.isArray(columns)) clauses.push(`(${columns.map(_util.identifierToSql).join(', ')})`); | ||
clauses.push((0, _util.commonOptionConnector)('VALUES', valuesToSQL, values)); | ||
clauses.push((0, _util.commonOptionConnector)(Array.isArray(values) ? 'VALUES' : '', valuesToSQL, values)); | ||
clauses.push((0, _util.commonOptionConnector)('WHERE', _expr.exprToSQL, where)); | ||
return clauses.filter(_util.hasVal).join(' '); | ||
} |
@@ -46,2 +46,3 @@ "use strict"; | ||
if (!opt) return; | ||
if (!keyword) return action(opt); | ||
return `${keyword.toUpperCase()} ${action(opt)}`; | ||
@@ -48,0 +49,0 @@ } |
{ | ||
"name": "node-sql-parser", | ||
"version": "1.6.6", | ||
"version": "1.6.7", | ||
"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 too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1450235
51435