Skip to content

#854: Reject empty just_one matching criteria - #1388

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

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

Conversation

@gemshrine

Copy link
Copy Markdown
Contributor

Fbe.just_one builds its lookup query from the attributes set by the callback. When the callback leaves no ordinary attributes, or sets only system attributes, the query becomes (and ); that can return an unrelated fact or fail in the parser.

The method now checks the non-system matching attributes after the callback and raises Fbe::Error before querying or inserting when the set is empty. Existing attribute handling and matching behavior stay the same when a usable key is present.

Tests cover an empty callback with an existing unrelated fact and a callback that sets only _id. The repository test suite runs these cases with bundle exec rake test.

Fixes #854

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.just_one builds an invalid (and ) query when the block sets no attributes

1 participant