Skip to content

LIKE and case sensitivity #9126

@roji

Description

@roji

While looking at the client-side implementation of LIKE, I noticed the following line:

if (matchExpression.Equals(pattern, StringComparison.OrdinalIgnoreCase))

(the regex below similarly has RegexOptions.IgnoreCase).

Now, I don't know SqlServer or the SQL Standard that well, but I'm wondering about the "correct" default for LIKE case sensitivity. PostgreSQL LIKE is case-sensitive (and an alternative ILIKE exists for insensitive). At the very least Oracle seems to be case-sensitive by default as well.

Given that I'm popping this out a bit last minute with 2.0.0 around the corner, I'm guessing that at least the client-side implementation is going to remain case-insensitive. I'm wondering what you'd recommend for the Npgsql behavior: to align with the "default" EF Core behavior, I'd generate case-insensitive ILIKE clauses rather than LIKE. But to cause less surprise with PostgreSQL users who are used to LIKE being sensitive, EF.Functions.Like() should generate LIKE - and accept that there are going to be variations across providers with this kind of thing.

Let me know what you think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions