Skip to content
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

Fix case-insensitive logic for column names in SQL queries #33885

Open
roji opened this issue Jun 3, 2024 · 1 comment
Open

Fix case-insensitive logic for column names in SQL queries #33885

roji opened this issue Jun 3, 2024 · 1 comment

Comments

@roji
Copy link
Member

roji commented Jun 3, 2024

Given the following entity type:

public class TwoFieldEntity
{
    public string FirstProperty { get; set; }
    public string SecondProperty { get; set; }
}

The following query works:

await context
    .Set<TwoFieldEntity>()
    .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

@caiogranero
Copy link

Hi @roji,

I took a look at this issue and I believe I can fix it. Can I work on this?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants