Open isaacabraham opened 4 years ago
FWIW https://github.com/Zaid-Ajaj/LiteDB.FSharp#id-auto-incremented
So this might be by design (cannot tell for sure) but the error should be more specific then.
Yes, maybe that's all that needs to be done. Note that LiteDB.FSharp is not compatible with v5 of LiteDB cc @Zaid-Ajaj
There is already an opened issue about updating LiteDB.FSharp to latest LiteDB version. I won't be able to work on it any time soon due to other prioritized projects. Feel free to send PRs for the issue in subject, I will be happy to review them
You can work around this by marking the record type with
[<CLIMutable>]
. However, this is non-idomatic from an F# perspective.
In LiteDB 4.x
Another workaround is to change int
to ObjectId
without adding [<CLIMutable>]
attribute
///using `ObjectId.NewObjectId()` but not `new ObjectId()`
type Customer = {
Id : ObjectId
Name : string
Phones : string array
IsActive : bool
}
A issue is the record type using ObjectId
will not support comparision
@humhei This happens because ObjectId
implements IComparable<ObjectId>
, but not IComparable
(an oversight, I believe). Try using Guid
as Id, it should work.
Version: LiteDB 5.0.3, Windows, NetCore3.1
Describe the bug Adding an immutable record to LiteDB gives an NRE, although the document is actually inserted.
Code to Reproduce
Expected behavior The record should be inserted without an exception.
System.NullReferenceException: Object reference not set to an instance of an object. at LiteDB.LiteCollection
1.Insert(T entity)`Additional context You can work around this by marking the record type with
[<CLIMutable>]
. However, this is non-idomatic from an F# perspective.