Skip to content

fix(#799): quote the id value and refuse to insert when nothing was deleted - #842

Open
Thayorns wants to merge 3 commits into
zerocracy:masterfrom
Thayorns:799
Open

Thayorns wants to merge 3 commits into
zerocracy:masterfrom
Thayorns:799

Conversation

@Thayorns

@Thayorns Thayorns commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Fbe.delete_one built its delete query by interpolating the identifying value straight into the sentence, so a String value arrived at the parser as a bare word and was read as a property name. With a custom id: the query matched nothing, the delete removed nothing, and the rebuilt fact was inserted anyway, leaving the original next to a copy of it.

The value now goes through Fbe::Term, a small object that renders one (eq prop value) sentence with the value spelled the way the parser reads it back: a String in quotes with the quotes inside escaped, a Time in ISO 8601, everything else as it is. The same interpolation lives in Fbe.if_absent, Fbe.just_one, Fbe.delete and Fbe.overwrite; moving them onto this object is worth a separate issue.

The second half of the bug had nothing to do with quoting. delete! was called for its side effect and its answer thrown away, so handing delete_one a fact that does not live in the given factbase inserted a copy of it there. It now raises Fbe::Error when the delete matched no facts, the way Fbe.overwrite already does.

Closes #799

@Thayorns

Thayorns commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@yegor256 please take a look when you have a moment, happy to clarify anything here.

Copy link
Copy Markdown
Member

This looks like the right fix for the quoting bug, but it's got conflicts with master now, so it needs a rebase before it can go in. Requesting another look too.


Generated by Claude Code

@yegor256
yegor256 self-requested a review September 27, 2026 06:44
@Thayorns

Thayorns commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@yegor256 done, ready for review again

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 duplicates the fact instead of deleting a value from it

2 participants