-
Notifications
You must be signed in to change notification settings - Fork 91
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
Support Datetime function CURRENT_DATE & CURRENT_TIME #624
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #624 +/- ##
============================================
- Coverage 91.97% 66.40% -25.57%
============================================
Files 297 465 +168
Lines 3215 4748 +1533
Branches 195 277 +82
============================================
+ Hits 2957 3153 +196
- Misses 204 1538 +1334
- Partials 54 57 +3 ☔ View full report in Codecov by Sentry. |
f436846
to
c963cc7
Compare
fun currentDate(): Expression<LocalDate> { | ||
return Expressions.currentDate() | ||
} |
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 Criteria API, the return type of currentDate()
is the java.sql.Date
.
The Jakarta specification also specifies that the return type is the java.sql.Date
. Therefore, please change the return type to the java.sql.Date
.
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.
For the same reason as above, I would like to request that the return type of currentTime()
be changed to the java.sql.Time
.
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 got it, I'll change currentTime & currentDate
|
||
class CurrentTimeDslTest : WithAssertions { | ||
@Test | ||
fun `currentDate() with a property`() { |
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.
테스트 함수 이름이 테스트 대상(currentTime)과 일치하지 않습니다. 알맞게 변경해주시면 좋을것같습니다.
private val expression = currentDate() | ||
|
||
@Test | ||
fun handledType() { // when |
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.
코드 스타일을 맞추기위해 // when
주석의 줄내림이 필요해 보입니다.
JpqlCurrentTimeSerializerTest.kt
코드에도 동일한 부분이 있으니 같이 수정해주시면 좋을것같습니다.
val delegate = context.getValue(JpqlRenderSerializer) | ||
|
||
writer.write("CURRENT_DATE") | ||
|
||
writer.writeParentheses { | ||
delegate.serialize(part, writer, context) | ||
} |
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.
serialize
에 part: JpqlCurrent.CurrentDate
을 전달하면,
JpqlCurrent.CurrentDate 타입에 대해 serialize 재귀 호출
이 일어나서 StackOverflowError가 발생합니다.
JpqlCurrentDateSerializer의 경우 괄호와 추가적인 serialize 호출이 필요가 없어보이므로
writer.write("CURRENT_DATE")
한줄만 있어도 충분해 보입니다.
JpqlCurrentTimeSerializer.kt
도 마찬가지이므로 같이 수정해주시면 좋을것같습니다.
각 SerializerTest도 수정된 내용에 맞게 다시 봐주시면 좋을것같습니다!
@@ -486,6 +488,26 @@ open class Jpql : JpqlDsl { | |||
return Expressions.times(this.toExpression(), value.toExpression()) | |||
} | |||
|
|||
/** | |||
* Creates an expression that represents the current date. |
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.
represents
와 the
사이에 불필요한 whitespace가 하나 더 포함 되어있습니다.
currentTime()의 주석도 둥일하니 같이 수정해주시면 좋을것같습니다.
@Test | ||
fun `currentDate() with a expression`() { | ||
// when | ||
val expression = queryPart { | ||
currentDate() | ||
}.toExpression() | ||
|
||
val actual: Expression<LocalDate> = expression // for type check | ||
|
||
// then | ||
val expected = Expressions.currentDate() | ||
|
||
assertThat(actual).isEqualTo(expected) | ||
} |
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.
위 테스트와 중복된 내용이므로 제거해도 될것같아요.
|
||
class CurrentDateDslTest : WithAssertions { | ||
@Test | ||
fun `currentDate() with a property`() { |
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.
특정 property나 expression을 가지고 테스트하는 코드가 아니므로
테스트 함수 이름이 fun currentDate()
정도로 표현되도 좋을것같습니다.
CurrentTimeDslTest 쪽도 비슷하니 같이 수정해주시면 좋을것같습니다.
import com.linecorp.kotlinjdsl.querymodel.jpql.expression.Expression | ||
import java.sql.Date | ||
|
||
object JpqlCurrentDate : Expression<Date> |
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.
Please add the Internal annotation
because this class belongs to an implementation.
@Internal
object JpqlCurrentDate : Expression<Date>
|
||
class CurrentDateDslTest : WithAssertions { | ||
@Test | ||
fun `currentDate()`() { |
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.
If the name of the test exposes only the name of the method being tested, it is not parenthesized. Please modify it like this:
@Test
fun currentDate() {
// ...test codes
}
@MockK | ||
private lateinit var serializer: JpqlRenderSerializer | ||
|
||
private val expression = currentDate() |
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.
It would be nice if you could use Expressions.currentDate()
instead of static import.
Some of the formatting is off, but I'll fix that! Thanks for your help. Finally, I'd like to ask you to sign the Contributor License Agreement. |
Motivation
Modifications
Commit Convention Rule
commit type
please describe it on the Pull RequestResult
Closes