Skip to content

Commit ed33893

Browse files
committed
test: verify closure junction counts after reparenting
1 parent fce681f commit ed33893

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎packages/typeorm/test/functional/tree-tables/closure-table/custom-primary-column/custom-primary-column.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe("tree-tables > closure-table > custom primary column", () => {
1919
beforeEach(() => reloadTestingDatabases(dataSources))
2020
after(() => closeTestingConnections(dataSources))
2121

22+
// Regression for #12904: renamed primary columns must not leave stale links.
2223
for (const destination of ["other root", "same tree", "root"] as const) {
2324
it(`should remove old ancestry when moving a branch to ${destination} with a renamed primary column`, () =>
2425
Promise.all(
@@ -57,6 +58,20 @@ describe("tree-tables > closure-table > custom primary column", () => {
5758
).to.have.members(expectedAncestors)
5859

5960
expect(await repository.count()).to.equal(4)
61+
const junction = repository.metadata.closureJunctionTable
62+
const closureCount = await dataSource
63+
.createQueryBuilder()
64+
.select("COUNT(*)", "count")
65+
.from(junction.tablePath, "closure")
66+
.getRawOne()
67+
const expectedClosureCounts = {
68+
"other root": 7,
69+
"same tree": 10,
70+
root: 5,
71+
}
72+
expect(Number(closureCount.count)).to.equal(
73+
expectedClosureCounts[destination],
74+
)
6075
}),
6176
))
6277
}

0 commit comments

Comments
 (0)