Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.24 to 1.6.0

33

lib/sql2json.js

@@ -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 @@ }

2

package.json
{
"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

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