Skip to content

Commit d2f48f1

Browse files
committed
Add trim function for functions =in= and =out=
1 parent cd4b7d0 commit d2f48f1

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rsql-mongodb",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Converting RSQL queries to MongoDB queries",
55
"main": "rsql-mongodb.js",
66
"typings": "rsql-mongodb.ts",

rsql-mongodb.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ module.exports = function (input) {
193193
typedExp2 = typedExp2.replace(")","");
194194
var typedValues = new Array();
195195
for ( var token of typedExp2.split(",") ) {
196-
typedValues.push(setType(token));
196+
typedValues.push(setType(token.trim()));
197197
}
198198
mongoQuery[exp1] = { $in: typedValues };
199199
break;
@@ -202,7 +202,7 @@ module.exports = function (input) {
202202
typedExp2 = typedExp2.replace(")","");
203203
var typedValues = new Array();
204204
for ( var token of typedExp2.split(",") ) {
205-
typedValues.push(setType(token));
205+
typedValues.push(setType(token.trim()));
206206
}
207207
mongoQuery[exp1] = { $nin: typedValues };
208208
break;

test.js

+2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ describe('rsql-mongodb', function () {
4242
it("Test operator In ('=in=')", function () {
4343
expect(rsqlMongoDB('childs=in=(1,2,3)')).to.deep.include({ "childs": { $in: [1,2,3] } });
4444
expect(rsqlMongoDB('childs=in=("1","2","3")')).to.deep.include({ "childs": { $in: ["1","2","3"] } });
45+
expect(rsqlMongoDB('childs=in=(1, 2, 3 )')).to.deep.include({ "childs": { $in: [1,2,3] } });
4546
});
4647
it("Test operator Out ('=out=')", function () {
4748
expect(rsqlMongoDB('childs=out=(1,2,3)')).to.deep.include({ "childs": { $nin: [1,2,3] } });
4849
expect(rsqlMongoDB('childs=out=("1","2","3")')).to.deep.include({ "childs": { $nin: ["1","2","3"] } });
50+
expect(rsqlMongoDB('childs=out=(1, 2, 3 )')).to.deep.include({ "childs": { $nin: [1,2,3] } });
4951
});
5052
it("Test logical operator AND (';')", function () {
5153
expect(rsqlMongoDB('firstName=="john";lastName=="doe"')).to.deep.include({ $and: [ { "firstName" : "john" } , { "lastName" : "doe" } ] });

0 commit comments

Comments
 (0)