Skip to content

Commit

Permalink
fix-has-any (#16)
Browse files Browse the repository at this point in the history
* commit

* fixes

* fix ingest

* fixes

* Update SampleObject3.cs

* done all fixes

* fixes
  • Loading branch information
barnuri authored Jan 6, 2025
1 parent ff579a8 commit d159f4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions LinqToKql.Test/Translator/WhereTranslatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Task Translate_ShouldHandleWhereWithOrAsync()
public Task Translate_ShouldHandleWhereWitContainsAsync()
=> AssertQueryAsync(
_q.Where(x => new string[] { "name1", "name2", "name3" }.Contains(x.Name)),
[_tableName, "where Name has_all ('name1', 'name2', 'name3')"]
[_tableName, "where Name has_any ('name1', 'name2', 'name3')"]
);

[Fact]
Expand All @@ -33,7 +33,7 @@ public async Task Translate_ShouldHandleWhereWitContainsWithListAsync()
var test = new List<string> { "name1", "name2", "name3" };
await AssertQueryAsync(
_q.Where(x => test.Contains(x.Name)),
[_tableName, "where Name has_all ('name1', 'name2', 'name3')"]
[_tableName, "where Name has_any ('name1', 'name2', 'name3')"]
);
}

Expand Down Expand Up @@ -111,14 +111,14 @@ await AssertQueryAsync(
public Task Translate_WhereListInAsync()
=> AssertQueryAsync(
_q.Where(x => x.Numbers.Contains(1)).Select(x => new { x.Date, x.Description }),
[_tableName, $"where Numbers has_all (1)", "project Date, Description"]
[_tableName, $"where Numbers has_any (1)", "project Date, Description"]
);

[Fact]
public Task Translate_WhereListNotInAsync()
=> AssertQueryAsync(
_q.Where(x => !x.Numbers.Contains(1)).Select(x => new { x.Date, x.Description }),
[_tableName, $"where not(Numbers has_all (1))", "project Date, Description"]
[_tableName, $"where not(Numbers has_any (1))", "project Date, Description"]
);

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion LinqToKql/Translator/Builders/LinqToKQLTranslatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private string BuildFilterCustomMethodCall(MethodCallExpression methodCall)
return methodName switch
{
nameof(string.Contains) when methodCall.Method.DeclaringType == typeof(string) => $"{leftSideKql} has_cs {rightSideKql}",
nameof(Enumerable.Contains) => $"{leftSideKql} has_all ({rightSideKql.TrimStart('(').TrimEnd(')')})",
nameof(Enumerable.Contains) => $"{leftSideKql} has_any ({rightSideKql.TrimStart('(').TrimEnd(')')})",
nameof(string.StartsWith) => $"{leftSideKql} startswith_cs {rightSideKql}",
nameof(string.EndsWith) => $"{leftSideKql} endswith_cs {rightSideKql}",
nameof(string.Equals) => $"{leftSideKql} == {rightSideKql}",
Expand Down

0 comments on commit d159f4d

Please sign in to comment.