Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Redis.OM/Common/ExpressionParserUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,11 @@ private static string TranslateAnyForEmbeddedObjects(MethodCallExpression exp, L

private static string ValueToString(object value)
{
if (value is null)
{
return "null";
}

Type valueType = value.GetType();

if (valueType == typeof(double) || Nullable.GetUnderlyingType(valueType) == typeof(double))
Expand Down
7 changes: 6 additions & 1 deletion src/Redis.OM/Common/ExpressionTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,12 @@ internal static string TranslateBinaryExpression(BinaryExpression binExpression,
if (rightResolvesToNull)
{
dialectNeeded |= 1 << 1;
return $"(ismissing({leftContent}))";
return binExpression.NodeType switch
{
ExpressionType.Equal => $"(ismissing({leftContent}))",
ExpressionType.NotEqual => $"-(ismissing({leftContent}))",
_ => throw new ArgumentException($"The expression node type {binExpression.NodeType} is not supported"),
};
}

var rightContent = ExpressionParserUtilities.GetOperandStringForQueryArgs(binExpression.Right, parameters, ref dialectNeeded, treatBooleanMemberAsUnary: true);
Expand Down
17 changes: 17 additions & 0 deletions test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4156,5 +4156,22 @@ await _substitute.Received().ExecuteAsync("FT.SEARCH",
"0",
"100");
}

[Fact]
public async Task TestIsNotNull()
{
_substitute.ClearSubstitute();
_substitute.ExecuteAsync(Arg.Any<string>(), Arg.Any<object[]>()).Returns(_mockReply);
var collection = new RedisCollection<ObjectWithNullableStrings>(_substitute);
await collection.Where(x => x.String1 != null).ToListAsync();
await _substitute.Received().ExecuteAsync("FT.SEARCH",
$"{nameof(ObjectWithNullableStrings).ToLower()}-idx",
"-(ismissing(@String1))",
"DIALECT",
2,
"LIMIT",
"0",
"100");
}
}
}