1
0
mirror of https://github.com/uptrace/go-clickhouse.git synced 2025-07-05 00:28:55 +02:00

fix: continue working with non UTC timezone

This commit is contained in:
Vladimir Mihailenco
2022-03-28 16:41:07 +03:00
parent 43a65a02e4
commit 033c41395a
3 changed files with 8 additions and 14 deletions

View File

@ -24,7 +24,7 @@ Main features are:
Unsupported:
- Server timezones other than UTC.
- `DateTime64`
Resources:

View File

@ -1,9 +1,5 @@
package chproto
import (
"fmt"
)
type ServerInfo struct {
Name string
MinorVersion uint64
@ -25,18 +21,13 @@ func (srv *ServerInfo) ReadFrom(rd *Reader) (err error) {
return err
}
timezone, err := rd.String()
if err != nil {
if _, err := rd.String(); err != nil { // timezone
return err
}
if timezone != "UTC" {
return fmt.Errorf("ch: ClickHouse server uses timezone=%q, expected UTC", timezone)
}
if _, err = rd.String(); err != nil { // display name
if _, err := rd.String(); err != nil { // display name
return err
}
if _, err = rd.Uvarint(); err != nil { // server version patch
if _, err := rd.Uvarint(); err != nil { // server version patch
return err
}

View File

@ -106,7 +106,10 @@ func AppendString(b []byte, s string) []byte {
}
func AppendTime(b []byte, tm time.Time) []byte {
return tm.UTC().AppendFormat(b, "'2006-01-02 15:04:05'")
b = append(b, "toDateTime('"...)
b = tm.UTC().AppendFormat(b, "2006-01-02 15:04:05")
b = append(b, "', 'UTC')"...)
return b
}
func AppendBytes(b []byte, bytes []byte) []byte {