[BUG] Adding an immutable record to LiteDB gives an NRE
See original GitHub issueVersion: 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
open LiteDB
type Customer = {
Id : int
Name : string
Phones : string array
IsActive : bool
}
let db = new LiteDatabase("MyData.db")
let col = db.GetCollection "customers"
let customer =
{ Id = 0
Name = "John Doe"
Phones = [| "8000-0000"; "9000-0000" |]
IsActive = true }
// Insert new customer document (Id will be auto-incremented)
col.Insert customer |> ignore
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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Update Litbedb to latest version · Issue #45
FSharp be updated to use latest LiteDB so that LiteDB Studio can be used? ... [BUG] Adding an immutable record to LiteDB gives...
Read more >city-chain/CHANGELOG.md at master
Add a fix from Blockcore/Stratis (580b418); Add latest checkpoint height which comes after Segwit activation (ac40169); Make sure that City Chain nodes ...
Read more >https://raw.githubusercontent.com/quozd/awesome-do...
Addins is a generic framework for creating extensible applications, and for creating add-ins which extend those applications * [peasy](https://github.com/peasy/ ...
Read more >awesome-c-sharp
Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom ...
Read more >2m-subdomains.txt
... spec libraries resources media java Assets js README application release ... TEDU odata2-lib visitor jmx BUGS libmproxy responses mipsel-linux-android ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@humhei This happens because
ObjectId
implementsIComparable<ObjectId>
, but notIComparable
(an oversight, I believe). Try usingGuid
as Id, it should work.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