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.4.2 to 1.4.3

3

lib/json2sql.js

@@ -46,2 +46,5 @@ function json2sql() {}

break;
case 'distinct':
responses.push(`DISTINCT ${parseSelect(node.arguments)}`);
break;
default:

@@ -48,0 +51,0 @@ break;

@@ -114,2 +114,3 @@ const lexer = require('sql-parser').lexer;

let containAs = false;
let isDistinct = false;
while (this.hasNext()) {

@@ -149,2 +150,5 @@ const token = this.next();

break;
case 'DISTINCT':
isDistinct = true;
break;
case 'SEPARATOR':

@@ -154,2 +158,8 @@ break;

this.index--;
if (isDistinct) {
this.parsed.select = [{
type: 'distinct',
arguments: this.parsed.select
}];
}
return;

@@ -156,0 +166,0 @@

2

package.json
{
"name": "sql2json",
"version": "1.4.2",
"version": "1.4.3",
"description": "",

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

@@ -277,2 +277,40 @@ const assert = require('assert');

});
it('SQL with distinct', () => {
const data = {
select: [{
type: 'distinct',
arguments: [{
value: 'countries',
type: 'literal',
alias: null
}]
}],
from: 'tablename'
};
const response = 'SELECT DISTINCT countries FROM tablename';
Json2sql.toSQL(data).should.deepEqual(response);
});
it('SQL with distinct with several files', () => {
const data = {
select: [{
type: 'distinct',
arguments: [{
value: 'countries',
type: 'literal',
alias: null
}, {
value: 'cities',
type: 'literal',
alias: null
}]
}],
from: 'tablename'
};
const response = 'SELECT DISTINCT countries, cities FROM tablename';
Json2sql.toSQL(data).should.deepEqual(response);
});
});

@@ -279,0 +317,0 @@ describe('OrderBy', () => {

@@ -295,2 +295,42 @@ const assert = require('assert');

it('SQL with distinct', () => {
const response = {
select: [{
type: 'distinct',
arguments: [{
value: 'countries',
type: 'literal',
alias: null
}]
}],
from: 'tablename'
};
const obj = new Sql2json('select distinct countries from tablename');
const json = obj.toJSON();
json.should.deepEqual(response);
});
it('SQL with distinct with several files', () => {
const response = {
select: [{
type: 'distinct',
arguments: [{
value: 'countries',
type: 'literal',
alias: null
}, {
value: 'cities',
type: 'literal',
alias: null
}]
}],
from: 'tablename'
};
const obj = new Sql2json('select distinct countries, cities from tablename');
const json = obj.toJSON();
json.should.deepEqual(response);
});
});

@@ -297,0 +337,0 @@

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