-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Proposal about drive Location and DB Timezone in session #1114
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
Comments
I believe using UTC is the only safe way. Only it can be recommended. So I am not so fever in the proposed To make this driver more safe for many users, I propose to send |
Hi @methane, thank you for your fast response. I think it makes sense too, and it's much simpler and objective approach. In the case of Can you assign me to this issue, I'ld love to help. |
I don't think it is backward compatible when loc is not UTC. I believe UTC is +0000 without DST in all systems in the world. But other time zones may be vary. Think about one MySQL server which is running on time_zone A but with old tzdata. We already mention about |
I agree with you, even our cause, we were using the connection without any parameter. Can I proceed with this, implementing as your proposal:
I was thinking and it seems that, one good solution was to add this login in But I couldn't think a way of writing a test case that breaks, since it would mean to change the global timezone from test database, disconnect and run a test, and it could cause side effects in other tests |
Problem
We have found that the time difference was happening when validating a time difference
between the moment an action was taken from the user and now, and the data from
the action was stored in the database.
When we were running locally, everything was working perfectly but, after deploy
to staging there was an unexpected error. The system was telling that the difference
was 3 hours more.
After we analyzed the problem we have found that:
loc
argument andtimezone
argument from the connection string produced some different behaviors.Behavior
You can view the source and run this example in this repo
How to reproduce
I've built a simple app that exposes a post endpoint that allows you to post data to DB and read automatically.
There are 4 instances in the
docker-compose.yml
file and a MySQL database in this repo.Source code from the program is in
main.go
To run, you just need to run
run.sh
(and probably, need to give execution permissions to it before runningchmod +x run.sh
)Proposal
Considering other database drivers, seems plausible that the driver could handle the timezone automatically, based on
some configuration, considering it, and avoiding breaking anyone using the connection as it is now, I think that, creating
a
configTZ
as aboolean configuration parameter
, that default value will befalse
, to implement the timezone configuration behavior bellow, when set astrue
.DB session to UTC
OR
Read from the
database and
set loc to the
same timezone
to database,
configure session
to America/Sao_Paulo
timezone, and use it
when parsing time
to database,
configure session
to America/Sao_Paulo
timezone, and use it
when parsing time
specified by the
user, but generates
a warning, telling
that TIMEZONE fields
could face a difference
after parse.
The text was updated successfully, but these errors were encountered: