Fix case-insensitive logic for column names in SQL queries
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
Given the following entity type:
```c#
public class TwoFieldEntity
{
public string FirstProperty { get; set; }
public string SecondProperty { get; set; }
}
```
The following query works:
```c#
await context
.Set()
.FromSqlRaw("select 'x' FirstPROPERTY, 'y' SecondPROPERTY")
.ToListAsync();
```
This is because in our reader column logic, we assume column names are case-insensitive; SQL Server indeed does not allow creating a table with two columns that differ from one another only by case, but this isn't true of other databases (e.g. PostgreSQL, possibly SQLite).
Unfortunately, change the logic to be case-sensitive would break any users currently using SQL Server and using names that match only case-insensitively; that would be too much. However, we can allow providers to specify whether they want case-sensitive or insensitive behavior.
Originally flagged by @simonmckenzie in #33748
Contributor guide
Assessment
This issue has not been assessed yet.