From 091acb88700225536967f423114a3b5b8be2b52d Mon Sep 17 00:00:00 2001 From: Vitaly Frolov <39946781+vitusik@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:13:28 +0200 Subject: [PATCH] fix the wild card logic (#9) * fix the wild card logic * update test name --------- Co-authored-by: Bar Nuri --- .../Translator/WhereTranslatorTests.cs | 20 +++++++++---------- LinqToKql/Extensions/IQueryableExtension.cs | 4 ++-- .../Builders/LinqToKQLTranslatorBase.cs | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/LinqToKql.Test/Translator/WhereTranslatorTests.cs b/LinqToKql.Test/Translator/WhereTranslatorTests.cs index 3eec281..f6ef255 100644 --- a/LinqToKql.Test/Translator/WhereTranslatorTests.cs +++ b/LinqToKql.Test/Translator/WhereTranslatorTests.cs @@ -155,8 +155,8 @@ public Task Translate_WhereStringNotEndsWithAsync() [Theory] [InlineData("na", "==")] [InlineData("%na%", "has_cs")] - [InlineData("%na", "startswith_cs")] - [InlineData("na%", "endswith_cs")] + [InlineData("%na", "endswith_cs")] + [InlineData("na%", "startswith_cs")] public Task Translate_LikeAsync(string pattern, string action) => AssertQueryAsync( _q.Like(y => y.Name, pattern, '%'), @@ -166,8 +166,8 @@ public Task Translate_LikeAsync(string pattern, string action) [Theory] [InlineData("na", "==")] [InlineData("%na%", "has_cs")] - [InlineData("%na", "startswith_cs")] - [InlineData("na%", "endswith_cs")] + [InlineData("%na", "endswith_cs")] + [InlineData("na%", "startswith_cs")] public Task Translate_LikeByPropNameAsync(string pattern, string action) => AssertQueryAsync( _q.Like("Name", pattern, '%'), @@ -177,8 +177,8 @@ public Task Translate_LikeByPropNameAsync(string pattern, string action) [Theory] [InlineData("na", "==")] [InlineData("*na*", "has_cs")] - [InlineData("*na", "startswith_cs")] - [InlineData("na*", "endswith_cs")] + [InlineData("*na", "endswith_cs")] + [InlineData("na*", "startswith_cs")] public Task Translate_LikeByStringMethodAsync(string pattern, string action) => AssertQueryAsync( _q.Where(x => x.Name.KqlLike(pattern, '*')), @@ -186,17 +186,17 @@ public Task Translate_LikeByStringMethodAsync(string pattern, string action) ); [Fact] - public Task Translate_WhereStringLikeStartsWithAsync() + public Task Translate_WhereStringLikeStartsWithWildCardAsync() => AssertQueryAsync( _q.Where(x => EF.Functions.Like(x.Name, "%na")).Select(x => new { x.Date, x.Description }), - [_tableName, $"where Name startswith_cs 'na'", "project Date, Description"] + [_tableName, $"where Name endswith_cs 'na'", "project Date, Description"] ); [Fact] - public Task Translate_WhereStringLikeEndsWithAsync() + public Task Translate_WhereStringLikeEndsWithWithWildCardAsync() => AssertQueryAsync( _q.Where(x => EF.Functions.Like(x.Name, "na%")).Select(x => new { x.Date, x.Description }), - [_tableName, $"where Name endswith_cs 'na'", "project Date, Description"] + [_tableName, $"where Name startswith_cs 'na'", "project Date, Description"] ); [Fact] diff --git a/LinqToKql/Extensions/IQueryableExtension.cs b/LinqToKql/Extensions/IQueryableExtension.cs index d393245..113706e 100644 --- a/LinqToKql/Extensions/IQueryableExtension.cs +++ b/LinqToKql/Extensions/IQueryableExtension.cs @@ -118,12 +118,12 @@ public static IQueryable Like(this IQueryable q, Expression