[CSHARP-4247] Permit empty objects as expressions in $set and $addFields aggregation stages Created: 11/Jul/22  Updated: 27/Oct/23  Resolved: 07/Sep/22

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: PM Bot Assignee: James Kovacs
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
Server Compat: 6.1
Upstream Changes Summary:

DRIVERS-2374:
$addFields and $set will no longer throw an error if you want to set a path to an empty object.
For example the stage {$set: {a: {}}} would take an incoming document and set the 'a' field to an empty object.
The behavior of $project behavior has not been changed and in order to get the same behavior a user would still have to wrap the object with $literal like this: {$project: {a: {$literal: {}}}}


 Description   

This ticket was split from DRIVERS-2374, please see that ticket for a detailed description.



 Comments   
Comment by James Kovacs [ 07/Sep/22 ]

The LINQ3 AST contains AstAddFieldsStage and AstSetStage, though we currently don't translate any LINQ constructs to these stages. Both stages allow computed fields set to empty documents. No work is required to support this feature when these stages are supported.

Generated at Wed Feb 07 21:47:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.