Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Merge pull request #287 from laurachapman/datetime-decoding-issue-127
Browse files Browse the repository at this point in the history
Fill the missing date/time related decoding in ReadExecutor
  • Loading branch information
bertlebee authored Nov 25, 2020
2 parents 7376fef + 15b9fdd commit d9d6a86
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions jdbc/src/main/scala/zio/sql/jdbc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

import zio.{ Chunk, Has, IO, Managed, ZIO, ZLayer, ZManaged }
import zio.blocking.Blocking
import zio.stream.{ Stream, ZStream }
Expand Down Expand Up @@ -184,8 +185,20 @@ 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.UTC)
)
case TOffsetTime =>
tryDecode[OffsetTime](
column
.fold(resultSet.getTime(_), resultSet.getTime(_))
.toLocalTime
.atOffset(ZoneOffset.UTC)
)
case TShort => tryDecode[Short](column.fold(resultSet.getShort(_), resultSet.getShort(_)))
case TString => tryDecode[String](column.fold(resultSet.getString(_), resultSet.getString(_)))
case TUUID =>
Expand Down

0 comments on commit d9d6a86

Please sign in to comment.