-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Quote collation names by default #37463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
QuerySqlGeneratorandMigrationsSqlGenerator - 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
There was a problem hiding this 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
Fixes #37462