node-sql-parser
Advanced tools
Comparing version 3.9.2 to 3.9.3
@@ -537,3 +537,3 @@ | ||
export type table_base = { type: 'dual' } | table_name & { as?: alias_clause; } | { expr: union_stmt; as?: alias_clause; }; | ||
export type table_base = { type: 'dual' } | { expr: union_stmt; as?: alias_clause; } | { type: 'expr'; expr: expr; as?: alias_clause; } | table_name & { as?: alias_clause; }; | ||
@@ -550,3 +550,3 @@ | ||
export type table_name = { db?: ident; table: ident | '*'; }; | ||
export type table_name = { db?: ident; schema?: ident, table: ident | '*'; }; | ||
@@ -553,0 +553,0 @@ |
@@ -25,2 +25,3 @@ (function (global, factory) { | ||
const { | ||
collate, | ||
target, | ||
@@ -51,2 +52,3 @@ expr: expression, | ||
if (alias) suffix += ` AS ${(0, _util.identifierToSql)(alias)}`; | ||
if (collate) suffix += ` ${(0, _util.commonTypeValue)(collate).join(' ')}`; | ||
return `${prefix}${symbolChar}${dataType}${str}${suffix}`; | ||
@@ -76,9 +78,11 @@ } | ||
parentheses, | ||
over | ||
over, | ||
collate | ||
} = expr; | ||
const collateStr = (0, _util.commonTypeValue)(collate).join(' '); | ||
const overStr = (0, _over.overToSQL)(over); | ||
if (!args) return [name, overStr].filter(_util.hasVal).join(' '); | ||
const str = `${name}(${(0, _expr.exprToSQL)(args).join(', ')})`; | ||
return [parentheses ? `(${str})` : str, overStr].filter(_util.hasVal).join(' '); | ||
return [parentheses ? `(${str})` : str, collateStr, overStr].filter(_util.hasVal).join(' '); | ||
} | ||
}); |
@@ -29,9 +29,11 @@ (function (global, factory) { | ||
as, | ||
expr | ||
expr, | ||
schema | ||
} = tableInfo; | ||
const database = (0, _util.identifierToSql)(db); | ||
const schemaStr = (0, _util.identifierToSql)(schema); | ||
let tableName = table && (0, _util.identifierToSql)(table); | ||
if (expr && expr.type === 'values') tableName = `(${(0, _util.commonOptionConnector)('VALUES', _insert.valuesToSQL, expr.values)})`; | ||
if (expr && expr.type !== 'values') tableName = (0, _expr.exprToSQL)(expr); | ||
const str = database ? `${database}.${tableName}` : tableName; | ||
const str = [database, schemaStr, tableName].filter(_util.hasVal).join('.'); | ||
if (as) return `${str} AS ${(0, _util.identifierToSql)(as)}`; | ||
@@ -38,0 +40,0 @@ return str; |
{ | ||
"name": "node-sql-parser", | ||
"version": "3.9.2", | ||
"version": "3.9.3", | ||
"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
38777348
22662