diff --git a/README.md b/README.md index 35558ad5..ca5c7f01 100644 --- a/README.md +++ b/README.md @@ -363,6 +363,7 @@ We'd love your contributions! If you want to contribute please read our [Contrib * [@JuliusMikkela](https://github.com/JuliusMikkela) * [@imansafari1991](https://github.com/imansafari1991) * [@AndersenGans](https://github.com/AndersenGans) +* [@mdrakib](https://github.com/mdrakib) [Logo]: images/logo.svg diff --git a/src/Redis.OM/Aggregation/AggregationPredicates/QueryPredicate.cs b/src/Redis.OM/Aggregation/AggregationPredicates/QueryPredicate.cs index 9e9b235f..5a6a27ef 100644 --- a/src/Redis.OM/Aggregation/AggregationPredicates/QueryPredicate.cs +++ b/src/Redis.OM/Aggregation/AggregationPredicates/QueryPredicate.cs @@ -94,6 +94,27 @@ protected override void ValidateAndPushOperand(Expression expression, Stack(); + + if (uni.Operand is BinaryExpression be) + { + SplitBinaryExpression(be, operandStack); + } + else + { + ValidateAndPushOperand(uni.Operand, operandStack); + } + + var val = string.Join(" ", operandStack); + if (uni.NodeType == ExpressionType.Not) + { + val = $"(-({val}))"; + } + + stack.Push(val); + } else { throw new ArgumentException("Invalid Expression Type"); diff --git a/test/Redis.OM.Unit.Tests/RediSearchTests/AggregationFunctionalTests.cs b/test/Redis.OM.Unit.Tests/RediSearchTests/AggregationFunctionalTests.cs index d675c9ba..f31672a8 100644 --- a/test/Redis.OM.Unit.Tests/RediSearchTests/AggregationFunctionalTests.cs +++ b/test/Redis.OM.Unit.Tests/RediSearchTests/AggregationFunctionalTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Redis.OM.Aggregation; using Redis.OM.Contracts; using System.Threading.Tasks; @@ -285,5 +286,21 @@ public async Task GetGroupCountWithNegationQuery() Assert.True(1 <= result["COUNT"]); } } + + [Fact] + public async Task TestListNotContains() + { + Setup(); + var collection = new RedisAggregationSet(_connection); + + var names = new List { "Beaker", "Rakib" }; + var people = await collection + .Where(x => !names.Contains(x.RecordShell.Name) && x.RecordShell.Name != "fake") + .Load(x => x.RecordShell.Name) + .ToListAsync(); + + Assert.Contains(people, x => x.Hydrate().Name == "Statler"); + Assert.DoesNotContain(people, x => x.Hydrate().Name == "Beaker"); + } } }