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

fix: Postgres DB with non-UTC timezone incorrectly parse in timestamptz fields #252

Merged
merged 5 commits into from
Sep 25, 2023

Conversation

Rascal
Copy link
Contributor

@Rascal Rascal commented Dec 6, 2022

@Rascal Rascal changed the title #251 fix: Postgres DB with non-UTC timezone incorrectly parse in timestamptz fields fix: Postgres DB with non-UTC timezone incorrectly parse in timestamptz fields Dec 6, 2022
@Rascal Rascal marked this pull request as ready for review December 6, 2022 16:21
@Rascal Rascal marked this pull request as draft December 6, 2022 20:51
@Rascal Rascal marked this pull request as ready for review December 6, 2022 21:49
@@ -25,7 +25,7 @@ func (d postgreSQL) EncodeBool(b bool) string {
}

func (d postgreSQL) EncodeTime(t time.Time) string {
return MySQL.EncodeTime(t)
return `'` + t.Format(time.RFC3339Nano) + `'`
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you update dialect.go timeFmt instead so that it is available in all dialects?

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 tested this format with the rest of the bases, MySQL (5.6) and MS SQL (2017) cannot parse time in this format. I suggest using the new format for PostgreSQL, leaving the old implementation for MySQL, SQLite and MS SQL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@taylorchu As I pointed out in the comment above, other bases understand a very limited number of formats, I suggest making changes only for Postgres methods.

@Rascal Rascal requested a review from taylorchu March 26, 2023 17:01
@austintaylor austintaylor merged commit 3be1adc into gocraft:master Sep 25, 2023
@Rascal Rascal deleted the fix_postgres_timezone_bug branch September 25, 2023 22:07
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.

3 participants