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

Postgres TIMESTAMP WITH TIMEZONE (TIMESTAMPTZ) support #75

Closed
ShawnROGrady opened this issue Jul 27, 2021 · 8 comments
Closed

Postgres TIMESTAMP WITH TIMEZONE (TIMESTAMPTZ) support #75

ShawnROGrady opened this issue Jul 27, 2021 · 8 comments

Comments

@ShawnROGrady
Copy link

Currently there is only a Value::DateTime variant which does not work for TIMESTAMP WITH TIMEZONE (TIMESTAMPTZ) column types.

@billy1624
Copy link
Member

Hi, thanks for the issue! What is your suggestions on this?

Perhaps we can add Value::DateTimeTz that is timezone aware?

pub enum Value {
    #[cfg(feature = "with-chrono")]
    DateTimeTz(Box<chrono::DateTime>),
    // ...
}

@ShawnROGrady
Copy link
Author

@billy1624 hi, that was my initial thought but I wasn't sure how well that would translate across the other dialects you support (mysql, sqlite) since postgres is what I'm most familiar with. Adding an additional enum variant seems like the clearest solution to me assuming other dialects have something analogous to TIMESTAMPTZ.

Thanks!

@billy1624
Copy link
Member

Yes, @ShawnROGrady, good point! We have to also consider the TIMESTAMPTZ support on other databases.

@billy1624
Copy link
Member

Currently there is only a Value::DateTime variant which does not work for TIMESTAMP WITH TIMEZONE (TIMESTAMPTZ) column types.

The problem is that Value::DateTime will produce a datetime string that does not have timezone suffix? i.e. "2021-07-27 16:48:00".

However, what you need for updating / inserting a TIMESTAMPTZ column is something like "2021-07-27 16:48:00+08"?

Correct me if I am wrong. Thanks!!

Ref: https://www.postgresql.org/docs/9.1/datatype-datetime.html

@tyt2y3
Copy link
Member

tyt2y3 commented Jul 27, 2021

@billy1624 I think your understanding of the problem is correct.

@tyt2y3
Copy link
Member

tyt2y3 commented Jul 30, 2021

I suggest adding a variant to Value called DateTimeWithTimeZone

@forrest-akin
Copy link

Similarly, Time is missing a corresponding TimeTz

@tyt2y3
Copy link
Member

tyt2y3 commented Aug 8, 2021

0.12.9
@ShawnROGrady please re-open this issue if you find any issues.
@forrest-akin please open a new issue if you needed that.

@tyt2y3 tyt2y3 closed this as completed Aug 8, 2021
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

No branches or pull requests

4 participants