Skip to content

Commit

Permalink
fix: For MS SQL Server use lowercase "sys"."columns" reference. (#8400)…
Browse files Browse the repository at this point in the history
… (#8401)

For MS SQL Server change uppercase table reference "SYS"."COLUMNS" to lowercase "sys"."columns" to avoid table name mismatch when database collation is ALTER'ed to a case-sensitive collation.
  • Loading branch information
krystalmonolith committed Nov 23, 2021
1 parent 3286519 commit e8a0f92
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/driver/sqlserver/SqlServerQueryRunner.ts
Expand Up @@ -1672,7 +1672,7 @@ export class SqlServerQueryRunner extends BaseQueryRunner implements QueryRunner
return `SELECT "TABLE_CATALOG", "TABLE_SCHEMA", "COLUMN_NAME", "TABLE_NAME" ` +
`FROM "${TABLE_CATALOG}"."INFORMATION_SCHEMA"."COLUMNS" ` +
`WHERE ` +
`EXISTS(SELECT 1 FROM "${TABLE_CATALOG}"."SYS"."COLUMNS" "S" WHERE OBJECT_ID("TABLE_CATALOG" + '.' + "TABLE_SCHEMA" + '.' + "TABLE_NAME") = "S"."OBJECT_ID" AND "COLUMN_NAME" = "S"."NAME" AND "S"."is_identity" = 1) AND ` +
`EXISTS(SELECT 1 FROM "${TABLE_CATALOG}"."sys"."columns" "S" WHERE OBJECT_ID("TABLE_CATALOG" + '.' + "TABLE_SCHEMA" + '.' + "TABLE_NAME") = "S"."OBJECT_ID" AND "COLUMN_NAME" = "S"."NAME" AND "S"."is_identity" = 1) AND ` +
`(${conditions})`;
}).join(" UNION ALL ");

Expand Down

0 comments on commit e8a0f92

Please sign in to comment.