Skip to content

[BUG] Case-sensitive filtering of strings with eql is case-insensitive when using Postgres #488

@fabian12943

Description

@fabian12943

Hi,

I’ve encountered an issue with the eql filter for strings while using PostgreSQL as the database for my Rails application. The current implementation of the filter_string_eql method does not enforce case-sensitive filtering, which is problematic when exact, case-sensitive matches are required.

Here’s the current implementation of filter_string_eql:

def filter_string_eql(scope, attribute, value, is_not: false)
  clause = { attribute => value }
  is_not ? scope.where.not(clause) : scope.where(clause)
end

Steps to Reproduce:

Given a user record with an email attribute set to test@example.com, a call such as:

filter_string_eql(User.all, :email, ["TEST@example.com"])

unexpectedly includes that record in the resulting scope.

Expected Behavior:

The filter_string_eql method should enforce case-sensitive filtering. In the above example, the method should exclude the record because TEST@example.com is not an exact, case-sensitive match for `test@example.com.

Thank you for investigating this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions