-
Notifications
You must be signed in to change notification settings - Fork 104
Support Arithmetic function ROUND #615
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
render/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/JpqlRenderContext.kt
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| /** | ||
| * Creates an expression that represents the rounding of the specified property's value to a specified scale. |
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 think it would be great to at least value instead of property's value, since not only the value of the property can be passed as a parameter to round, but also the literal.
| * Creates an expression that represents the rounding of the specified property's value to a specified scale. | ||
| */ | ||
| @SinceJdsl("3.4.0") | ||
| fun <T : Any, V : Number> round(expr: KProperty1<T, @Exact V>, scale: Expression<Int>): Expression<Double> { |
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 don't think the ROUND is a primary function, so I think it would be better to have the function located below the DIV.
| * Creates an expression that represents the rounding of the specified property's value to a specified scale. | ||
| */ | ||
| @SinceJdsl("3.4.0") | ||
| fun <T : Number> round(value: Expressionable<T>, scale: Expressionable<Int>): Expression<Double> { |
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.
In the jakarta specification, the return type of ROUND is the same type as the first argument: value.
Could you test this to make sure it's really correct? I think it would be okay to test with Int, Double, and BigDecimal only.
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 modify a bit from what you wrote, just the method names and such. Thanks for the help! |
|
Oh, and I was expecting you to use the example module to test that Double and Int work with JPA locally. |

Motivation
Modifications
Commit Convention Rule
commit typeplease describe it on the Pull RequestResult
roundis created.Closes