Comparing version 1.6.1 to 1.6.2
@@ -81,2 +81,5 @@ function json2sql() {} | ||
break; | ||
case 'number': | ||
responses.push(`${node.value}${node.alias ? ` AS ${node.alias}` : ''}`); | ||
break; | ||
case 'math': | ||
@@ -175,2 +178,5 @@ responses.push(parseMath(node)); | ||
break; | ||
case 'number': | ||
result.push(`${node.value}`); | ||
break; | ||
case 'function': | ||
@@ -177,0 +183,0 @@ result.push(parseFunction(node)); |
@@ -189,2 +189,9 @@ const lexer = require('sql-parser').lexer; | ||
break; | ||
case 'NUMBER': | ||
this.parsed.select.push({ | ||
value: parseFloat(token[1]), | ||
type: 'number', | ||
alias: null | ||
}); | ||
break; | ||
case 'STAR': | ||
@@ -626,2 +633,10 @@ this.parsed.select.push({ | ||
break; | ||
case 'NUMBER': | ||
stack.push({ | ||
value: parseFloat(token[1]), | ||
type: 'number', | ||
alias: null, | ||
direction: null | ||
}); | ||
break; | ||
case 'MATH_MULTI': | ||
@@ -740,2 +755,8 @@ case 'MATH': | ||
break; | ||
case 'NUMBER': | ||
stack.push({ | ||
type: 'number', | ||
value: parseFloat(token[1]) | ||
}); | ||
break; | ||
default: | ||
@@ -742,0 +763,0 @@ this.parsed.group = stack; |
{ | ||
"name": "sql2json", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -320,2 +320,16 @@ const assert = require('assert'); | ||
it('SQL with number of name of columns', () => { | ||
const data = { | ||
select: [{ | ||
value: 123, | ||
alias: null, | ||
type: 'number' | ||
}], | ||
from: 'tablename' | ||
}; | ||
const response = 'SELECT 123 FROM tablename'; | ||
Json2sql.toSQL(data).should.deepEqual(response); | ||
}); | ||
it('SQL with wildcard', () => { | ||
@@ -673,2 +687,22 @@ const data = { | ||
it('SQL with number of name of columns', () => { | ||
const data = { | ||
select: [{ | ||
value: 123, | ||
alias: null, | ||
type: 'number' | ||
}], | ||
from: 'tablename', | ||
orderBy: [{ | ||
value: 123, | ||
alias: null, | ||
type: 'number', | ||
direction: null | ||
}] | ||
}; | ||
const response = 'SELECT 123 FROM tablename ORDER BY 123'; | ||
Json2sql.toSQL(data).should.deepEqual(response); | ||
}); | ||
it('SQL with orderby with quotes', () => { | ||
@@ -831,2 +865,20 @@ const data = { | ||
it('Group by number of column name', () => { | ||
const data = { | ||
select: [{ | ||
value: '*', | ||
alias: null, | ||
type: 'wildcard' | ||
}], | ||
from: 'tablename', | ||
group: [{ | ||
type: 'number', | ||
value: 123 | ||
}] | ||
}; | ||
const response = 'SELECT * FROM tablename GROUP BY 123'; | ||
Json2sql.toSQL(data).should.deepEqual(response); | ||
}); | ||
it('Group by several fields', () => { | ||
@@ -833,0 +885,0 @@ const data = { |
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
153742
4225