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

JPQL left() and right() functions #396

Closed
gavinking opened this issue Apr 18, 2023 · 0 comments
Closed

JPQL left() and right() functions #396

gavinking opened this issue Apr 18, 2023 · 0 comments

Comments

@gavinking
Copy link
Contributor

JPQL already has a substring() function, but for many uses, left() and right() are more convenient, and these functions are supported on many databases and easy to emulate on the rest. It might be worth the very minimal effort required to add them.

gavinking added a commit to gavinking/persistence that referenced this issue May 25, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
rfelcman added a commit to eclipse-ee4j/eclipselink that referenced this issue Aug 29, 2023
…1933)

This change contains following changes:

New JPQL String functions LEFT(), RIGHT() for return leftmost, rightmost number of character from string passed as a first function argument
Tests are available in the JPQL parser and JPA JSE test module
EclipseLink issue is described at #1885 and Jakarta Persistence specification request at the jakartaee/persistence#396
This feature is not directly functional on Apache Derby Database and Oracle Database, but for a booth platforms is implemented overridden operator based on SUBSTR(...) SQL function. See org.eclipse.persistence.platform.database.DerbyPlatform#derbyLeftOperator | derbyRightOperator
and
org.eclipse.persistence.platform.database.OraclePlatform#oracleLeft | oracleRight .

LEFT seemed to be in collision with LEFT JOIN and similar, but after code inspection of usage org.eclipse.persistence.jpa.jpql.parser.Expression.LEFT it never happens.
Main meaning if org.eclipse.persistence.jpa.jpql.parser.Expression.LEFT is now as LEFT() function identifier and in some particular cases String constant "LEFT" behind org.eclipse.persistence.jpa.jpql.parser.Expression.LEFT is used to parse JOINs.

Signed-off-by: Radek Felcman <[email protected]>
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

No branches or pull requests

1 participant