Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Jan 8, 2026

Fixes #37462

Copilot AI review requested due to automatic review settings January 8, 2026 07:36
@roji roji requested a review from a team as a code owner January 8, 2026 07:36
@roji roji enabled auto-merge (squash) January 8, 2026 07:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #37462 by changing the default behavior to quote collation names in SQL generation to prevent SQL injection vulnerabilities. The implementation adds quoting at the relational base layer and provides SQL Server-specific overrides that validate collation name characters instead of quoting (since SQL Server doesn't support quoted collation names).

  • Collation names are now quoted by default in QuerySqlGenerator and MigrationsSqlGenerator
  • SQL Server overrides the quoting behavior with character validation (alphanumeric and underscores only)
  • Added error message resource for invalid SQL Server collation names
  • Added test coverage for SQL Server's invalid collation name validation

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/EFCore.Relational/Query/QuerySqlGenerator.cs Changed to quote collation names by default using DelimitIdentifier for security, with explanatory comments about provider overrides
src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs Changed to quote collation names in column definitions for consistency with query generation
src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs Added VisitCollate override to validate collation name characters instead of quoting (SQL Server doesn't support quoted collation names)
src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs Added character validation for collation names in ColumnDefinition method
src/EFCore.SqlServer/Properties/SqlServerStrings.resx Added error message resource for invalid collation names
src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs Generated code for the new error message resource
test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs Added test to verify invalid collation names throw the correct exception
Files not reviewed (1)
  • src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported

Copilot AI review requested due to automatic review settings January 8, 2026 11:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported

@roji roji merged commit 6ebaec6 into dotnet:main Jan 8, 2026
7 checks passed
@roji roji deleted the CollateQuoting branch January 8, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate EF.Functions.Collate input

2 participants