JasperFx / marten

.NET Transactional Document DB and Event Store on PostgreSQL
https://martendb.io
MIT License
2.74k stars 428 forks source link

F# discriminated union support for strongly-typed identifiers #3279

Closed nkosi23 closed 1 week ago

nkosi23 commented 2 weeks ago

Implements #3280

nkosi23 commented 2 weeks ago

One thing that I've not done though is Comb's sequential Guid id generation. This is the kind of thing I'd love to use as I see a lot of value in it, but I'm not sure how I'd surface such an id generated by marten considering that:

1) The FSharp DU id generation strategy is essentially a no-op strategy 2) F# objects are immutable by default

My understanding is that these Ids cannot be generated externally but must be generated from the internals of Marten since it requires access to the database context (having raw access to the table etc...)

Edit: okay, was tired and read too fast the code about Comb Guids. just figured comb guids can be generated externally from my code as they actually only depend on a timestamp. I guess I'll just create and inject a Guid generation service in my project that will use Marten's CombGuidIdGeneration.NewGuid() method behind the scenes.

jeremydmiller commented 2 weeks ago

@nkosi23 Can you reverse the rename of ValueTypeInfo to StrongTypedIdInfo? The earlier name was to reflect that that was used within LINQ and possibly independently of the strong typed ids

nkosi23 commented 2 weeks ago

@jeremydmiller Thanks for the feedback, I've just reverted it