simple-sql-parser
Advanced tools
Comparing version
@@ -9,3 +9,3 @@ { | ||
"license": "MIT", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "dsferruzza", | ||
@@ -12,0 +12,0 @@ "contributors": [ |
@@ -19,3 +19,3 @@ sqlParser.js | ||
```js | ||
var sqlParser = require('sqlParser'); | ||
var sqlParser = require('simple-sql-parser'); | ||
``` | ||
@@ -22,0 +22,0 @@ |
@@ -9,3 +9,3 @@ function trim(str) { | ||
function protect_split(separator, str) { | ||
var sep = '######'; | ||
var sep = separator || '######'; | ||
@@ -68,3 +68,3 @@ var string = false; | ||
})); | ||
var parts_order = new Array(); | ||
var parts_order = []; | ||
@@ -122,3 +122,3 @@ // Hide words defined as separator but written inside brackets in the query | ||
// Define analysis functions | ||
var analysis = new Array(); | ||
var analysis = []; | ||
@@ -146,3 +146,3 @@ analysis['SELECT'] = analysis['SET'] = function (str) { | ||
str = str.split(' ON '); | ||
var result = new Object(); | ||
var result = {}; | ||
result['table'] = trim(str[0]); | ||
@@ -159,3 +159,3 @@ result['cond'] = trim(str[1]); | ||
str = str.split(','); | ||
var result = new Array(); | ||
var result = []; | ||
str.forEach(function (item, key) { | ||
@@ -165,3 +165,3 @@ var order_by = /([A-Za-z0-9_\.]+)\s+(ASC|DESC){1}/gi; | ||
if (order_by != null) { | ||
var tmp = new Object(); | ||
var tmp = {}; | ||
tmp['column'] = trim(order_by[1]); | ||
@@ -179,3 +179,3 @@ tmp['order'] = trim(order_by[2]); | ||
if (typeof limit[2] == 'undefined') limit[2] = 1; | ||
var result = new Object(); | ||
var result = {}; | ||
result['nb'] = parseInt(trim(limit[3])); | ||
@@ -189,3 +189,3 @@ result['from'] = parseInt(trim(limit[2])); | ||
insert = insert.exec(str); | ||
var result = new Object(); | ||
var result = {}; | ||
result['table'] = trim(insert[1]); | ||
@@ -203,5 +203,5 @@ if (typeof insert[3] != 'undefined') { | ||
var groups = protect_split(',', str); | ||
var result = new Array(); | ||
var result = {}; | ||
groups.forEach(function(group) { | ||
var group = group.replace(/^\(/g,'').replace(/\)$/g,''); | ||
group = group.replace(/^\(/g,'').replace(/\)$/g,''); | ||
group = protect_split(',', group); | ||
@@ -216,3 +216,3 @@ result.push(group); | ||
// Analyze parts | ||
var result = new Object(); | ||
var result = {}; | ||
var j = 0; | ||
@@ -228,3 +228,3 @@ parts_order.forEach(function (item, key) { | ||
var tmp = result[item]; | ||
result[item] = new Array(); | ||
result[item] = []; | ||
result[item].push(tmp); | ||
@@ -382,3 +382,3 @@ } | ||
return {type: 'operator', value: tokenValue}; | ||
}, | ||
} | ||
}; | ||
@@ -482,3 +482,3 @@ | ||
return astNode; | ||
}, | ||
} | ||
}; | ||
@@ -489,4 +489,4 @@ | ||
return new CondParser(source).parseExpressionsRecursively(); | ||
} | ||
}; | ||
module.exports = parseSQL; |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32733
-73.1%9
-40%395
-87.1%1
Infinity%