question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Adding an immutable record to LiteDB gives an NRE

See original GitHub issue

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

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.LiteCollection1.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:open
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lbnascimentocommented, May 7, 2020

@humhei This happens because ObjectId implements IComparable<ObjectId>, but not IComparable (an oversight, I believe). Try using Guid as Id, it should work.

1reaction
Zaid-Ajajcommented, Mar 9, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found