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

feat: add operators validation #3809

Merged

Conversation

ndr-brt
Copy link
Member

@ndr-brt ndr-brt commented Jan 29, 2024

What this PR changes/adds

Add operator validation.

Why it does that

avoid problems with unsupported operators upfront

Further notes

  • Had to refactor the way we translate from a criterion operator to a Predicate, this way it will be possible for adopters to implement custom operators with custom validation. the CriterionOperatorRegistry keeps track of the supported operators and the way to translate a Criterion into a Predicate.

Linked Issue(s)

Closes #3713

Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.

@ndr-brt ndr-brt added enhancement New feature or request refactoring Cleaning up code and dependencies labels Jan 29, 2024
@ndr-brt ndr-brt force-pushed the 3713-add-operators-validator branch from 0749aa5 to 5d78f71 Compare January 29, 2024 16:35
Copy link

github-actions bot commented Feb 6, 2024

This pull request is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale Open for x days with no activity label Feb 6, 2024
@ndr-brt ndr-brt removed the stale Open for x days with no activity label Feb 6, 2024
@Override
public boolean test(Object property, Object operandRight) {
if (property instanceof Collection<?> collection) {
return collection.contains(operandRight);
Copy link
Member

Choose a reason for hiding this comment

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

theoretically operandRight could be a List itself, IDK what would happen then...

Copy link
Member Author

@ndr-brt ndr-brt Feb 6, 2024

Choose a reason for hiding this comment

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

in the (postgre)SQL context it can be only a single object, because eventually I guess another operator/syntax would need to be used.
I think if we want to being able to pass a list as operandRight we'll need another operator (containsAll?)

@ndr-brt ndr-brt merged commit de7bf4d into eclipse-edc:main Feb 6, 2024
19 checks passed
@ndr-brt ndr-brt deleted the 3713-add-operators-validator branch February 6, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring Cleaning up code and dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

api: add validation on the Criterion object to avoid unsupported operators
2 participants