Skip to content

Commit

Permalink
Fix update expressions, close #32
Browse files Browse the repository at this point in the history
  • Loading branch information
nightroman committed Nov 10, 2019
1 parent e95e731 commit ab8f618
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Release-Notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Mdbc Release Notes

## v6.0.2

Fix update expression conversion, #32

## v6.0.1

**Mdbc.Dictionary and Mdbc.Collection**
Expand Down
4 changes: 4 additions & 0 deletions Src/Actor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ static BsonValue ToBsonValue(object value, DocumentInput input, int depth)
return ToBsonValue(value, null, depth);
}
}
public static BsonDocument ToBsonDocumentFromDictionary(IDictionary dictionary)
{
return ToBsonDocumentFromDictionary(null, dictionary, null, null, 0);
}
//! IConvertibleToBsonDocument (e.g. Mdbc.Dictionary) must be converted before if source and properties are null
static BsonDocument ToBsonDocumentFromDictionary(BsonDocument source, IDictionary dictionary, DocumentInput input, IEnumerable<Selector> properties, int depth)
{
Expand Down
2 changes: 1 addition & 1 deletion Src/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static bool TryBsonDocument(object value, out BsonDocument result)
//! after IConvertibleToBsonDocument
if (value is IDictionary dictionary)
{
result = new BsonDocument(dictionary);
result = Actor.ToBsonDocumentFromDictionary(dictionary);
return true;
}

Expand Down
6 changes: 6 additions & 0 deletions Tests/Api.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ task UpdateDefinition {
equals $r1 $r2
) | Out-String
}

task Issue32 {
$manifestEntry = [PSCustomObject]@{releaseNumber = 1; p1 = 1}
$r = [Mdbc.Api]::UpdateDefinition(@{'$set' = @{value = $manifestEntry}})
equals $r.Render($null, $null).ToString() '{ "$set" : { "value" : { "releaseNumber" : 1, "p1" : 1 } } }'
}

0 comments on commit ab8f618

Please sign in to comment.