Skip to content

Conversation

scorredoira
Copy link

Use the DNS setting localTime=true:

"User:password@tcp(localhost:5555)/dbname?localTime=true"

Description

Allows to insert datetime values without altering their timezone.

Currently this is only possible by setting the location for the connecton using the loc setting.
If you need to handle the logic by the application this setting allows you to do it. An example of why this may be need is a multi-tenant application where each tenant has its own timezone and dates are always local to the tenant.

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary
  • Added myself / the copyright holder to the AUTHORS file

Use the DNS setting localTime=true:

 "User:password@tcp(localhost:5555)/dbname?localTime=true"
@methane
Copy link
Member

methane commented Feb 14, 2022

Before reviewing code, please reply to this:

  • Why should it resolved in the driver layer, instead of ORM?
  • Is it symmetry between query parameters and scanning?

@scorredoira
Copy link
Author

@methane that is precisely the point, to not alter what is sent to the driver. By default if I send something to the database I should see exactly that in the database. This is how other drivers work, like https://github.com/mattn/go-sqlite3

Anyway, I found a workaround by sending a string instead of a time.Time struct so I am closing this.

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