feat: add function expression support to JDQL grammar and parser#714
Merged
otaviojava merged 5 commits intoApr 19, 2026
Merged
Conversation
added 5 commits
April 4, 2026 09:23
Introduces DefaultFunction and FunctionQueryValue to represent scalar function calls within JDQL query values. Both types are package-private, keeping implementation details out of the public API. Also updates the changelog. Issue eclipse-jnosql#643 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Updates the ANTLR4 grammar to support ABS, LENGTH, LOWER, UPPER, LEFT, and RIGHT functions. Ensures function keywords can still be used as field identifiers to maintain backward compatibility. Issue eclipse-jnosql#643 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Enhances PrimaryFunction to process function expression nodes from the AST, converting them into FunctionQueryValue objects. Introduces FunctionType enum to normalize function names and enforce arity validation per the Jakarta Data specification. Enables recursive parsing of nested function arguments. Arithmetic expressions within function arguments are explicitly rejected as unsupported. Issue eclipse-jnosql#643 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Updates AbstractWhere to support function expressions within query conditions, allowing them to be processed by the JDQL provider. Issue eclipse-jnosql#643 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Covers single-parameter functions (UPPER, LOWER, LENGTH, ABS), multi-parameter functions (LEFT, RIGHT), nested function calls, named parameters, field name collision with function keywords, wrong arity rejection, and arithmetic expression rejection. Issue eclipse-jnosql#643 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Contributor
|
sorry for take longer @omatheusmesmo , meged it. Thank you |
Author
No problems, thank you too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds grammar and parser support for scalar function expressions (ABS, LENGTH, LOWER, UPPER, LEFT, RIGHT) in JDQL queries. After this, queries like
SELECT e FROM Entity e WHERE ABS(e.salary) > 1000just work.Step 2 of 3 from the PR #704 split.
Related Issue: Related to #643
Type of Contribution
Architectural and Design Decisions
DefaultFunction,FunctionQueryValue,FunctionType) are package-private inside thedatasubpackage.FunctionTypeis an enum that replaces the if-else chain inPrimaryFunction.identifierrule that includes function tokens (ABS, LENGTH, etc.) to keep backward compatibility — without it, fields namedlength,left, etc. would stop parsing as valid field names.AbstractWheredrops theexitFunction_expressionoverride that threwUnsupportedOperationException— the grammar andPrimaryFunctionhandle everything now.Contribution Checklist
Validation Results