Skip to content

#977: Reject empty if_absent matching criteria - #1393

Open
gemshrine wants to merge 1 commit into
zerocracy:masterfrom
gemshrine:977
Open

gemshrine wants to merge 1 commit into
zerocracy:masterfrom
gemshrine:977

Conversation

@gemshrine

Copy link
Copy Markdown
Contributor

Fixes #977

Cause

Fbe.if_absent builds its lookup query from the callback's attributes after excluding system fields. With no remaining attributes, it sends (and ) to Factbase. That query can match an unrelated existing fact, and an empty factbase can instead receive a blank fact.

Change

The method now raises Fbe::Error before querying or inserting when the callback sets no non-system attributes. The same guard covers callbacks that set only _id, _time, or _version.

Test coverage

Regression cases cover an empty callback with an unrelated fact already present and a callback that sets only _id. Run them with bundle exec ruby -Itest test/fbe/test_if_absent.rb; repository CI also runs the full Rake test suite.

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.if_absent with no attributes matches the first fact

1 participant