node-sql-parser
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -17,3 +17,3 @@ 'use strict' | ||
const surportedTypes = ['select', 'delete', 'update', 'insert', 'drop', 'rename', 'truncate', 'call'] | ||
const surportedTypes = ['select', 'delete', 'update', 'insert', 'drop', 'rename', 'truncate', 'call', 'use'] | ||
@@ -38,2 +38,7 @@ function escape(str) { | ||
function getSemiColon(semicolon = '') { | ||
if (semicolon === null) semicolon = '' | ||
return semicolon | ||
} | ||
function literalToSQL(literal) { | ||
@@ -364,3 +369,4 @@ const { type } = literal | ||
clauses.push(str) | ||
return clauses.join(' ') | ||
const semicolon = getSemiColon(stmt.semicolon) | ||
return `${clauses.join(' ')}${semicolon}` | ||
} | ||
@@ -386,2 +392,9 @@ | ||
function useToSQL(stmt) { | ||
const type = stmt.type && stmt.type.toUpperCase() | ||
const database = identifierToSql(stmt.db) | ||
const semicolon = getSemiColon(stmt.semicolon) | ||
return `${type} ${database}${semicolon}` | ||
} | ||
function callToSQL(stmt) { | ||
@@ -420,2 +433,3 @@ const type = 'CALL' | ||
truncate : dropAndTruncateToSQL, | ||
use : useToSQL, | ||
rename : renameToSQL, | ||
@@ -422,0 +436,0 @@ call : callToSQL, |
{ | ||
"name": "node-sql-parser", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "simple node sql parser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -65,27 +65,19 @@ # Nodejs SQL Parser | ||
{ | ||
"tableList": [ | ||
"select::null::t" | ||
"with": null, | ||
"type": "select", | ||
"options": null, | ||
"distinct": null, | ||
"columns": "*", | ||
"from": [ | ||
{ | ||
"db": null, | ||
"table": "t", | ||
"as": null | ||
} | ||
], | ||
"columnList": [ | ||
"select::null::(.*)" | ||
], | ||
"ast": { | ||
"with": null, | ||
"type": "select", | ||
"options": null, | ||
"distinct": null, | ||
"columns": "*", | ||
"from": [ | ||
{ | ||
"db": null, | ||
"table": "t", | ||
"as": null | ||
} | ||
], | ||
"where": null, | ||
"groupby": null, | ||
"having": null, | ||
"orderby": null, | ||
"limit": null | ||
} | ||
"where": null, | ||
"groupby": null, | ||
"having": null, | ||
"orderby": null, | ||
"limit": null | ||
} | ||
@@ -105,3 +97,3 @@ ``` | ||
### TableList, ColumnList, Ast | ||
### Get TableList, ColumnList, Ast by `parse` function | ||
@@ -108,0 +100,0 @@ ```javascript |
Sorry, the diff of this file is too big to display
376563
12911
165616
161