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

feat: supporting localDateTime function for datetime function #628

Merged
merged 4 commits into from
Feb 8, 2024

Conversation

ilgolf
Copy link
Contributor

@ilgolf ilgolf commented Feb 6, 2024

Motivation

  • JDSL doesn't support LOCAL DATETIME in JPQL

Modifications

  • I create localDateTime() & serializer to support LOCAL DATETIME function

Commit Convention Rule

Commit type Description
feat New Feature
fix Fix bug
docs Documentation only changed
ci Change CI configuration
refactor Not a bug fix or add feature, just refactoring code
test Add Test case or fix wrong test case
style Only change the code style(ex. white-space, formatting)
chore It refers to minor tasks such as library version upgrade, typo correction, etc.
  • If you want to add some more commit type please describe it on the Pull Request

Result

  • Support LOCAL DATETIME function in JPQL

Closes

@CLAassistant
Copy link

CLAassistant commented Feb 6, 2024

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (4219a32) 91.97% compared to head (156bbc9) 91.96%.

Files Patch % Lines
...pql/serializer/impl/JpqlLocalDateTimeSerializer.kt 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
- Coverage   91.97%   91.96%   -0.02%     
==========================================
  Files         297      299       +2     
  Lines        3215     3222       +7     
  Branches      195      195              
==========================================
+ Hits         2957     2963       +6     
- Misses        204      205       +1     
  Partials       54       54              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expression
import java.time.LocalDateTime

object LocalDateTimeExpression : Expression<LocalDateTime>
Copy link
Member

Choose a reason for hiding this comment

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

Please add the Internal annotation because this class belongs to an implementation.

@Internal
object LocalDateTimeExpression : Expression<LocalDateTime>

Comment on lines 170 to 172
/**
* Creates a datetime expression with the localDateTime.
*/
Copy link
Member

Choose a reason for hiding this comment

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

I think the comment below are better. I've adopted the comments from the contributor of currentTime().

/**
 * Creates an expression that represents the local datetime.
 *
 * This is the same as ```LOCAL DATETIME```.
 */

class LocalDateTimeExpressionDslTest {

@Test
fun `localDateTime to support LOCAL DATETIME in jpql`() {
Copy link
Member

Choose a reason for hiding this comment

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

To keep test names simple, we only write the name of the target method in the test name unless there are multiple test cases.

image

@@ -228,7 +228,7 @@ Kotlin JDSL provides a series of functions to support built-in functions in JPA.
| CURRENT\_TIMESTAMP | not yet |
| LOCAL DATE | not yet |
| LOCAL TIME | not yet |
| LOCAL DATETIME | not yet |
| LOCAL DATETIME | support |
Copy link
Collaborator

Choose a reason for hiding this comment

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

functions that are already supported should be deleted.

@@ -226,7 +226,7 @@ Kotlin JDSL은 JPA에서 제공하는 여러 함수들을 지원하기 위함
| CURRENT\_TIMESTAMP | not yet |
| LOCAL DATE | not yet |
| LOCAL TIME | not yet |
| LOCAL DATETIME | not yet |
| LOCAL DATETIME | support |
Copy link
Collaborator

Choose a reason for hiding this comment

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

functions that are already supported should be deleted.

@ilgolf ilgolf requested review from cj848 and shouwn February 7, 2024 11:30
Comment on lines 23 to 25
writer.writeParentheses {
delegate.serialize(part, writer, context)
}
Copy link
Member

Choose a reason for hiding this comment

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

I checked that LOCAL DATETIME does not need parentheses. Please remove the parentheses.

@@ -887,4 +888,15 @@ class ExpressionsTest : WithAssertions {

assertThat(actual).isEqualTo(expected)
}

@Test
fun `localDateTime to support LOCAL DATETIME in jpql`() {
Copy link
Member

Choose a reason for hiding this comment

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

As with the DSL test, please simplify the test name.

Comment on lines 639 to 641
/**
* Creates an expression that represents the local datetime in jpql.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Please align the comment with DSL.

@shouwn
Copy link
Member

shouwn commented Feb 8, 2024

Please sign our Contributor License Agreement.

image

@shouwn
Copy link
Member

shouwn commented Feb 8, 2024

Thanks for your help! I'll fix some formatting after the merge!

@shouwn shouwn merged commit 6d838d6 into line:main Feb 8, 2024
4 checks passed
shouwn added a commit that referenced this pull request Feb 8, 2024
This reverts commit 6d838d6, reversing
changes made to 4219a32.
@shouwn
Copy link
Member

shouwn commented Feb 8, 2024

@ilgolf Sorry, I didn't see that the base branch was main and merged it. I reverted the merge on the main branch, could you please create PR to the develop branch?

@ilgolf
Copy link
Contributor Author

ilgolf commented Feb 8, 2024

okay, sorry i miss... @shouwn

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.

5 participants