Comparing version 1.0.0 to 1.0.1
@@ -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 @@ |
{ | ||
"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); | ||
}); | ||
}); | ||
}); |
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
61013
1712