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.6.1 to 1.6.2

6

lib/json2sql.js

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

break;
case 'number':
responses.push(`${node.value}${node.alias ? ` AS ${node.alias}` : ''}`);
break;
case 'math':

@@ -175,2 +178,5 @@ responses.push(parseMath(node));

break;
case 'number':
result.push(`${node.value}`);
break;
case 'function':

@@ -177,0 +183,0 @@ result.push(parseFunction(node));

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

break;
case 'NUMBER':
this.parsed.select.push({
value: parseFloat(token[1]),
type: 'number',
alias: null
});
break;
case 'STAR':

@@ -626,2 +633,10 @@ this.parsed.select.push({

break;
case 'NUMBER':
stack.push({
value: parseFloat(token[1]),
type: 'number',
alias: null,
direction: null
});
break;
case 'MATH_MULTI':

@@ -740,2 +755,8 @@ case 'MATH':

break;
case 'NUMBER':
stack.push({
type: 'number',
value: parseFloat(token[1])
});
break;
default:

@@ -742,0 +763,0 @@ this.parsed.group = stack;

2

package.json
{
"name": "sql2json",
"version": "1.6.1",
"version": "1.6.2",
"description": "",

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

@@ -320,2 +320,16 @@ const assert = require('assert');

it('SQL with number of name of columns', () => {
const data = {
select: [{
value: 123,
alias: null,
type: 'number'
}],
from: 'tablename'
};
const response = 'SELECT 123 FROM tablename';
Json2sql.toSQL(data).should.deepEqual(response);
});
it('SQL with wildcard', () => {

@@ -673,2 +687,22 @@ const data = {

it('SQL with number of name of columns', () => {
const data = {
select: [{
value: 123,
alias: null,
type: 'number'
}],
from: 'tablename',
orderBy: [{
value: 123,
alias: null,
type: 'number',
direction: null
}]
};
const response = 'SELECT 123 FROM tablename ORDER BY 123';
Json2sql.toSQL(data).should.deepEqual(response);
});
it('SQL with orderby with quotes', () => {

@@ -831,2 +865,20 @@ const data = {

it('Group by number of column name', () => {
const data = {
select: [{
value: '*',
alias: null,
type: 'wildcard'
}],
from: 'tablename',
group: [{
type: 'number',
value: 123
}]
};
const response = 'SELECT * FROM tablename GROUP BY 123';
Json2sql.toSQL(data).should.deepEqual(response);
});
it('Group by several fields', () => {

@@ -833,0 +885,0 @@ const data = {

Sorry, the diff of this file is too big to display

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