Closed ankitvijay closed 5 years ago
Thank you for your report. I will take a look and publish a fix.
@ankitvijay I did identify the issue and I will be committing a fix later today. I will also probably publish a new nuget version as well with the fix today.
Funny enough, this fix shows that there is a bug with the underlying Cosmos DB v2 SDK as well where the JsonSerializationSettings are now being honored during LINQ to SQL conversion, but there is nothing I can do about that.
It's a valid bug here: https://github.com/Azure/azure-cosmos-dotnet-v2/issues/351
Fixed in b61fc0161b02b981408f4bff71ab46a98e4eaa4d. Published in 2.11.1: https://www.nuget.org/packages/Cosmonaut/2.11.1
Waoow.. That was lightning fast. Thanks for the fix :)
Now signature of ToCosmonautDocument method has changed. I use it in many places. Now need to fix all. It is a minor but still breaking change. Would be better to provide a default argument to avoid breaking existing code.
@irriss Sorry for that. You are right I should have added a default one. Ideally I do whenever I can but for some reason I thought this method was marked internal
. I will add a default implementation in the next version so if you don't have a need to update you can skip that version.
@Elfocrash not a big issue, thanks for answer and this excellent project!
I ran into an issue while using
Cosmonaunt
library. I had definedCosmosStoreSettings
as follows:MyEntity
had a self-referential loop. Since,JsonSerializerSettings
had been set to NOT error on the reference loop, I expected below line to save theMyEntity
object to the CosmosDB collection.However, this line throws below error:
Note that when I used the
DocumentClient
directly to save theMyEntity
object, thenMyEntity
was saved successfully. My expectation was that it should respect theJsonSerializerSettings
defined bycosmosStoreSettings
when we callAddAsync
and not throw an exception.On digging into the
Cosmonaut
source code, I found that issue was in the methodCosmonautHelpers
-->ToCosmonautDocument
. This method uses "Global" JsonSerialize settings instead of the one defined incosmosStoreSettings
. Here is the line of code which led to this issue:When, updating the default global
JsonSerializerSettings
with the same setting ascosmosStoreSettings
the entity was saved successfully.I do not think i should need to change global
JsonSerializerSettings
to get this working since I'm supplying the settings already.