From da86d804ba470f147f6251c1f691926edceeded6 Mon Sep 17 00:00:00 2001 From: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com> Date: Sat, 8 Aug 2026 12:48:40 +0000 Subject: [PATCH] test(node): cover tables across database connections --- nodejs/__test__/connection.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/nodejs/__test__/connection.test.ts b/nodejs/__test__/connection.test.ts index 68180471a..3813f9f83 100644 --- a/nodejs/__test__/connection.test.ts +++ b/nodejs/__test__/connection.test.ts @@ -69,6 +69,33 @@ describe("given a connection", () => { await expect(tbl.countRows()).resolves.toBe(1); }); + it("should isolate object-form table creation across databases", async () => { + const otherTmpDir = tmp.dirSync({ unsafeCleanup: true }); + const otherDb = await connect(otherTmpDir.name); + + try { + const firstTable = await db.createTable({ + name: "defaultTable", + data: [{ rowId: "id1", vector: Array(384).fill(0) }], + }); + const secondTable = await otherDb.createTable({ + name: "defaultTable", + data: [{ rowId: "id2", vector: Array(384).fill(0) }], + }); + + await expect(db.tableNames()).resolves.toEqual(["defaultTable"]); + await expect(otherDb.tableNames()).resolves.toEqual(["defaultTable"]); + + const firstRows = await firstTable.query().select(["rowId"]).toArray(); + const secondRows = await secondTable.query().select(["rowId"]).toArray(); + expect(firstRows.map((row) => row.rowId)).toEqual(["id1"]); + expect(secondRows.map((row) => row.rowId)).toEqual(["id2"]); + } finally { + otherDb.close(); + otherTmpDir.removeCallback(); + } + }); + it("should be able to drop tables`", async () => { await db.createTable("test", [{ id: 1 }, { id: 2 }]); await db.createTable("test2", [{ id: 1 }, { id: 2 }]);