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

Support for case insensitive filtering for string #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ishit-parikh-hs
Copy link

Added a boolean param in Filter to support case-insensitive filter for strings and operators - StartsWith, EndsWith, Contains and Doesnotcontain

@yogen-darji-hs
Copy link

support for this #15

src/Filter.cs Outdated
/// Gets or sets the filtering logic. Can be set to "or" or "and". Set to null unless Filters is set.
/// </summary>
[DataMember(Name = "ignoreCase")]
public bool ignoreCase { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use Pascal Case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use Pascal Case?

Thanks for finding out, missed to make it Pascal in hurry. Committing after correction.

@ishit-parikh-hs
Copy link
Author

Property name changed to Pascal case

@linmasaki linmasaki self-requested a review October 30, 2021 14:57
@linmasaki linmasaki linked an issue Oct 30, 2021 that may be closed by this pull request
@@ -37,6 +37,12 @@ public class Filter
[DataMember(Name = "logic")]
public string Logic { get; set; }

/// <summary>
/// Gets or sets the filtering logic. Can be set to "or" or "and". Set to null unless Filters is set.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This summary is required to adjust.

Number = 2,
Identification = Guid.Parse("a3ee172c-fdf3-4390-9bb1-d5a70ccfbb3b"),
Name = "CoCo",
Introduce = "I'm CoCo",
Salary = 2500,
Weight = 69.2,
Gender = Gender.M,
Birthday = new DateTime(1986,10,10),
Birthday = new DateTime(1986, 10, 9, 16, 0, 0),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the reason for changing this test data value?

Number = 4,
Identification = Guid.Parse("a4e918a9-46f9-4a13-8f37-e8771bf7dc5c"),
Name = "Rock",
Introduce = "I'm Rock",
Salary = 1750,
Weight = 82.1,
Gender = Gender.M,
Birthday = new DateTime(1976,11,6),
Birthday = new DateTime(1976, 11, 5, 16, 0, 0),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@@ -55,16 +57,48 @@ public void InputParameter_SubPropertyContains_CheckResultCount()
Assert.AreEqual(2, result2.Total);
}

[Test]
public void InputParameter_SubPropertyContains_Case_Insensitive_CheckResultCount()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide a sample of JSON string(with ignoreCase property) that request in a real scenario?

@linmasaki
Copy link
Owner

linmasaki commented Oct 31, 2021

By the way, I found some references that indicated the case sensitivity depends on the database provider. For example, SQLite and PostgreSQL are case-sensitive by default, others like SQL Server and MySQL are case-insensitive. On the other hand, Use string.ToLower might cause a performance issue.

Overriding case sensitivity in a query via EF.Functions.Collate (or by calling string.ToLower) can have a very significant impact on your application's performance.

References:

  1. toODataString returns an invalid string when using case insensitive search
  2. Entity Framework Core - Contains is case sensitive or case insensitive
  3. Collations and Case Sensitivity

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

Successfully merging this pull request may close these issues.

IgnoreCase is not working for string comparisons
3 participants