Skip to content

Commit

Permalink
fix: Casting to IQueryable no longer drops chunk size (#455)
Browse files Browse the repository at this point in the history
* fix: Casting to IQueryable no longer drops chunk size

* including saveState

* adding contributor to readme

---------

Co-authored-by: Lennon <[email protected]>
Co-authored-by: slorello89 <[email protected]>
  • Loading branch information
3 people authored Jul 11, 2024
1 parent 66c2f0c commit eff0dc9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ We'd love your contributions! If you want to contribute please read our [Contrib
* [@axnetg](https://github.com/axnetg)
* [@abbottdev](https://github.com/abbottdev)
* [@PrudiusVladislav](https://github.com/PrudiusVladislav)
* [@CormacLennon](https://github.com/CormacLennon)

<!-- Logo -->
[Logo]: images/logo.svg
Expand Down
8 changes: 6 additions & 2 deletions src/Redis.OM/Searching/RedisQueryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ public IQueryable CreateQuery(Expression expression)
(IQueryable)Activator.CreateInstance(
typeof(RedisCollection<>).MakeGenericType(elementType),
this,
expression);
expression,
StateManager,
null,
_saveState,
_chunkSize);
}
catch (TargetInvocationException e)
{
Expand All @@ -102,7 +106,7 @@ public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
where TElement : notnull
{
var booleanExpression = expression as Expression<Func<TElement, bool>>;
return new RedisCollection<TElement>(this, expression, StateManager, booleanExpression, true);
return new RedisCollection<TElement>(this, expression, StateManager, booleanExpression, _saveState, _chunkSize);
}

/// <inheritdoc/>
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 @@ -3822,5 +3822,22 @@ public async Task EnumerateAllButAllExpired()

Assert.Empty(people);
}

[Fact]
public void TestBasicQueryCastToIQueryable()
{
_substitute.ClearSubstitute();
_substitute.Execute(Arg.Any<string>(), Arg.Any<object[]>()).Returns(_mockReply);
var y = 33;
var collection = new RedisCollection<Person>(_substitute, 1234) as IQueryable<Person>;
_ = collection.Where(x => x.Age < y).ToList();
_substitute.Received().Execute(
"FT.SEARCH",
"person-idx",
"(@Age:[-inf (33])",
"LIMIT",
"0",
"1234");
}
}
}

0 comments on commit eff0dc9

Please sign in to comment.