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

Support for fuction call #137

Merged
merged 15 commits into from
Feb 15, 2024

Conversation

ng-galien
Copy link
Contributor

@ng-galien ng-galien commented Nov 27, 2023

It could be great if we can call function in RSQL queries.
This POC adresses this feature as function pattern is @function_name[arg1|arg2|...]
It support function imbrication and constant (null, boolean, number, string) in parameters.

Some expressions tested in the POC

@upper[code]==HELLO
@concat[code|name]=='TestTest Lab'
@concat[@upper[code]|name]=='TESTTest Lab'
@concat[@upper[code]|#WORLD]=='HELLOWORLD'

The main limitation is we cannot use white space in the query because of the parser.

If we feel confortable with this feature I will finish implementation with Sort and more tests

@perplexhub
Copy link
Owner

@ng-galien This is a very useful feature. Could it be disabled by default and turned on by setting a flag? Thanks.

@ng-galien
Copy link
Contributor Author

@perplexhub
I've experienced this feature at work and, as you suggest, we have a mandatory whiteList and an optional blackList for the safety reason.
Procedure call is also supported for sorting.

@perplexhub
Copy link
Owner

@ng-galien Could you please help to resolve the conflicts and implement the remaining parts? Thanks

@ng-galien
Copy link
Contributor Author

@perplexhub I can do it next week, then are we aligned with this feature spec

  1. The function call syntax (with empty space restriction because of the RSQL parser)
  2. Ability to use it for where and sort
  3. Mandatory whitelist and optional blacklist with regex, supplied in both QuerySupport and SortSupport

Regarding the third point, we can use RSQLCommonSupport too and specialized supports as an override.

@perplexhub
Copy link
Owner

@ng-galien Thanks for your help. I agree with your spec.
About point 1, do you think we could provide an option to define a string pattern variable to mimic a space? The pattern would be replaced with space internally if the string pattern variable was set.

Alexandre Boyer added 2 commits January 20, 2024 09:35
…-call

# Conflicts:
#	rsql-jpa/src/main/java/io/github/perplexhub/rsql/RSQLJPAPredicateConverter.java
@ng-galien
Copy link
Contributor Author

@perplexhub
I've just merged in order to pass basic tests, but code needs some refactoring as it's quite messy

@ng-galien ng-galien changed the title POC - Support for fuction call Support for fuction call Jan 20, 2024
@ng-galien
Copy link
Contributor Author

@ng-galien Thanks for your help. I agree with your spec. About point 1, do you think we could provide an option to define a string pattern variable to mimic a space? The pattern would be replaced with space internally if the string pattern variable was set.

We can use tab as a replacement for a space.
See testFunctionStaticWhitespaceAsSpace in RSQLJPASupportTest

@perplexhub perplexhub merged commit 651bbec into perplexhub:master Feb 15, 2024
1 check passed
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.

2 participants