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

Explain how timestamptz doesn't save tz #379

Closed
wants to merge 1 commit into from

Conversation

ysangkok
Copy link
Contributor

@ysangkok ysangkok commented Oct 4, 2024

It confused me a bunch of times that timestamptz doesn't actually save the tz. Maybe I will stop getting confused if we document it.

Comment on lines +653 to +655
Note that the time zone is not actually stored. On read, if the session
time zone setting isn't set to UTC, the offset will be applied to the local
time component. On write, the offset always 0.
Copy link
Member

@jlavelle jlavelle Oct 4, 2024

Choose a reason for hiding this comment

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

I actually think it's slightly misleading to talk about timezone offsets getting applied here because it's always a UTCTime on the Haskell side.

Copy link
Contributor Author

@ysangkok ysangkok Oct 4, 2024

Choose a reason for hiding this comment

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

But anyone that executes select ('2020-01-01' :: timestamptz); will see the offset and wonder how that gets mapped to Haskell. And anyone that reads this Haddock will see 'with time zone' and wonder how that works if it maps to a UTCTime. For example, one could think that the offset would get truncated instead of applied.

Since Orville is also used with data that is written in other places, how do we document the fact that Orville applies the offset when decoding?

Copy link
Member

@jlavelle jlavelle Oct 4, 2024

Choose a reason for hiding this comment

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

Okay I see where you're coming from now. You'd like to make it clear that Orville is handling the offsets correctly, even though PostgreSQL doesn't store the timezone in the actual timestamp value. We should also say something in the docs for SqlType.timestamp, in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I suppose it does make sense to not document expected behaviour. So I'll close this and we can focus on #380.

@ysangkok ysangkok closed this Oct 5, 2024
@ysangkok ysangkok deleted the explain-timestamptz branch October 5, 2024 15:21
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