Skip to content

Fix wildcard semantics; fix like clause anchoring #26

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

Merged
merged 2 commits into from
Mar 7, 2021

Conversation

nblumhardt
Copy link
Member

Serilog.Expressions has a number of language features in common with Seq (though the implementations are generally very different). I checked over how wildcards are evaluated after having a bug reported in Seq's implementation, to see whether similar issues existed over here.

And, yes! - Found some problems in how wildcards work, leading to potentially incorrect results in the presence of indexing into potentially-undefined values.

After adding some new test cases for that issue, I fleshed out testing of like and found that expressions aren't being correctly anchored, here - A like 'a%' should anchor a at the beginning of the target string, but doesn't, and end anchoring was similarly broken.

This PR fixes both sets of issues.

// If we hit a wildcard-compatible operation, then any wildcards within its operands "belong" to
// it and can't be the result of this search.
if (Operators.WildcardComparators.Contains(lx.OperatorName))
return null;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix for wildcard translation - stop searching upon reaching another comparison.

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.

1 participant