-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DbRef bug - document is still referenced after delete #831
Comments
Hi @Youwannadie, DbRef has no constraints, like SQL databases. DbRef are only a way to represent document reference. In this case you must manually delete references too. |
I was trying LiteDB Shell with 3.1.4 version and data are same. So difference must be in Include method or something there. If I get data in v4.0.0 referenced documents are populated wrong. In v3.1.4 are populated properly. It means in v3.1.4 must be check or something in Include method and I think it is nice behaviour. |
Oh, ok. Now I got your point. That's true, this same operation has different returns. In v3, includes/dbref are used only in LiteDatabase level (after BsonMapper map your class into BsonDocument). Basicly I changed serialize/deserialize methods to include/exclude external class instance. When you add an include in an array, if element are not found they are removed from return (not from collection, only from return). In v4 this include method are moved into LiteEngine level (before BsonMapper). Now, it's possible include before map into your class. With this, it´s possible do this include in tools that use only BsonDocument, like shell.
But, in both cases (v3/v4) LiteDB doesn't exclude external child. In your example, But thinking better about this, I'm still in doubt about this: which version are more correct? When use include operation, remove item if not exists or keeps as $id only? |
For me "remove item if not exists" is right way.
|
Did you try it? @mbdavid |
Yes, I understand your example and agree that are different from v3.x. But first I will run in MongoDB to check how they implement this case. The main problem to "remove" is that you are not removing from storage, only removing from viewing results. If I compare with traditional SQL databases with no FK, data also are not removed and join will not return what are expected. |
Thank you, but my main point now is in v4 are children totally wrong. They contains not existing childs. |
Hi @Youwannadie, i got it.... in BsonMapper I had this little tricky when deserialize array:
This line check just first line in array to know if all element are included or only ref. If you mix results, we have a problem. Fix this is easy, but i'm thinking that you right: when use include, must remove from result missing object. To do this, is quite more complicate because I need remove in BsonDocument level and for now, I do not have "remove" method from an |
Nice, thank you. |
First deserialize problem fixed. But i'm still missing "remove" not found includes.... |
Hi @Youwannadie, can you test now using master branch version? I will add more performance tests and if ok, will release as a bugfix in 4.1.1 |
I got same result as in v3.x. So I think it is fixed. :) |
Hi! With the objective of organizing our issues, we are closing old unsolved issues. Please check the latest version of LiteDB and open a new issue if your problem/question/suggestion still applies. Thanks! |
Hi,
I think i found bug. If you delete document which is referenced by another document, refference still exists. Db version is 4.0.0. In 3.1.4 it is working properly.
Proof is in attachment
I hope it is clear. Sorry for my english.
The text was updated successfully, but these errors were encountered: