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.1.2 to 1.1.3

18

lib/sql2json.js

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

sql2json.prototype.parseFrom = function () {
let name = '';
while (this.hasNext()) {

@@ -133,11 +134,16 @@ const token = this.next();

case 'LITERAL':
this.parsed.from = token[1];
return;
name += token[1];
break;
case 'DOT':
name += token[1];
break;
case 'STRING':
this.parsed.from = `'${token[1]}'`;
return;
name += `'${token[1]}'`;
break;
case 'DBLSTRING':
this.parsed.from = `"${token[1]}"`;
return;
name += `"${token[1]}"`;
break;
default:
this.parsed.from = name;
this.index--;
return;

@@ -144,0 +150,0 @@

{
"name": "sql2json",
"version": "1.1.2",
"version": "1.1.3",
"description": "",

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

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

it('With table name inside dots', () => {
const data = {
select: [{
value: '*',
alias: null,
type: 'wildcard'
}],
from: 'public.pepe'
};
const response = 'SELECT * FROM public.pepe';
Json2sql.toSQL(data).should.deepEqual(response);
});
});

@@ -81,0 +95,0 @@

@@ -83,2 +83,17 @@ const assert = require('assert');

it('With table name inside dots', () => {
const response = {
select: [{
value: '*',
alias: null,
type: 'wildcard'
}],
from: 'public.pepe'
};
const obj = new Sql2json('select * from public.pepe');
const json = obj.toJSON();
json.should.deepEqual(response);
});
});

@@ -614,2 +629,29 @@

it('With like', () => {
const response = {
select: [{
value: '*',
alias: null,
type: 'wildcard'
}],
from: 'tablename',
where: {
type: 'operator',
left: {
value: 'country_iso',
type: 'literal'
},
value: 'LIKE',
right: {
value: 'BRA',
type: 'string'
}
}
};
const obj = new Sql2json('select * from tablename where country_iso LIKE \'BRA\'');
const json = obj.toJSON();
json.should.deepEqual(response);
});
});

@@ -616,0 +658,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