You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't set the value from string to null.
basic example code:
Future<Map<String, dynamic>?> exanple(
{
required ObjectId id,
required String? oldValue,
required String? newValue,
}) async {
return await mongodb.dbCollection.findAndModify(
query: where.id(id).eq('value', oldValue),
update: (AggregationPipelineBuilder()..addStage(SetStage({'value': newValue}))).build(),
returnNew: true,
);
}
print(await example(id: ObjectId(), oldValue: 'oldValue', newValue: null)); //got the map with the `value` field is 'oldValue'. (should be null)
but this function will work successfully when I set any string for newValue: property.
What happened?
The text was updated successfully, but these errors were encountered:
SittiphanSittisak
changed the title
The SetStage can't work with null value.
The SetStage() in AggregationPipelineBuilder().addStage(SetStage()) isn't working with setting the field to the null value.
Mar 13, 2023
There is a problem in the code so that all the stages with a null value are excluded. I consider it a bug, but I have to do some tests to see if it is possible to simply remove that selection.
The reason why you are able to unset, but not to set, is that you are doing two different operations: unsetting, you are removing the field from the document, setting with a null value, you change the value of the field to null, but the field is still in the document.
Aside of the new mongo_db_driver package, I have also posted a new mongo_db_query one that should not have the problem you reported. If you could test it it would be great!
I can't set the value from string to null.
basic example code:
but this function will work successfully when I set any string for
newValue:
property.What happened?
The text was updated successfully, but these errors were encountered: