Repository navigation
fix: read closure-table primary values through column metadata - #12907
Conversation
commit: |
Code Review by Qodo
1.
|
|
Addressed in ed33893. The review is correct: Kept the four-entity assertion and added a direct count of All four tests in the custom-primary-column suite passed with SQL.js/better-sqlite3. TypeScript compilation, ESLint, formatting, and whitespace checks passed. No runtime-code change was needed for this finding. |
|
The Oracle CI failure occurs in the reparenting INSERT ... SELECT: Oracle rejects AS before table aliases. Removed AS from the two table aliases, preserving the query and parameters. The regression remains enabled for Oracle. All four custom-primary-column cases pass locally with SQL.js/better-sqlite3; TypeScript compilation and lint/format/whitespace checks pass (existing lint warnings remain). Oracle verification is pending the new CI run. |
Description of change
Fixes #12904.
When a primary property maps to a differently named database column, closure-table reparenting reads the DELETE parameter using the database column name on the entity object. That returns undefined, so old ancestor links remain. Cross-root moves return stale ancestors; same-tree moves can fail with a unique-constraint error.
Read the primary value through
column.getEntityValue(entity), matching the existing INSERT phase. The fix changes neither SQL shape nor query count.Three regression cases cover moving a branch with a child across roots, within the same tree, and to a new root. They check exact ancestors and closure-record counts. The linked issue includes a standalone reproduction.
Validation on Windows / Node 22.17.1:
Pull-Request Checklist
f279fd1367f24ad108a1b11cf833f1620274088d.Review follow-up
Addressed in ed33893. The review is correct:
repository.count()checks entity rows, not closure-junction rows. The original PR description overstated what that assertion verified.Kept the four-entity assertion and added a direct count of
repository.metadata.closureJunctionTable.tablePath. Expected junction totals are 7 for moving across roots, 10 within the same tree, and 5 when detaching as a root. These complement the exact leaf-ancestor assertions. Added the #12904 issue reference as well.All four tests in the custom-primary-column suite passed with SQL.js/better-sqlite3. TypeScript compilation, ESLint, formatting, and whitespace checks passed. No runtime-code change was needed for this finding.