diff --git a/packages/core/src/api/sync/__tests__/collector.test.js b/packages/core/src/api/sync/__tests__/collector.test.js index 598752e9c..fa1ea715d 100644 --- a/packages/core/src/api/sync/__tests__/collector.test.js +++ b/packages/core/src/api/sync/__tests__/collector.test.js @@ -90,6 +90,25 @@ test("localOnly note should get included as a deleted item in collector", () => expect(items[1].type).toBe("note"); })); +test("unlinked relation should get included in collector", () => + databaseTest().then(async (db) => { + await loginFakeUser(db); + const collector = new Collector(db); + await db.relations.add( + { id: "h", type: "note" }, + { id: "h", type: "attachment" } + ); + + await iteratorToArray(collector.collect(100, false)); + + await db.relations.from({ id: "h", type: "note" }, "attachment").unlink(); + + const items = await iteratorToArray(collector.collect(100, false)); + + expect(items).toHaveLength(1); + expect(items[0].items[0].id).toBe("cd93df7a4c64fbd5f100361d629ac5b5"); + })); + async function iteratorToArray(iterator) { let items = []; for await (const item of iterator) { diff --git a/packages/core/src/collections/content.ts b/packages/core/src/collections/content.ts index a2a3448e7..b594f8245 100644 --- a/packages/core/src/collections/content.ts +++ b/packages/core/src/collections/content.ts @@ -197,7 +197,7 @@ export class Content implements ICollection { await this.db .sql() .replaceInto("content") - .columns(["id", "dateModified", "deleted"]) + .columns(["id", "dateModified", "deleted", "synced"]) .expression((eb) => eb .selectFrom("content") @@ -205,7 +205,8 @@ export class Content implements ICollection { .select((eb) => [ "content.id", eb.lit(Date.now()).as("dateModified"), - eb.lit(1).as("deleted") + eb.lit(1).as("deleted"), + eb.lit(0).as("synced") ]) ) .execute();