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.0.0 to 1.0.1

4

lib/sql2json.js

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

this.parsed.where = stack.pop();
this.index--;
return;

@@ -304,2 +306,3 @@ }

this.parsed.orderBy = stack;
this.index--;
return;

@@ -356,2 +359,3 @@

this.parsed.group = stack;
this.index--;
return;

@@ -358,0 +362,0 @@

2

package.json
{
"name": "sql2json",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

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

@@ -251,2 +251,28 @@ const assert = require('assert');

});
it('Group with where', () => {
const data = {
select: [{
value: '*',
alias: null,
type: 'wildcard'
}],
from: 'tablename',
group: ['name', 'surname'],
where: {
type: 'between',
value: 'data',
arguments: [{
value: 1,
type: 'number'
}, {
value: 3,
type: 'number'
}]
}
};
const response = 'SELECT * FROM tablename WHERE data BETWEEN 1 AND 3 GROUP BY name, surname';
Json2sql.toSQL(data).should.deepEqual(response);
});
});

@@ -603,2 +629,34 @@

});
describe('all', () => {
it('All', () => {
const data = {
select: [{
value: '*',
alias: null,
type: 'wildcard'
}],
from: 'tablename',
group: ['name', 'surname'],
where: {
type: 'between',
value: 'data',
arguments: [{
value: 1,
type: 'number'
}, {
value: 3,
type: 'number'
}]
},
limit: 1,
orderBy: [{
value: 'name',
direction: null
}]
};
const response = 'SELECT * FROM tablename WHERE data BETWEEN 1 AND 3 GROUP BY name, surname ORDER BY name LIMIT 1';
Json2sql.toSQL(data).should.deepEqual(response);
});
});
});

@@ -513,2 +513,29 @@ const assert = require('assert');

});
it('Group with where', () => {
const response = {
select: [{
value: '*',
alias: null,
type: 'wildcard'
}],
from: 'tablename',
group: ['name', 'surname'],
where: {
type: 'between',
value: 'data',
arguments: [{
value: 1,
type: 'number'
}, {
value: 3,
type: 'number'
}]
}
};
const obj = new Sql2json('select * from tablename where data between 1 and 3 group by name, surname');
const json = obj.toJSON();
json.should.deepEqual(response);
});
});

@@ -635,2 +662,36 @@

describe('all', () => {
it('All', () => {
const response = {
select: [{
value: '*',
alias: null,
type: 'wildcard'
}],
from: 'tablename',
group: ['name', 'surname'],
where: {
type: 'between',
value: 'data',
arguments: [{
value: 1,
type: 'number'
}, {
value: 3,
type: 'number'
}]
},
limit: 1,
orderBy: [{
value: 'name',
direction: null
}]
};
const obj = new Sql2json('select * from tablename where data between 1 and 3 group by name, surname order by name limit 1');
const json = obj.toJSON();
json.should.deepEqual(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