Skip to content

Commit

Permalink
isGenerator() should check for nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-coleman committed Oct 30, 2017
1 parent c279c71 commit c238879
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### 1.3.3 Maintenance Release

- $lookup() function throws an error when the property has a null value (issue #85)

#### 1.3.2 Maintenance Release

- Support extension functions that mix sync/async behaviours (issue #77)
Expand Down
1 change: 1 addition & 0 deletions jsonata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,7 @@ var jsonata = (function() {
function isGenerator(arg) {
return (
typeof arg === 'object' &&
arg !== null &&
Symbol.iterator in arg &&
typeof arg[Symbol.iterator] === 'function' &&
'next' in arg &&
Expand Down
15 changes: 15 additions & 0 deletions test/jsonata-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5253,6 +5253,21 @@ describe('Evaluator - functions: lookup', function () {
});
});

describe('lookup a null value', function () {
it('should return null', function () {
var data = {
"temp": 22.7,
"wind": 7,
"gust": null,
"timestamp": 1508971317377
};
var expr = jsonata('$lookup($$, "gust")');
var result = expr.evaluate(data);
var expected = null;
expect(result).to.deep.equal(expected);
});
});

});

describe('Evaluator - functions: append', function () {
Expand Down

0 comments on commit c238879

Please sign in to comment.