Skip to content

Commit

Permalink
fix: sequelize set datavalue should not check attribute strictly (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyDaddy authored Jun 11, 2021
1 parent fb12f19 commit 85b3ab9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/adapters/sequelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ module.exports = Bone => {
}

setDataValue(key, value) {
this.attribute(key, value);
if (this.hasAttribute(key)) this.attribute(key, value);
else this[key] = value;
}

// EXISTS
Expand Down
8 changes: 8 additions & 0 deletions test/unit/adapters/sequelize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,14 @@ describe('=> Sequelize adapter', () => {
const extra = post.getDataValue('extra');
assert(!extra);
});

it('instance.setDataValue', async () => {
const book = await Book.create({ name: 'Book of Tyrael', price: 20 });
book.setDataValue('name', 'Book1');
assert(book.name === 'Book1');
book.setDataValue('hello', 'hello');
assert(book.hello === 'hello');
});
});

describe('Model scope', () => {
Expand Down

0 comments on commit 85b3ab9

Please sign in to comment.