OrleansContrib / Orleans.Providers.MongoDB

A MongoDb implementation of the Orleans Providers: Membership, Storage and Reminders.
MIT License
100 stars 43 forks source link

#124 Unique constraint violations are not propagated #125

Closed tomhreb closed 1 year ago

tomhreb commented 1 year ago

Hi!

I have not found better way for detecting which field constraint was violated than "parsing" the exception message.

I've added couple test methods into the test host, as it does not seem there is a unit test approach for the persistence provider.

SebastianStehle commented 1 year ago

I think the message you test for is too specific. It is very easy to break that. Perhaps you can just check for "_id"?

tomhreb commented 1 year ago

I think the message you test for is too specific. It is very easy to break that. Perhaps you can just check for "_id"?

I am afraid that checking for "_id" only is not enough, for example when someone creates custom index with "_id" in its name.

wassim-k commented 1 year ago

Thoughts on the following slightly less verbose check?

&& w.WriteError.Category == ServerErrorCategory.DuplicateKey
&& w.WriteError.Message.Contains("index: _id_ ", StringComparison.Ordinal)
tomhreb commented 1 year ago

ok, changed.

tomhreb commented 1 year ago

@SebastianStehle what do you think now, will you merge it? Would you like more tests, or?

SebastianStehle commented 1 year ago

I want to step back, so it is up to @wassim-k to decide

wassim-k commented 1 year ago

good work @tomhreb, can you please just bump the version number in the csproj file and we'll get it merged.

tomhreb commented 1 year ago

@wassim-k done