Skip to content

Conversation

@cristof
Copy link
Contributor

@cristof cristof commented Feb 3, 2025

Implemented LOCAL DATE, LOCAL TIME, LOCAL DATETIME functions and criteria api equivalents
Implemented EXTRACT functions
Updated documentation
Fixed corner case of round function on postgresql (got the error when testing updated master on derbydb, h2, mariadb (11), mysql (8 and 9) and postgresql (16 and 17).
Please, don't hesitate to ask fixes (pretty sure it needs some).

* Bumped jakarta persistence API to 3.1.0
* Added necessary stub impl of methods (throws UnsupportedOperationException)
* Tests passes, but actual impls must be made in probably different issues, one for each new features (https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spec-3.1#jakarta-persistence-3-1)
…EXTRACT functions

* Added JPA 3.1 date/time JPQL new functions LOCAL DATE, LOCAL TIME and LOCAL DATETIME and Criteria equivalents
* Added JPQL EXTRACT date/time field and EXTRACT date/time (as a CAST) JPQL functions
* Added tests to verify validity of BNF changes in JPQL.jjt and each new function
* Updated round function usage and test due a corner case on postgresql tests
* Made EXTRACT function test be resistent to date/time divergence between db and test environments
* Updated manual BNF and Date Time functions chapters
Copy link
Contributor

@solomax solomax left a comment

Choose a reason for hiding this comment

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

I would ask for a minor change

The PR is absolutely fantastic! Thanks for you work! :))

switch (_field) {
case QUARTER:
int month = t.get(ChronoField.MONTH_OF_YEAR);
return (int) Math.round(Math.ceil(month/3f));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return (int) Math.round(Math.ceil(month/3f));
return Math.round(month / 3f);

should be enough here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, your solution gives wrong results for January(1) - gives 0, April(4) - gives 1, July (7) - gives 3, and October (10) - gives 3, because rounds 0.3 to 0 and so on.

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad :(
You are right :)

The only redundant part is (int) :))

@solomax solomax merged commit 141bcd6 into apache:master Feb 8, 2025
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