Open AlBannaTechno opened 3 years ago
I stumbled upon this behavior too. I guess what happens on Insert
is this:
Home
object gets replaced by a DbRef
Value
, but a DbRef
doesn't have this property
null
(?) or nothing(?) being added to the indexHuman
object is insertedWhat should happen is this:
Home
collection (on the Value
property)Home
collection should be used for your queryDbRef
ed object doesn't make sense and should at least cause a runtime errorBe aware that a DebRef
never ensures referential integrity. It's just a tool to reduce the amount of duplicated information. The DbRef
d object simply gets removed. It will never be persisted.
I'm not sure if it's simple to change the behavior above, but I feel the danger of deadlocks when I think about it.
This are some options what you could do instead:
Home
collection which should reference the Human
collection.Home
collection firstHome
object IDs to query the Human
collectionHuman.Homes[*].$id ANY = @id
Human.HomeIds[*] ANY = @id
@fubar-coder, until now I have no time to debug the source code of LiteDB, but, to notice, when creating an index with Fluent Syntax, and Querying With Fluent Syntax without explicitly writing the SQL statements, everything works fine,
Thank you for your idea, but the solution you provide, will degrees the performance to the worst level when using pagination,
So to get everything to work in all cases, this LiteDB Issue must fix, as soon as I have time for that I will work on it.
@AlBannaTechno I think that it, when you use the fluent syntax, just doesn't use the index at all and just applies the condition after the Home
object was merged back into the Human
object.
Version 5.0.9
Describe the bug When I try to query based on a referenced entity, everything works fine until I create the index for that query?
Code to Reproduce
Suppose we have this
And We have the next code to work with DB
and we need to get all Humans that Have a Home With Value More Than N ?
This Works
But if we define the index
we will not get any value ??
Expected behavior I think LiteDb Should Show The Result As Expected
Additional context @bnascimento Can you help me with that, I have a question
Suppose I create the next index
How could I use this index explicitly? I see that in old Version
4
docs, also on the UnitTests in the current version, But can not apply the same caseI see a thing like this
But I can not use that
Not work
, even if I just use nested collection without any reference to another document,I think, we need a revolution to revive the documentation, there are tones of information in the Tests, but not documented, I tried to do that, but I have leaks of information about LiteDb, but I will try to figure it.