Socket
Socket
Sign inDemoInstall

sql2json

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql2json - npm Package Compare versions

Comparing version 1.5.17 to 1.5.18

2

lib/sql2json.js
const lexer = require('sql-parser').lexer;
const postgisFunctions = /^(ST_SummaryStatsAgg|ST_value|st_transform|ST_Intersects|st_buffer|ST_AsGeoJson|ST_SetSRID|ST_GeomFromGeoJSON|ST_METADATA|ST_SUMMARYSTATS|ST_HISTOGRAM|TO_NUMBER|TO_CHAR|ST_GeoHash|first|last|ST_BANDMETADATA|st_centroid|round|trunc|abs|ceil|exp|floor|power|sqrt|acos|asin|atan|atan2|cos|cot|sin|tan|ST_X|ST_Y|CF_[a-zA-Z0-9_-])$/gi;
const postgisFunctions = /^(Shape.STLength|ST_SummaryStatsAgg|ST_value|st_transform|ST_Intersects|st_buffer|ST_AsGeoJson|ST_SetSRID|ST_GeomFromGeoJSON|ST_METADATA|ST_SUMMARYSTATS|ST_HISTOGRAM|TO_NUMBER|TO_CHAR|ST_GeoHash|first|last|ST_BANDMETADATA|st_centroid|round|trunc|abs|ceil|exp|floor|power|sqrt|acos|asin|atan|atan2|cos|cot|sin|tan|ST_X|ST_Y|CF_[a-zA-Z0-9_-])$/gi;
const between = /^between$/gi;

@@ -5,0 +5,0 @@ const sqlStatements = /^delete$/gi;

{
"name": "sql2json",
"version": "1.5.17",
"version": "1.5.18",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -173,2 +173,21 @@ const assert = require('assert');

it('SQL with function shape', () => {
const data = {
select: [{
value: 'Shape.STLength',
alias: null,
type: 'function',
arguments: []
}, {
value: 'x',
alias: null,
type: 'literal'
}],
from: 'tablename'
};
const response = 'SELECT Shape.STLength(), x FROM tablename';
Json2sql.toSQL(data).should.deepEqual(response);
});
it('SQL with static columns', () => {

@@ -175,0 +194,0 @@ const data = {

@@ -168,3 +168,3 @@ const assert = require('assert');

it('SQL with wildcard', () => {
it('SQL with values as name column', () => {
const response = {

@@ -184,2 +184,23 @@ select: [{

it('SQL with function shape', () => {
const response = {
select: [{
value: 'Shape.STLength',
alias: null,
type: 'function',
arguments: []
}, {
value: 'x',
alias: null,
type: 'literal'
}],
from: 'tablename'
};
const obj = new Sql2json('SELECT Shape.STLength(), x from tablename');
const json = obj.toJSON();
json.should.deepEqual(response);
});
it('SQL with static columns', () => {

@@ -186,0 +207,0 @@ const response = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc