Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf9d8518

Browse files
authored
Do not attempt to delete from non-existing index (#543)
* reproduce upsert erroring when previous virtual field values are undefined* do not attempt to delete from non-existing index
1 parent5849a46 commitf9d8518

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

‎src/db/Table.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export class Table {
467467
// attribute has not changed, no need to update any index
468468
return;
469469
}
470-
if(prevValue!==null){
470+
if(prevValue!==null&&typeofprevValue!=="undefined"){
471471
// remove id from attribute's index for its old value
472472
indexIdsToDelete.push([attr,prevValue,id]);
473473
}

‎src/test/functional/immutableSessions.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,21 @@ describe("Immutable session", () => {
622622
expect(movie.publisher.ref).toBe(newPublisher.ref);
623623
});
624624

625+
it("upserting previously empty forwards foreign key (many-to-one) field works",()=>{
626+
const{ Movie, Publisher}=session;
627+
628+
constpublisher=Publisher.withId(0);
629+
630+
constinitialMovie=Movie.create({});
631+
constnewMovie=Movie.upsert({
632+
id:initialMovie.id,
633+
publisherId:publisher.id,
634+
});
635+
636+
expect(newMovie.publisherId).toEqual(0);
637+
expect(newMovie.publisher.ref).toBe(publisher.ref);
638+
});
639+
625640
it("trying to set backwards foreign key (reverse many-to-one) field throws",()=>{
626641
const{ Book}=session;
627642

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp