-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
timezone bug when persisting *gtime.Time to db #1714
Comments
a more comprehensive test:
|
@wesleywu Thanks, I will carefully review this issue and PR again these days. |
@gqcn Thanks for reconsider this issue. The purpose of functions like String() or Sprintf() is to output informations (can be abbreviated or truncated information) to users. These functions should not be used at any circumstances of data persisting, because they may cause loss of information and they were designed to not be responsible for the loss. I could accept the fact that gtime.time.String() lose timezone info and there are many workarounds like call Local() before String(). |
fix timezone bug when persisting *gtime.Time to db #1714
@wesleywu Thanks for your PR, it is already merged into master branch. |
1. What version of
Go
and system type/arch are you using?go1.17.6 darwin/amd64
2. What version of
GoFrame
are you using?v2.0.4
3. Can this issue be re-produced with the latest release?
yes
4. What did you do?
write a simple service "TestTime" to save record to db
DSN
mysql:user:pass@tcp(127.0.0.1:3306)/db?charset=utf8mb4&parseTime=true&loc=Local
Use *time.Time for column type, and write a test as below:
console output:
database records:
above all are expected results.
console output:
database record:
I think the behavior may related to bug in gtime.Time.String().
GF might have used the string representation of a gtime.Time before persisting to db.
Another bug is:
When I use timestamp(6) or datetime(6) as sql column type, gtime.Time will truncate my milliseconds from my time field.
This may also related to the gtime.Time.String() bug.
The text was updated successfully, but these errors were encountered: