-
Notifications
You must be signed in to change notification settings - Fork 149
[OPENJPA-2933] Implements new date JPA 3.1 JPQL functions and equivalent Criteria API #123
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
Conversation
* 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
solomax
left a comment
There was a problem hiding this 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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return (int) Math.round(Math.ceil(month/3f)); | |
| return Math.round(month / 3f); |
should be enough here :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) :))
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).