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

fix: EXPOSED-384 CurrentTimestamp cannot be used with OffsetDateTimeColumnType #2081

Merged
merged 2 commits into from
May 14, 2024

Conversation

bog-walk
Copy link
Member

Version 0.50.0 introduced 2 changes to CurrentTimestamp:

  • It is now an object instead of a class.
  • It no longer returns type T, but instead returns an Instant.

So its previous use as a default expression with a timezone compatible column is no longer possible, as even changing to a singleton still requirs OffsetDateTime as the return type:

// compile error - invoke() not found
val t3: Column<OffsetDateTime> = timestampWithTimeZone("t3").defaultExpression(CurrentTimestamp())

// compile error - type mismatch
val t3: Column<OffsetDateTime> = timestampWithTimeZone("t3").defaultExpression(CurrentTimestamp)

This fix introduces a new object CurrentTimestampWithTimeZone for this specific use, to both modules exposed-java-time and exposed-kotlin-datetime.

Rather than repeating the same query builder logic, the 3 CurrentX objects now extend from a base sealed class.

Note: A new object was not added to exposed-joda-time since timestampWithTimeZone() use the same DateTime column type, so it can be used with CurrentDateTime.

…olumnType

Since the 0.50.0 column type safety changes, CurrentTimestamp is no longer a class,
but an object, and it no longer returns type T, but Instant.

So its previous use as a default expression with a timezone compatible column is
no longer possible, as even changing to a singleton still required OffsetDateTime
as the return type.

This introduces a new object CurrentTimestampWithTimeZone for this specific use
to both modules exposed-java-time and exposed-kotlin-datetime.

Rather than repeating the same query builder logic, the 3 CurrentX objects now
extend from a base sealed class.
@bog-walk bog-walk requested a review from e5l May 13, 2024 20:17
Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

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

Looks better, thanks for updating KDocs

@bog-walk bog-walk merged commit e5d438a into main May 14, 2024
5 checks passed
@bog-walk bog-walk deleted the bog-walk/fix-current-timestamp-tz branch May 14, 2024 13:46
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.

None yet

2 participants