Skip to content

Commit

Permalink
Fix for null value
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizcko committed Feb 17, 2024
1 parent 743d0dd commit 5e7453b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rsql-mongodb",
"version": "2.0.1",
"version": "2.0.2",
"description": "Converting RSQL queries to MongoDB queries",
"main": "rsql-mongodb.js",
"typings": "rsql-mongodb.ts",
Expand Down
3 changes: 3 additions & 0 deletions rsql-mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function setType(input) {
}
else if(input === 'false'){
typedInput = false;
}
else if(input === 'null'){
typedInput = null;
}
else if (!isNaN(Number(input))) {
typedInput = Number(input);
Expand Down
2 changes: 2 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('rsql-mongodb', function () {
expect(rsqlMongoDB('birthday=="1959-10-21"')).to.deep.include({ "birthday" : "1959-10-21" });
expect(rsqlMongoDB('birthday==1959-10-21')).to.be.a('object');
expect(rsqlMongoDB('married==true')).to.deep.include({ "married" : true });
expect(rsqlMongoDB('childs==null')).to.deep.include({ "childs" : null });
expect(rsqlMongoDB('childs==2')).to.deep.include({ "childs" : 2 });
expect(rsqlMongoDB('creationDate==2021-10-30T00:00:00.000Z')).to.be.a('object');
});
Expand All @@ -20,6 +21,7 @@ describe('rsql-mongodb', function () {
expect(rsqlMongoDB('birthday!="1959-10-21"')).to.deep.include({ "birthday": { $ne: "1959-10-21" } });
expect(rsqlMongoDB('birthday!=1959-10-21')).to.be.a('object');
expect(rsqlMongoDB('married!=false')).to.deep.include({ "married": { $ne: false } });
expect(rsqlMongoDB('childs!=null')).to.deep.include({ "childs": { $ne: null } });
expect(rsqlMongoDB('childs!=2')).to.deep.include({ "childs": { $ne: 2 } });

});
Expand Down

0 comments on commit 5e7453b

Please sign in to comment.