Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: should not reload by default #423

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading