Skip to content

Fix IQueryable select projection path#562

Open
slorello89 wants to merge 3 commits intomainfrom
fix/issue-507-select-projection
Open

Fix IQueryable select projection path#562
slorello89 wants to merge 3 commits intomainfrom
fix/issue-507-select-projection

Conversation

@slorello89
Copy link
Member

@slorello89 slorello89 commented Mar 18, 2026

Issue: #507

Root cause: IQueryProvider.CreateQuery(Expression) was using the full IQueryable<T> type as the collection generic argument and then invoking the internal RedisCollection<T> constructor with public-only reflection, so projected queries failed before enumeration.

Fix: derive the sequence element type from the query expression, invoke the internal constructor with non-public binding flags, and preserve the original document root type on projected collections.

Tests run:

  • dotnet test test/Redis.OM.Unit.Tests/Redis.OM.Unit.Tests.csproj --filter FullyQualifiedName~Redis.OM.Unit.Tests.RediSearchTests.SearchTests.TestSelectViaNonGenericQueryProvider --no-restore
  • dotnet test test/Redis.OM.Unit.Tests/Redis.OM.Unit.Tests.csproj -f net7.0 --filter FullyQualifiedName~Redis.OM.Unit.Tests.RediSearchTests.SearchFunctionalTests.SelectNameViaNonGenericQueryProvider --no-restore
  • dotnet test test/Redis.OM.Unit.Tests/Redis.OM.Unit.Tests.csproj -f net6.0 --filter FullyQualifiedName~Redis.OM.Unit.Tests.RediSearchTests.SearchFunctionalTests.SelectNameViaNonGenericQueryProvider --no-restore

Risk: low. The change is scoped to query-provider instantiation for projected queryables; the main remaining risk is compatibility with other expression shapes that also flow through non-generic CreateQuery.


Note

Low Risk
Low risk, scoped to RedisQueryProvider.CreateQuery(Expression) instantiation logic for projected queryables; primary risk is unexpected element/root type inference for uncommon expression shapes.

Overview
Fixes projection queries created via the non-generic IQueryProvider.CreateQuery(Expression) path so Select/chained projections no longer fail before enumeration.

The provider now derives the sequence element type from the expression type, uses reflection that can invoke non-public RedisCollection<T> constructors, and preserves the original document RootType on projected collections. Adds unit + functional coverage for selecting Name via manually-built Queryable.Select expressions using the non-generic provider.

Written by Cursor Bugbot for commit 5237572. This will update automatically on new commits. Configure here.

@jit-ci
Copy link

jit-ci bot commented Mar 18, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant