Skip to content

Add matchesPattern support - #2519

Merged
habbes merged 8 commits into
OData:masterfrom
Arithmomaniac:master
Oct 24, 2022
Merged

Add matchesPattern support#2519
habbes merged 8 commits into
OData:masterfrom
Arithmomaniac:master

Conversation

@Arithmomaniac

Copy link
Copy Markdown
Contributor

Issues

This pull request fixes #1901.

Description

Adds support for the matchesPattern function introduced in OData v4. In addition to being added as a supported function to the raw parser, it is mapped in .NET to Regex.IsMatch(input, pattern, RegexOptions.ECMAScript).

The basic methodology was to look for any C# file in the repository that handled all of the string predicates (startswith, endswith, etc.) and added matchesPattern to that set. There was at least one legacy provider with no support for e.g. contains; that provider was unmodified.

As part of this work, the case-insensitivity logic had to be changed to account for matchesPattern being the first OData function whose canonical name is mixed-case.

Checklist

  • Test cases added
  • Build and test with one-click build and test script passed
    • Almost of the tests passed locally
    • Some unit tests failed intermittently from the build script but worked in VS (different tests each time)
    • Astoria complained about Unable to cast COM object of type 'AstoriaUnitTests.Tests.JScriptEngine'...)

mikepizzo
mikepizzo previously approved these changes Oct 3, 2022

@mikepizzo mikepizzo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

Fix misaligned spacing
@pull-request-quantifier-deprecated

Copy link
Copy Markdown

This PR has 100 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Small
Size       : +90 -10
Percentile : 40%

Total files changed: 15

Change summary by file extension:
.cs : +90 -10

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@habbes
habbes merged commit 023bede into OData:master Oct 24, 2022
xuzhg added a commit that referenced this pull request Mar 9, 2026
…ction

New Test Cases:

FunctionCallBinderTests.cs - MatchesPatternFunctionBindsCorrectly: Tests binder layer binding, validates two string parameters, verifies Edm.Boolean return type

FilterAndOrderByFunctionalTests.cs - MatchesPatternInFilterWithTheReturnType: Tests complete filter parsing pipeline with Name property, query: matchesPattern(Name, '^[A-Z][a-z]+dollar'), validates property access and pattern parameters

FilterAndOrderByFunctionalTests.cs - MatchesPatternInFilterWithBooleanComparison: Tests matchesPattern in boolean expression, query: matchesPattern(Name, '[0-9]+') eq true

Coverage: Binder layer, filter parser end-to-end, property access parameters, literal patterns, boolean expressions, return type validation. matchesPattern was added in commit 023bede (PR #2519) by Avi Levin on Oct 24, 2022.
xuzhg added a commit that referenced this pull request Mar 9, 2026
…ction

New Test Cases:

FunctionCallBinderTests.cs - MatchesPatternFunctionBindsCorrectly: Tests binder layer with Name property access, validates two parameters (property + pattern), verifies Edm.Boolean return type with email validation regex

FilterAndOrderByFunctionalTests.cs - MatchesPatternInFilterWithTheReturnType: Tests complete filter parsing pipeline, query: matchesPattern(Name, '^[A-Z][a-z]+'), validates property access and pattern parameters

FilterAndOrderByFunctionalTests.cs - MatchesPatternInFilterWithBooleanComparison: Tests matchesPattern in boolean expression, query: matchesPattern(Name, '[0-9]+') eq true, validates function in binary operator context

Coverage: Binder layer, filter parser end-to-end, property access parameters, literal patterns, boolean expressions, return type validation. matchesPattern was added in commit 023bede (PR #2519)
xuzhg added a commit that referenced this pull request Mar 9, 2026
…ction (#3499)

New Test Cases:

FunctionCallBinderTests.cs - MatchesPatternFunctionBindsCorrectly: Tests binder layer with Name property access, validates two parameters (property + pattern), verifies Edm.Boolean return type with email validation regex

FilterAndOrderByFunctionalTests.cs - MatchesPatternInFilterWithTheReturnType: Tests complete filter parsing pipeline, query: matchesPattern(Name, '^[A-Z][a-z]+'), validates property access and pattern parameters

FilterAndOrderByFunctionalTests.cs - MatchesPatternInFilterWithBooleanComparison: Tests matchesPattern in boolean expression, query: matchesPattern(Name, '[0-9]+') eq true, validates function in binary operator context

Coverage: Binder layer, filter parser end-to-end, property access parameters, literal patterns, boolean expressions, return type validation. matchesPattern was added in commit 023bede (PR #2519)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An unknown function with name 'matchesPattern' was found

3 participants