Comparing version 1.4.3 to 1.4.4
const lexer = require('sql-parser').lexer; | ||
const postgisFunctions = /ST_Intersects|ST_AsGeoJson|ST_SetSRID|ST_GeomFromGeoJSON|ST_METADATA|ST_SUMMARYSTATS|ST_HISTOGRAM|TO_NUMBER|TO_CHAR|ST_GeoHash|st_centroid/gi; | ||
const postgisFunctions = /ST_Intersects|ST_AsGeoJson|ST_SetSRID|ST_GeomFromGeoJSON|ST_METADATA|ST_SUMMARYSTATS|ST_HISTOGRAM|TO_NUMBER|TO_CHAR|ST_GeoHash|first|last|ST_BANDMETADATA|st_centroid/gi; | ||
const between = /between/gi; | ||
@@ -142,2 +142,4 @@ const sqlStatements = /delete/gi; | ||
case 'FUNCTION': | ||
case 'FIRST': | ||
case 'LAST': | ||
if (containAs) { | ||
@@ -314,2 +316,4 @@ this.parsed.select[this.parsed.select.length - 1].alias = token[1]; | ||
case 'FUNCTION': | ||
case 'LAST': | ||
case 'FIRST': | ||
stack.push(this.parseFunction(token[1])); | ||
@@ -339,3 +343,3 @@ break; | ||
conditional = null; | ||
} | ||
@@ -366,3 +370,3 @@ conditional = token[1]; | ||
conditional = null; | ||
} | ||
@@ -369,0 +373,0 @@ this.parsed.where = stack.pop(); |
{ | ||
"name": "sql2json", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -335,2 +335,64 @@ const assert = require('assert'); | ||
it('SQL with FIRST function', () => { | ||
const response = { | ||
select: [{ | ||
alias: null, | ||
type: 'function', | ||
value: 'first', | ||
arguments: [{ | ||
value: 'column1', | ||
type: 'literal' | ||
}] | ||
}], | ||
from: 'tablename' | ||
}; | ||
const obj = new Sql2json('select first(column1) from tablename'); | ||
const json = obj.toJSON(); | ||
json.should.deepEqual(response); | ||
}); | ||
it('SQL with LAST function', () => { | ||
const response = { | ||
select: [{ | ||
alias: null, | ||
type: 'function', | ||
value: 'last', | ||
arguments: [{ | ||
value: 'column1', | ||
type: 'literal' | ||
}] | ||
}], | ||
from: 'tablename' | ||
}; | ||
const obj = new Sql2json('select last(column1) from tablename'); | ||
const json = obj.toJSON(); | ||
json.should.deepEqual(response); | ||
}); | ||
it('SQL with ST_BANDMETADATA function', () => { | ||
const response = { | ||
select: [{ | ||
alias: null, | ||
type: 'function', | ||
value: 'ST_BANDMETADATA', | ||
arguments: [{ | ||
value: 'rast', | ||
type: 'literal' | ||
}, | ||
{ | ||
value: 1, | ||
type: 'number' | ||
} | ||
] | ||
}], | ||
from: 'tablename' | ||
}; | ||
const obj = new Sql2json('select ST_BANDMETADATA(rast, 1) from tablename'); | ||
const json = obj.toJSON(); | ||
json.should.deepEqual(response); | ||
}); | ||
}); | ||
@@ -337,0 +399,0 @@ |
Sorry, the diff of this file is not supported yet
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
89076
2540