ClickHouse / ClickHouse/clickhouse-go

Using time.Time with zero value results in "dateTime overflow" error.

Open
#882 9 comments 0 reactions 0 assignees View on GitHub
discuss
Dominant language
Go
Stars
3.3k
Forks
680
Avg merge
2d 3h
Merged PRs (30d)
14

Description

### Issue description
We're using `jmoiron/sqlx` library to insert data to CH database.
When I switched project to use `clickhouse-go/v2`, inserting object with field `time.Time` with zero value (0001-01-01 00:00:00 +0000 UTC) results in dateTime overflow error.
In previous v1, it was inserting the beginning of Unix timestamp.

### Example code
```go
type Event struct {
EventAt time.Time `db:"event_at"` // this one is filled with correct data
DifferentEventAt time.Time `db:"different_event_at"` // this one is untouched, so zero time.Time value remains
}
```

### Error log
```
clickhouse: dateTime overflow. different_event_at must be between 1970-01-01 00:00:00 and 2105-12-31 23:59:59
```

### Configuration
*OS:*
macOS M1

*Interface:*
`golang.yandex/hasql/sqlx` along with `github.com/jmoiron/sqlx`

*Driver version:*
v2.5.1

*Go version:*
1.19.4

*ClickHouse Server version:*
21.5.7.9 running on Docker

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by reproducing the zero-value time.Time insert with clickhouse-go/v2 and compare it with the previous v1 behavior; trace the dateTime encoding path and add regression coverage once the expected handling is decided.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, go
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.