The engine's test covers a cursor of another generation: tables of another schema are made again
Jonas Templestein, 2026-11-26 22:42 UTC · dc1cadf241f4ccb5943c6f1b8c87fa1a38bf5f7d · parent d8e4c19
1 file changed
M core/itx/src/context/reactive-catalog.test.ts
@@ -372,6 +372,33 @@ expect(calls).toBe(5); }); +test("tables of another schema are made again and filled again, and a cursor of the old ones gets every row", () => { + const source = [task(1, "open", 10), task(2, "open", 20)]; + using object = fakeObject((after, limit) => + source.filter((row) => byteOrder(row.path, after) > 0).slice(0, limit), + ); + const client = new Client(); + client.connect(object.wake()); + const spec = { where: { status: "open" }, limit: 5 }; + client.subscribe(object.wake(), "open", spec); + const sub = client.subs.get("open")!; + expect(sub.answers.at(-1)).toMatchObject({ reset: true, put: 2 }); + const generation = sub.gen; + + // a later release of the kernel keeps its tables in another shape + object.db.exec("UPDATE rcat_meta SET v = 'an earlier schema' WHERE k = 'schema'"); + client.socket!.close(); + object.sockets.delete(client.socket!); + const later = object.wake(); + client.connect(later); + // The watcher's cursor fits the new tables by its numbers alone: the two rows have the same + // revisions and the same keys again. Only the generation says that it is of other tables. + client.subscribe(later, "open", spec, true); + expect(sub.answers.at(-1)).toMatchObject({ reset: true, put: 2 }); + expect(sub).not.toMatchObject({ gen: generation }); + expect(later.watches({ verify: true })).toMatchObject({ active: true, rows: 2, faults: [] }); +}); + test("one write is one message for a socket, over all of its queries", () => { using object = fakeObject(); const catalog = object.wake();