Comparing version 1.1.2 to 1.1.3
@@ -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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71863
2016