node-sql-parser
Advanced tools
Comparing version 2.0.3-beta to 2.0.4-beta
@@ -19,4 +19,3 @@ (function (global, factory) { | ||
}); | ||
_exports.dropToSQL = dropToSQL; | ||
_exports.truncateToSQL = truncateToSQL; | ||
_exports.commonCmdToSQL = commonCmdToSQL; | ||
_exports.renameToSQL = renameToSQL; | ||
@@ -28,9 +27,23 @@ _exports.useToSQL = useToSQL; | ||
function dropToSQL(stmt) { | ||
const clauses = ['DROP TABLE', (0, _tables.tablesToSQL)(stmt.table)]; | ||
return clauses.join(' '); | ||
} | ||
function commonCmdToSQL(stmt) { | ||
const { | ||
type, | ||
keyword, | ||
name | ||
} = stmt; | ||
const clauses = [(0, _util.toUpper)(type), (0, _util.toUpper)(keyword)]; | ||
function truncateToSQL(stmt) { | ||
const clauses = ['TRUNCATE', stmt.keyword, (0, _tables.tablesToSQL)(stmt.table)]; | ||
switch (keyword) { | ||
case 'table': | ||
clauses.push((0, _tables.tablesToSQL)(name)); | ||
break; | ||
case 'procedure': | ||
clauses.push((0, _util.identifierToSql)(name)); | ||
break; | ||
default: | ||
break; | ||
} | ||
return clauses.filter(_util.hasVal).join(' '); | ||
@@ -62,3 +75,3 @@ } | ||
} = stmt; | ||
const action = type && type.toUpperCase(); | ||
const action = (0, _util.toUpper)(type); | ||
const database = (0, _util.identifierToSql)(db); | ||
@@ -65,0 +78,0 @@ return `${action} ${database}`; |
@@ -29,4 +29,4 @@ (function (global, factory) { | ||
insert: _insert.insertToSQL, | ||
drop: _command.dropToSQL, | ||
truncate: _command.truncateToSQL, | ||
drop: _command.commonCmdToSQL, | ||
truncate: _command.commonCmdToSQL, | ||
use: _command.useToSQL, | ||
@@ -33,0 +33,0 @@ rename: _command.renameToSQL, |
{ | ||
"name": "node-sql-parser", | ||
"version": "2.0.3-beta", | ||
"version": "2.0.4-beta", | ||
"description": "simple node sql parser", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
}, | ||
"pre-commit": "test", | ||
"pre-commit": "coverLocal", | ||
"keywords": [ | ||
@@ -24,0 +24,0 @@ "sql", |
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
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
4113776
113734