-
Notifications
You must be signed in to change notification settings - Fork 677
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: Add time extension function for temporal expressions in Kotlin and Java #2121
feat: Add time extension function for temporal expressions in Kotlin and Java #2121
Conversation
exposed-jodatime/src/main/kotlin/org/jetbrains/exposed/sql/jodatime/DateFunctions.kt
Outdated
Show resolved
Hide resolved
private fun dateTimeWithFractionFormat(fraction: Int): DateTimeFormatter { | ||
val baseFormat = "YYYY-MM-dd HH:mm:ss" | ||
private fun dateTimeWithFractionFormat(date: String, fraction: Int): DateTimeFormatter { | ||
val containsDatePart = date.contains("T") || date.contains(" ") |
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 see that it's duplicated in other datetime packages, and I believe that it works, but is it possible that containsDatePart
is false here?
I wanted to write that if we use method inside DateColumnType
class, and this method takes date: String
argument, it must have date part, but now I see.
I don't expect that it's the problem of this PR, but it might be a problem in the long term. We have a DateColumnType
class that is expected to be used with exact values from the database (actually also different values from different dialects, but it's another problem), but after that we query something like SUBSTRING(CONVERT(NVARCHAR, TestTable."timestamptz-column", 121), 12, 15)
and expect that the column type should parse it also. And the problem is that we actually cannot say which values we expect from the database, we can rely only on what's covered by tests.
But I don't know is it easy to change with the current approach. Particularly for the time function, if the final goal is to return user the date from the whole timestamp, we can query the whole timestamp and extract time on the exposed side (instead of querying time only).
Anyway, it's just some thoughts about the potential problems with maintaining our datetime classes.
exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors/FunctionProvider.kt
Outdated
Show resolved
Hide resolved
65335c2
to
6ca6888
Compare
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.
Left small comments in the test files.
exposed-java-time/src/test/kotlin/org/jetbrains/exposed/JavaTimeTests.kt
Outdated
Show resolved
Hide resolved
...kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt
Outdated
Show resolved
Hide resolved
...kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt
Outdated
Show resolved
Hide resolved
…and Java H2 V1 is excluded because of a bug in the driver that messes up the fractional seconds
6ca6888
to
15cff13
Compare
time
extension functions for temporal expressions in Kotlin and Java.Time
function to make it work for all database dialects.JodaTimeMiscTableTest
andJodaTimeDefaultsTest
to extendDatabaseTestsBase
instead ofJodaTimeBaseTest
to match the way it is in the Kotlin and Java tests.I'm planning to add more tests to cover more types in later pull requests.