Skip to content
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

khepri_pattern_tree: Fix conditions that were matching subtrees #257

Merged
merged 1 commit into from
May 15, 2024

Conversation

dumbbell
Copy link
Member

Why

A pattern tree with /parent/* is supposed to match /parent/child but not /parent/child/grandchild.

Before this patch, this was the case because we didn't check if we reached the of the path before calling the folding function in khepri_pattern_tree:fold1/6.

How

Now, we check the context and only call the fold function if we reached the end of the path.

Otherwise, we recurse without calling that fold function, checking a few more things depending on whether the condition could match grand children or not.

The testsuites are expanded with more testcases to cover these situations.

@dumbbell dumbbell self-assigned this May 15, 2024
Copy link

codecov bot commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.70%. Comparing base (b963ca8) to head (f523f28).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #257      +/-   ##
==========================================
- Coverage   89.75%   89.70%   -0.06%     
==========================================
  Files          20       20              
  Lines        2998     3002       +4     
==========================================
+ Hits         2691     2693       +2     
- Misses        307      309       +2     
Flag Coverage Δ
erlang-24 88.74% <100.00%> (+0.04%) ⬆️
erlang-25 88.60% <100.00%> (-0.09%) ⬇️
erlang-26 89.40% <100.00%> (+0.08%) ⬆️
os-ubuntu-latest 89.70% <100.00%> (+0.14%) ⬆️
os-windows-latest 89.44% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for fixing this! I just found a tiny typo

src/khepri_pattern_tree.erl Outdated Show resolved Hide resolved
[Why]
A pattern tree with `/parent/*` is supposed to match
`/parent/child` but not `/parent/child/grandchild`.

Before this patch, this was the case because we didn't check if we
reached the of the path before calling the folding function in
`khepri_pattern_tree:fold1/6`.

[How]
Now, we check the context and only call the fold function if we reached
the end of the path.

Otherwise, we recurse without calling that fold function, checking a few
more things depending on whether the condition could match grand
children or not.

The testsuites are expanded with more testcases to cover these
situations.
@dumbbell dumbbell force-pushed the fix-pattern-tree-conditions-matching-subtrees branch from 93f4e41 to f523f28 Compare May 15, 2024 15:17
@dumbbell dumbbell marked this pull request as ready for review May 15, 2024 15:29
@dumbbell dumbbell added the bug Something isn't working label May 15, 2024
@dumbbell dumbbell added this to the v0.14.0 milestone May 15, 2024
@dumbbell dumbbell merged commit 8dde132 into main May 15, 2024
12 checks passed
@dumbbell dumbbell deleted the fix-pattern-tree-conditions-matching-subtrees branch May 15, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants