Comparing version 1.5.24 to 1.6.0
@@ -134,3 +134,3 @@ const lexer = require('sql-parser').lexer; | ||
this.parsed.select = []; | ||
let lastParen = false; | ||
while(this.hasNext()) { | ||
@@ -153,5 +153,10 @@ const token = this.next(); | ||
} | ||
if (token[1] !== '(' && token[1] !== ')' && token[1] !== ',') { | ||
if (!lastParen && token[1] !== '(' && token[1] !== ')' && token[1] !== ',' && token[1] !== '.' && token[1] !== '*') { | ||
el.value += ' ' + token[1]; | ||
} else { | ||
if (token[1] === '('){ | ||
lastParen = true; | ||
} else { | ||
lastParen = false; | ||
} | ||
el.value += token[1]; | ||
@@ -553,2 +558,3 @@ } | ||
const token = this.next(); | ||
let lastParen = false; | ||
switch (obtainType(token)) { | ||
@@ -574,5 +580,10 @@ | ||
} | ||
if (token[1] !== '(' && token[1] !== ')' && token[1] !== ',') { | ||
if (!lastParen && token[1] !== '(' && token[1] !== ')' && token[1] !== ',' && token[1] !== '.' && token[1] !== '*') { | ||
el.value += ' ' + token[1]; | ||
} else { | ||
if (token[1] === '('){ | ||
lastParen = true; | ||
} else { | ||
lastParen = false; | ||
} | ||
el.value += token[1]; | ||
@@ -633,2 +644,3 @@ } | ||
const stack = []; | ||
let lastParen = false; | ||
while (this.hasNext()) { | ||
@@ -658,5 +670,10 @@ const token = this.next(); | ||
} | ||
if (token[1] !== '(' && token[1] !== ')' && token[1] !== ',') { | ||
if (!lastParen && token[1] !== '(' && token[1] !== ')' && token[1] !== ',' && token[1] !== '.' && token[1] !== '*') { | ||
el.value += ' ' + token[1]; | ||
} else { | ||
if (token[1] === '('){ | ||
lastParen = true; | ||
} else { | ||
lastParen = false; | ||
} | ||
el.value += token[1]; | ||
@@ -737,2 +754,3 @@ } | ||
const stack = []; | ||
let lastParen = false; | ||
while (this.hasNext()) { | ||
@@ -761,5 +779,10 @@ const token = this.next(); | ||
} | ||
if (token[1] !== '(' && token[1] !== ')' && token[1] !== ',') { | ||
if (!lastParen && token[1] !== '(' && token[1] !== ')' && token[1] !== ',' && token[1] !== '.' && token[1] !== '*') { | ||
el.value += ' ' + token[1]; | ||
} else { | ||
if (token[1] === '('){ | ||
lastParen = true; | ||
} else { | ||
lastParen = false; | ||
} | ||
el.value += token[1]; | ||
@@ -766,0 +789,0 @@ } |
{ | ||
"name": "sql2json", | ||
"version": "1.5.24", | ||
"version": "1.6.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -101,3 +101,3 @@ const assert = require('assert'); | ||
select: [{ | ||
value: 'ST_Intersects( the_geom, \'{}\')', | ||
value: 'ST_Intersects(the_geom, \'{}\')', | ||
alias: null, | ||
@@ -114,2 +114,17 @@ type: 'literal' | ||
it('With function and *', () => { | ||
const response = { | ||
select: [{ | ||
value: '(ST_MetaData(the_raster_webmercator)).*', | ||
alias: null, | ||
type: 'literal' | ||
}], | ||
from: 'tablename' | ||
}; | ||
const obj = new Sql2json('select (ST_MetaData(the_raster_webmercator)).* from tablename', true); | ||
const json = obj.toJSON(); | ||
json.should.deepEqual(response); | ||
}); | ||
it('With where', () => { | ||
@@ -124,3 +139,3 @@ const response = { | ||
where: { | ||
value: 'ST_Intersects( the_geom, \'{}\')', | ||
value: 'ST_Intersects(the_geom, \'{}\')', | ||
type: 'literal', | ||
@@ -144,3 +159,3 @@ alias: null | ||
orderBy: [{ | ||
value: 'avg( name)', | ||
value: 'avg(name)', | ||
type: 'literal', | ||
@@ -165,3 +180,3 @@ alias: null | ||
orderBy: [{ | ||
value: 'avg( name), name asc', | ||
value: 'avg(name), name asc', | ||
type: 'literal', | ||
@@ -186,3 +201,3 @@ alias: null | ||
group: [{ | ||
value: 'ST_GeoHash( the_geom_point, 8)', | ||
value: 'ST_GeoHash(the_geom_point, 8)', | ||
type: 'literal', | ||
@@ -189,0 +204,0 @@ alias: null |
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
145440
4103