ChilliCream / ChilliCream/graphql-platform

Contains FilterExpressionBuild to compare using StringComparison

Open
#6,289 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ hot chocolate Area: Data
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

Product

Hot Chocolate

Is your feature request related to a problem?

Yes, filtering strings with StringComparison (to ignore case sensitivity for example) isn't currently possible.

The solution you'd like

In HotChocolate.Data.Filters.Expressions.FilterExpressionBuilder, Add:

private static readonly MethodInfo _containsWithStringComparison = ReflectionUtils.ExtractMethod<string>(x => x.Contains(default(string)!, default));

Add overload to the Contains method with the signature or where a contains method for strings makes more sense.

public static Expression Contains(Expression property, object value, StringComparison stringComparison)
{
 return Expression.AndAlso(Expression.NotEqual(property, _null),
                              Expression.Call(property,
                                              _containsWithStringComparison,
                                              CreateParameter(value, property.Type),
                                              Expression.Constant(stringComparison, typeof(StringComparison))));
}

Possibly make the QueryableString*Handlers have the option to use StringComparison.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in HotChocolate.Data.Filters.Expressions.FilterExpressionBuilder and inspect the existing Contains implementation and its reflection helpers. Add support for the StringComparison overload described in the issue, then review the QueryableString*Handlers to determine whether they should expose the option. Done means string filtering can compare with a specified StringComparison without breaking existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.