Skip to content

Commit

Permalink
fix: dyanmic ref deser ends at wrong token
Browse files Browse the repository at this point in the history
  • Loading branch information
pnwpedro committed Oct 10, 2024
1 parent 4772e4d commit 5fab9b6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Fauna.Test/Integration.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,20 @@ public async Task CanResumeStreamWithStreamOptions()

Assert.Zero(expectedEvents, "stream handler should process all events");
}

[Test]
public async Task CollectionAll()
{
var query = FQL($"Collection.all()");
object result = (await _client.QueryAsync(query)).Data!;
switch (result)
{
case Page<object> p:
Assert.Greater(p.Data.Count, 0);
break;
default:
Assert.Fail($"Expected Page<Ref<Dictionary<string, object>>> but was {result.GetType()}");
break;
}
}
}
3 changes: 3 additions & 0 deletions Fauna/Serialization/DynamicSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ private object DeserializeDocumentInternal(MappingContext context, ref Utf8Fauna
builder.Doc = (Dictionary<string, object>?)_dict.DeserializeDocument(context, builder.Id, builder.Name, builder.Collection, ref reader);
break;
}

// After we deserialize into a doc, we end on the EndDocument a token and do not want to read again
if (reader.CurrentTokenType == TokenType.EndDocument) break;
}

return builder.Build();
Expand Down

0 comments on commit 5fab9b6

Please sign in to comment.