-
-
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
pgsql的timestamptz类型问题 #1256
Comments
问题1,通过把时间数据解析为local时间解决 #1257 问题2,查询条件换成gtime的ISO8601,也没有问题 问题3,保证自身业务的程序和数据库时区一致即可,其实主要问题在于updated_time这些字段的自动维护上,如果时区一致就不会有问题了。但是如果写入的数据库时区不一致就会比较麻烦了 |
gqcn
added
bug
It is confirmed a bug, but don't worry, we'll handle it.
done
This issue is done, which may be release in next version.
labels
Jun 2, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
版本
go1.16
gf v1.15.6
场景
数据库使用pgsql,字段类型为timestamptz,数据内容例如: 2021-05-20 00:00:00+00
数据库时区为UTC,go服务时区为UTC+8
问题
查询结果,会忽略掉数据中的时区,直接保存为UTC+8时区。例如数据2021-05-20 00:00:00+00,查询结果为2021-05-20 00:00:00+08
查询如果包含gtime.Time类型的条件,会按照UTC+8格式化成时间字符串(2021-05-20 00:00:00)没有附加时区+08。
这时如果数据非UTC+8,就会按照数据本身的时区查询。 例如: 数据为 2021-05-20 00:00:00+00,查询条件 2021-05-20 00:00:00可以命中这条记录。
插入数据时,插入数据不带时区信息。例如数据库时区为UTC,程序时区UTC+8,插入数据2021-05-21 00:00:00+08,实际保存的数据是2021-05-21 00:00:00+00
The text was updated successfully, but these errors were encountered: