Skip to content

Commit

Permalink
chore: should not reload by default (#423)
Browse files Browse the repository at this point in the history
* feat: remove-reload

* test: reload

---------

Co-authored-by: cyang <[email protected]>
Co-authored-by: Chen Yangjian <[email protected]>
  • Loading branch information
3 people authored Aug 23, 2024
1 parent 002eca9 commit cf07fac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/bone.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,6 @@ class Bone {
}
try {
const res = await this._update(Object.keys(changes).length? changes : values, options);
if (typeof values === 'object' && Object.values(values).some(v => v instanceof Raw)) {
await this.reload();
}
return res;
} catch (error) {
// revert value in case update failed
Expand Down
3 changes: 3 additions & 0 deletions test/integration/suite/json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ describe('=> Basic', () => {
await gen.update({ extra: { a: 1 } });
assert.equal(gen.extra.a, 1);
await gen.jsonMerge('extra', { b: 2, a: 3 });
await gen.reload();
assert.equal(gen.extra.a, 3);
assert.equal(gen.extra.b, 2);

const gen2 = await Gen.create({ name: 'gen2', extra: { test: 1 }});
assert.equal(gen2.extra.test, 1);
await gen2.jsonMerge('extra', { url: 'https://www.wanxiang.art/?foo=' });
await gen2.reload();
assert.equal(gen2.extra.url, 'https://www.wanxiang.art/?foo=');
});

Expand All @@ -51,6 +53,7 @@ describe('=> Basic', () => {

const sql = new Raw(`JSON_MERGE_PATCH(extra, '${JSON.stringify({ url: 'https://www.taobao.com/?id=1' })}')`);
await gen.update({extra: sql});
await gen.reload();
assert.equal(gen.extra.url, 'https://www.taobao.com/?id=1');
});
});
Expand Down

0 comments on commit cf07fac

Please sign in to comment.