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

Fill the missing date/time related decoding in ReadExecutor #287

Merged
merged 5 commits into from
Nov 25, 2020

Conversation

laurachapman
Copy link
Contributor

Fixes #147

@CLAassistant
Copy link

CLAassistant commented Nov 21, 2020

CLA assistant check
All committers have signed the CLA.

@jczuchnowski
Copy link
Member

@robmwalsh could you take a look at this PR? It touches the same area as #263

@robmwalsh robmwalsh self-requested a review November 23, 2020 23:44
Copy link
Contributor

@robmwalsh robmwalsh left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this! Just a couple of minor things to fix up. Apparently ZonedDateTime, Instant and OffsetTime aren't supported by jdbc. We will have to decide how/if we want to support this (this is a jdbc problem, not just postgres), but at the moment I think getting an offset time in local time as a convenience is probably reasonable. I'll create an issue for this Issue #322. I resolved a merge conflict so please pull your branch before making changes. We also need you to please sign the CLA - there are instructions on that above.

case TOffsetTime =>
tryDecode[OffsetTime](
column
.fold(resultSet.getTimestamp(_), resultSet.getTimestamp(_))
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we need resultSet.getTime for this - I'm not sure what calling getTimestamp on a time column would do.

column
.fold(resultSet.getTimestamp(_), resultSet.getTimestamp(_))
.toLocalDateTime()
.atOffset(ZoneOffset.of(ZoneId.systemDefault().getId))
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes for sure. Thank you for the feedback. See my latest commit.

@@ -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 }
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove unused import

[error] /home/circleci/project/jdbc/src/main/scala/zio/sql/jdbc.scala:5:68: Unused import
[error] import java.time.{ OffsetDateTime, OffsetTime, ZoneId, ZoneOffset, ZonedDateTime }
[error]                                                                    ^

@robmwalsh
Copy link
Contributor

Thanks, looks looks like just that unused import (this might seem picky but our CI fails for this to keep the imports tidy - 1 isn't too bad but they'd just grow over time if it wasn't enforced) & CLA and this will be good to merge

@laurachapman
Copy link
Contributor Author

Sorry about that, I'm working on a new machine and didn't have the setting turned on that flags unused imports so I wasn't seeing it. I appreciate your patience! I work with zio at work but this is my first time contributing to open source.

I'm not sure what's wrong with the CLA, I have signed it already under my github account laurachapman but it's showing "LAURA CHAPMAN seems not to be a github user" in the contributers section. Not sure how to resolve this. Worst case I can make a new branch/PR and be sure to sign it there. Let me know and I'll go ahead and do that.

@robmwalsh
Copy link
Contributor

No worries, thanks for helping out! Your new machine is probably the culprit for the CLA issue as well - you need to make sure that the email address that's used by git on your local machine is listed in your github account. Take a look at this article.

https://docs.github.com/en/free-pro-team@latest/github/committing-changes-to-your-project/why-are-my-commits-linked-to-the-wrong-user

@robmwalsh robmwalsh closed this Nov 25, 2020
@robmwalsh robmwalsh reopened this Nov 25, 2020
@robmwalsh robmwalsh merged commit d9d6a86 into zio:master Nov 25, 2020
@robmwalsh
Copy link
Contributor

looks like I just had to rerun CI to recheck the CLA status. Thanks and congrats on your first contribution!

amrkamel pushed a commit to amrkamel/zio-sql that referenced this pull request May 26, 2022
Fill the missing date/time related decoding in ReadExecutor
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.

Fill the missing date/time related decoding in ReadExecutor
4 participants