You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have virtuals defined on the model, even when using omitNew, the virtuals are returned.
let Person = bookshelf.Model.extend({
virtuals: {
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}
}
});
let p = new Person({firstName: 'Jon', lastName: 'Smith'});
p.toJSON({omitNew: true}); // { fullName: 'Jon Smith' }
This becomes a problem when loading relations that could be null. This virtual turns into { fullName: 'undefined undefined' } for instance, when it should be returning null.
The text was updated successfully, but these errors were encountered:
jgr3go
added a commit
to jgr3go/bookshelf
that referenced
this issue
Feb 3, 2017
If you have virtuals defined on the model, even when using
omitNew
, the virtuals are returned.This becomes a problem when loading relations that could be null. This virtual turns into
{ fullName: 'undefined undefined' }
for instance, when it should be returningnull
.The text was updated successfully, but these errors were encountered: