Skip to content

Refuse Fbe.delete_one when several facts share the id - #1270

Open
Thayorns wants to merge 1 commit into
zerocracy:masterfrom
Thayorns:1175
Open

Thayorns wants to merge 1 commit into
zerocracy:masterfrom
Thayorns:1175

Conversation

@Thayorns

Copy link
Copy Markdown
Contributor

Fbe.delete_one deleted every fact its id query matched and inserted one rebuilt fact back, so when two facts shared an id, the one that was not given was destroyed along with its properties. #914 gave Fbe.delete and Fbe.overwrite a guard against this and delete_one was left out.

It now counts what delete! removed and raises Fbe::Error with the same message as Fbe.delete when more than one fact went, and the transaction rolls the deletion back. The extra branch pushed the method over the complexity cops by one, so the check for a missing property was merged into the index lookup right after it. The behavior is the same: nothing happens when the property or the value is absent.

The tests cover two facts sharing _id and a random number of facts sharing a custom id: property. My #842 touches the same delete! line, so whichever of the two lands second will need a small rebase.

Closes #1175

@Thayorns

Copy link
Copy Markdown
Contributor Author

@yegor256 take a look please, happy to clarify anything in the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fbe.delete_one destroys every fact that shares the id, not only the one given

1 participant