-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: 2.19.2
-
Component/s: None
-
None
-
Fully Compatible
-
Not Needed
-
Summary
A LINQ projection that used to work is now failing. Specifically, `x => x`.
We have helper method to wrap most FindOneAndUpdates to consistently handles things like "ID does not exist". To reduce code, there's an overload with no projection that just calls the overload that supports projection with a barebones `x => x`.
After upgrading to 2.19.2, this is now throwing an exception. We are still using the V2 LINQ translator.
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
When upgrading driver from 2.19.1 to 2.19.2.
MongoDB 6.0.x running in Atlas.
How to Reproduce
Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example.
var id = ObjectId.GenerateNewId(); var update = Builders<TDocument>.Update.Set("example", 2); var options = new FindOneAndUpdateOptions<TDocument>() { Projection = Builders<TDocument>.Projection.Expression(x => x), }; collection.FindOneAndUpdate<TDocument, TDocument>(x => x.Id == id, update, options);
Additional Background
Stack trace:
System.NotSupportedException : $project or $group does not support {document}.
Stack Trace:
41 at MongoDB.Driver.Linq.Linq2Implementation.Translators.AggregateLanguageTranslator.TranslateValue(Expression node)
42 at MongoDB.Driver.Linq.Linq2Implementation.Translators.AggregateLanguageTranslator.Translate(Expression node, ExpressionTranslationOptions translationOptions)
43 at MongoDB.Driver.Linq.Linq2Implementation.Translators.AggregateProjectTranslator.TranslateProject(Expression expression, ExpressionTranslationOptions translationOptions)
44 at MongoDB.Driver.Linq.Linq2Implementation.Translators.AggregateProjectTranslator.Translate[TDocument,TResult](Expression`1 projector, IBsonSerializer`1 parameterSerializer, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions)
45 at MongoDB.Driver.Linq.Linq2Implementation.LinqProviderAdapterV2.TranslateExpressionToProjection[TInput,TOutput](Expression`1 expression, IBsonSerializer`1 inputSerializer, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions)
46 at MongoDB.Driver.ExpressionProjectionDefinition`2.Render(IBsonSerializer`1 inputSerializer, IBsonSerializerRegistry serializerRegistry, LinqProvider linqProvider)
47 at MongoDB.Driver.MongoCollectionImpl`1.CreateFindOneAndUpdateOperation[TProjection](FilterDefinition`1 filter, UpdateDefinition`1 update, FindOneAndUpdateOptions`2 options)
48 at MongoDB.Driver.MongoCollectionImpl`1.FindOneAndUpdateAsync[TProjection](IClientSessionHandle session, FilterDefinition`1 filter, UpdateDefinition`1 update, FindOneAndUpdateOptions`2 options, CancellationToken cancellationToken)
49 at MongoDB.Driver.MongoCollectionImpl`1.<>c__DisplayClass60_0`1.<FindOneAndUpdateAsync>b__0(IClientSessionHandle session)
50 at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
...my code...
- depends on
-
CSHARP-4742 Find and Aggregate Project should work with identity projection x => x on all server versions
- Closed