Skip to content

Add support for time-0.2 types #580

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

Merged
merged 4 commits into from
Mar 3, 2020
Merged

Add support for time-0.2 types #580

merged 4 commits into from
Mar 3, 2020

Conversation

aloucks
Copy link
Contributor

@aloucks aloucks commented Feb 28, 2020

This is essentially ported from the chrono implementation.

@@ -391,6 +397,10 @@ impl WrongType {
/// | `chrono::DateTime<FixedOffset>` | TIMESTAMP WITH TIME ZONE |
/// | `chrono::NaiveDate` | DATE |
/// | `chrono::NaiveTime` | TIME |
/// | `time::PrimitiveDateTime` | TIMESTAMP |
/// | `time::OffsetDateTime` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
Copy link
Owner

Choose a reason for hiding this comment

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

I think this should only support TIMESTAMP WITH TIME ZONE to align with chrono.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chrono's types embed specific timezones (or rather UTC vs Local) where as OffsetDateTime doesn't have the generic component and is compatible with both TIMESTAMP and TIMESTAMPZ. I'd prefer to be able to use OffsetDateTime with TIMESTAMP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to be able to use OffsetDateTime with TIMESTAMP.

With cockroach TIMESTAMP will always be UTC. I'm still looking for clarification on postgres's behavior. I think with the fact that we're explicitly setting the session to UTC, it should be OK either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sfackler I thought about this some more and came to the same conclusion. OffsetDateTime now only supports TIMESTAMPTZ in the latest commit. Do you want me to squash these commits?

@sfackler
Copy link
Owner

Can you add tests as well?

@aloucks
Copy link
Contributor Author

aloucks commented Feb 28, 2020

Can you add tests as well?

Ah! I just found the type tests under tokio-postgres. I'll update and push a commit shortly.

@sfackler
Copy link
Owner

sfackler commented Mar 3, 2020

No need to squash!

@sfackler sfackler merged commit 45b80e8 into sfackler:master Mar 3, 2020
@sfackler
Copy link
Owner

sfackler commented Mar 3, 2020

Thanks!

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.

2 participants