Repository navigation
Conversation
The LEFT JOIN on sys.computed_columns matched only by column name, causing columns in unrelated tables to be misidentified as computed when they shared a name with a computed column in another table. This produced unnecessary migrations on every synchronize or migration:generate run. Add OBJECT_NAME and OBJECT_SCHEMA_NAME conditions to the join so that computed column metadata is matched to the correct table and schema. Closes typeorm#12019
Review Summary by QodoFix MSSQL computed-column cross-table JOIN scope issue
WalkthroughsDescription• Fix MSSQL computed-columns JOIN to include table and schema filters - Prevents cross-table column name collisions from misidentifying regular columns • Add regression test for computed column name collision scenario - Verifies no unnecessary migrations generated when column names match across tables Diagramflowchart LR
A["MSSQL Schema Query"] -->|"Add table/schema filters"| B["Computed Columns JOIN"]
B -->|"Correctly scoped to"| C["Specific Table & Schema"]
D["Regression Test"] -->|"Validates"| E["No False Positives"]
E -->|"Prevents"| F["Unnecessary Migrations"]
File Changes1. src/driver/sqlserver/SqlServerQueryRunner.ts
|
Code Review by Qodo
1.
|
…e correctness Also add issue reference comment to regression test for traceability.
|
Persistent review updated to latest commit e94b670 |
|
|
Persistent review updated to latest commit 5ecb780 |
commit: |
…ry (#12288) Co-authored-by: Piotr Kuczynski <> Co-authored-by: Prakhar Chhalotre <[email protected]> (cherry picked from commit 36728fc)
…ry (#12288) Co-authored-by: Piotr Kuczynski <> Co-authored-by: Prakhar Chhalotre <[email protected]> Co-authored-by: Lucian Mocanu <[email protected]> (cherry picked from commit 36728fc)



Summary
sys.computed_columnsLEFT JOIN inSqlServerQueryRunnerto includeOBJECT_NAMEandOBJECT_SCHEMA_NAMEconditionsRoot Cause
The join condition only matched by column name (
COL_NAME(...) = "COLUMN_NAME"), with no table or schema filter. This caused cross-table computed column definitions to leak into unrelated tables.Changes
src/driver/sqlserver/SqlServerQueryRunner.ts: AddOBJECT_NAMEandOBJECT_SCHEMA_NAMEconditions to the computed-columns join (2 lines)TableWithComputed,TableWithRegular) sharing column namefullName, asserting that schema diff produces no queries after initial creationTest plan
pnpm tsc --noEmitpassesCloses #12019