Skip to content

Commit 0efdb69

Browse files
committed
Merge pull request #280 from jysperm/fix-fetch
fix(Object.fetch): fetchOptions.include.join is not a function
2 parents 0dcc442 + 657f618 commit 0efdb69

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ module.exports = function(AV) {
804804
options = arguments[1] || {};
805805
}
806806

807-
if (fetchOptions && fetchOptions.include && fetchOptions.include.length > 0) {
807+
if (fetchOptions && fetchOptions.include && _.isArray(fetchOptions.include)) {
808808
fetchOptions.include = fetchOptions.include.join(',');
809809
}
810810

test/object.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,19 @@ describe('Objects', function(){
363363
});
364364
});
365365

366+
it('should compatible with previous include option of fetch', function() {
367+
var myPost = new Post();
368+
myPost.set('author1', new Person({name: '1'}));
369+
myPost.set('author2', new Person({name: '2'}));
370+
return myPost.save().then(function() {
371+
myPost = AV.Object.createWithoutData('Post', myPost.id);
372+
return myPost.fetch({include: 'author1, author2'}, {}).then(function() {
373+
expect(myPost.get('author1').get('name')).to.be('1');
374+
expect(myPost.get('author2').get('name')).to.be('2');
375+
});
376+
});
377+
});
378+
366379
/*
367380
368381
it("it should fetch relation post",function(done){

0 commit comments

Comments
 (0)