-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fill the missing date/time related decoding in ReadExecutor #287
Changes from 2 commits
a83438a
71aa621
0449a62
569101b
15b9fdd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,8 @@ package zio.sql | |
|
||
import java.sql._ | ||
import java.io.IOException | ||
import java.time.{ ZoneId, ZoneOffset } | ||
import java.time.{ OffsetDateTime, OffsetTime, ZoneId, ZoneOffset, ZonedDateTime } | ||
|
||
import zio.{ Chunk, Has, IO, Managed, ZIO, ZLayer, ZManaged } | ||
import zio.blocking.Blocking | ||
import zio.stream.{ Stream, ZStream } | ||
|
@@ -184,8 +185,21 @@ trait Jdbc extends zio.sql.Sql { | |
column.fold(resultSet.getTimestamp(_), resultSet.getTimestamp(_)).toLocalDateTime().toLocalTime() | ||
) | ||
case TLong => tryDecode[Long](column.fold(resultSet.getLong(_), resultSet.getLong(_))) | ||
case TOffsetDateTime => ??? | ||
case TOffsetTime => ??? | ||
case TOffsetDateTime => | ||
tryDecode[OffsetDateTime]( | ||
column | ||
.fold(resultSet.getTimestamp(_), resultSet.getTimestamp(_)) | ||
.toLocalDateTime() | ||
.atOffset(ZoneOffset.of(ZoneId.systemDefault().getId)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to https://jdbc.postgresql.org/documentation/head/java8-date-time.html, "OffsetDateTime instances will have be in UTC (have offset 0). This is because the backend stores them as UTC" - can you please change this to be UTC instead of local time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes for sure. Thank you for the feedback. See my latest commit. |
||
) | ||
case TOffsetTime => | ||
tryDecode[OffsetTime]( | ||
column | ||
.fold(resultSet.getTimestamp(_), resultSet.getTimestamp(_)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we need |
||
.toLocalDateTime() | ||
.toLocalTime | ||
.atOffset(ZoneOffset.of(ZoneId.systemDefault().getId)) | ||
) | ||
case TShort => tryDecode[Short](column.fold(resultSet.getShort(_), resultSet.getShort(_))) | ||
case TString => tryDecode[String](column.fold(resultSet.getString(_), resultSet.getString(_))) | ||
case TUUID => | ||
|
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 remove unused import