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: Add time extension function for temporal expressions in Kotlin and Java #2121

Merged

Conversation

joc-a
Copy link
Collaborator

@joc-a joc-a commented Jun 12, 2024

  • Added time extension functions for temporal expressions in Kotlin and Java.
  • Modified Time function to make it work for all database dialects.
  • Modified JodaTimeMiscTableTest and JodaTimeDefaultsTest to extend DatabaseTestsBase instead of JodaTimeBaseTest to match the way it is in the Kotlin and Java tests.
  • H2 V1 is excluded from the tests because of a bug in the driver that messes up the fractional seconds.

I'm planning to add more tests to cover more types in later pull requests.

@joc-a joc-a marked this pull request as ready for review June 12, 2024 14:04
@joc-a joc-a requested review from bog-walk and obabichevjb June 12, 2024 14:05
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(" ")
Copy link
Collaborator

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.

@joc-a joc-a force-pushed the joc/add-time-extension-function-for-temporal-expressions branch from 65335c2 to 6ca6888 Compare June 26, 2024 10:56
@joc-a joc-a changed the title feat: Add time extension function for temporal expressions feat: Add time extension function for temporal expressions in Kotlin and Java Jun 26, 2024
@joc-a joc-a requested review from bog-walk and obabichevjb June 26, 2024 13:34
Copy link
Member

@bog-walk bog-walk left a 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.

…and Java

H2 V1 is excluded because of a bug in the driver that messes up the fractional seconds
@joc-a joc-a force-pushed the joc/add-time-extension-function-for-temporal-expressions branch from 6ca6888 to 15cff13 Compare June 27, 2024 10:20
@joc-a joc-a merged commit 3fafec1 into main Jun 27, 2024
5 checks passed
@joc-a joc-a deleted the joc/add-time-extension-function-for-temporal-expressions branch June 27, 2024 11:53
DonRobo referenced this pull request in DonRobo/home-former Aug 4, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[org.jetbrains.exposed:exposed-jdbc](https://togithub.com/JetBrains/Exposed)
| `0.52.0` -> `0.53.0` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/org.jetbrains.exposed:exposed-jdbc/0.53.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/org.jetbrains.exposed:exposed-jdbc/0.53.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/org.jetbrains.exposed:exposed-jdbc/0.52.0/0.53.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/org.jetbrains.exposed:exposed-jdbc/0.52.0/0.53.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[org.jetbrains.exposed:exposed-core](https://togithub.com/JetBrains/Exposed)
| `0.52.0` -> `0.53.0` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/org.jetbrains.exposed:exposed-core/0.53.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/org.jetbrains.exposed:exposed-core/0.53.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/org.jetbrains.exposed:exposed-core/0.52.0/0.53.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/org.jetbrains.exposed:exposed-core/0.52.0/0.53.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>JetBrains/Exposed
(org.jetbrains.exposed:exposed-jdbc)</summary>

###
[`v0.53.0`](https://togithub.com/JetBrains/Exposed/blob/HEAD/CHANGELOG.md#0530)

[Compare
Source](https://togithub.com/JetBrains/Exposed/compare/0.52.0...0.53.0)

Infrastructure:

-   SQLite driver 3.46.0.1
-   Spring Framework 6.1.11
-   Spring Boot 3.3.2
-   junit-bom 5.10.3

Features:

- feat: Add time extension function for temporal expressions in Kotlin
and Java by [@&#8203;joc-a](https://togithub.com/joc-a) in
[https://github.com/JetBrains/Exposed/pull/2121](https://togithub.com/JetBrains/Exposed/pull/2121)
- feat: EXPOSED-435 Allow insertReturning() to set isIgnore = true by
[@&#8203;bog-walk](https://togithub.com/bog-walk) in
[https://github.com/JetBrains/Exposed/pull/2148](https://togithub.com/JetBrains/Exposed/pull/2148)
- feat: EXPOSED-77 Support entity class for table with composite primary
key by [@&#8203;bog-walk](https://togithub.com/bog-walk) in
[https://github.com/JetBrains/Exposed/pull/1987](https://togithub.com/JetBrains/Exposed/pull/1987)
- feat: EXPOSED-446 Support N-column inList equality comparisons by
[@&#8203;bog-walk](https://togithub.com/bog-walk) in
[https://github.com/JetBrains/Exposed/pull/2157](https://togithub.com/JetBrains/Exposed/pull/2157)
- feat: EXPOSED-450 Merge command: PostgreSQL improvements by
[@&#8203;obabichevjb](https://togithub.com/obabichevjb) in
[https://github.com/JetBrains/Exposed/pull/2161](https://togithub.com/JetBrains/Exposed/pull/2161)
- feat: EXPOSED-388 Support for column type converters by
[@&#8203;obabichevjb](https://togithub.com/obabichevjb) in
[https://github.com/JetBrains/Exposed/pull/2143](https://togithub.com/JetBrains/Exposed/pull/2143)
- Adding comment text for a query SQL by
[@&#8203;xJoeWoo](https://togithub.com/xJoeWoo) in
[https://github.com/JetBrains/Exposed/pull/2088](https://togithub.com/JetBrains/Exposed/pull/2088)
- feat: EXPOSED-459 Open AbstractQuery.copyTo() to allow custom Query
class extension by [@&#8203;bog-walk](https://togithub.com/bog-walk) in
[https://github.com/JetBrains/Exposed/pull/2173](https://togithub.com/JetBrains/Exposed/pull/2173)
- feat: EXPOSED-461 Add time column in Joda-Time module by
[@&#8203;joc-a](https://togithub.com/joc-a) in
[https://github.com/JetBrains/Exposed/pull/2175](https://togithub.com/JetBrains/Exposed/pull/2175)

Bug fixes:

- fix: EXPOSED-424 ClassCastException exception when using
`fetchBatchedResults` with `alias` by
[@&#8203;joc-a](https://togithub.com/joc-a) in
[https://github.com/JetBrains/Exposed/pull/2140](https://togithub.com/JetBrains/Exposed/pull/2140)
- fix: EXPOSED-407 compositeMoney() nullability definition issues by
[@&#8203;bog-walk](https://togithub.com/bog-walk) in
[https://github.com/JetBrains/Exposed/pull/2137](https://togithub.com/JetBrains/Exposed/pull/2137)
- fix: EXPOSED-415 SchemaUtils incorrectly generates ALTER statements
for existing nullable columns by
[@&#8203;obabichevjb](https://togithub.com/obabichevjb) in
[https://github.com/JetBrains/Exposed/pull/2136](https://togithub.com/JetBrains/Exposed/pull/2136)
- fix: EXPOSED-363 LocalTime and literal(LocalTime) are not the same by
[@&#8203;joc-a](https://togithub.com/joc-a) in
[https://github.com/JetBrains/Exposed/pull/2152](https://togithub.com/JetBrains/Exposed/pull/2152)
- fix: EXPOSED-432 CurrentDate default is generated as null in MariaDB
by [@&#8203;joc-a](https://togithub.com/joc-a) in
[https://github.com/JetBrains/Exposed/pull/2149](https://togithub.com/JetBrains/Exposed/pull/2149)
- fix: Allow column reference in default expressions for MySQL and
MariaDB by [@&#8203;joc-a](https://togithub.com/joc-a) in
[https://github.com/JetBrains/Exposed/pull/2159](https://togithub.com/JetBrains/Exposed/pull/2159)
- fix: EXPOSED-430 Insert and BatchInsert do not return default values
by [@&#8203;obabichevjb](https://togithub.com/obabichevjb) in
[https://github.com/JetBrains/Exposed/pull/2158](https://togithub.com/JetBrains/Exposed/pull/2158)
- fix: EXPOSED-452 Flaky H2\_Oracle test
`testTimestampWithTimeZoneDefaults` by
[@&#8203;joc-a](https://togithub.com/joc-a) in
[https://github.com/JetBrains/Exposed/pull/2169](https://togithub.com/JetBrains/Exposed/pull/2169)
- EXPOSED-457 The column default value always compares unequal by
[@&#8203;obabichevjb](https://togithub.com/obabichevjb) in
[https://github.com/JetBrains/Exposed/pull/2170](https://togithub.com/JetBrains/Exposed/pull/2170)
- EXPOSED-409 Custom primary key. Access to the primary key fails with
ClassCastException by
[@&#8203;obabichevjb](https://togithub.com/obabichevjb) in
[https://github.com/JetBrains/Exposed/pull/2151](https://togithub.com/JetBrains/Exposed/pull/2151)
- fix: EXPOSED-447 Eager loading does not work with composite PK entity
by [@&#8203;bog-walk](https://togithub.com/bog-walk) in
[https://github.com/JetBrains/Exposed/pull/2177](https://togithub.com/JetBrains/Exposed/pull/2177)

Docs:

- chore: Add migration sample by
[@&#8203;joc-a](https://togithub.com/joc-a) in
[https://github.com/JetBrains/Exposed/pull/2144](https://togithub.com/JetBrains/Exposed/pull/2144)
- docs: Change repetitionAttempts to maxAttempts in website docs by
[@&#8203;bog-walk](https://togithub.com/bog-walk) in
[https://github.com/JetBrains/Exposed/pull/2164](https://togithub.com/JetBrains/Exposed/pull/2164)
- docs: EXPOSED-445 Add documentation for DSL & DAO composite primary
keys by [@&#8203;bog-walk](https://togithub.com/bog-walk) in
[https://github.com/JetBrains/Exposed/pull/2165](https://togithub.com/JetBrains/Exposed/pull/2165)
- docs: EXPOSED-419 Rework the getting started tutorial by
[@&#8203;vnikolova](https://togithub.com/vnikolova) in
[https://github.com/JetBrains/Exposed/pull/2160](https://togithub.com/JetBrains/Exposed/pull/2160)
- Configure API documentation for Exposed by
[@&#8203;e5l](https://togithub.com/e5l) in
[https://github.com/JetBrains/Exposed/pull/2171](https://togithub.com/JetBrains/Exposed/pull/2171)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job
log](https://developer.mend.io/github/DonRobo/home-former).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

3 participants