Skip to content

Commit

Permalink
Merge pull request #16 from pinax-network/fix/handle_date
Browse files Browse the repository at this point in the history
fix handle Date type
  • Loading branch information
fschoell authored Jul 29, 2024
2 parents 3777895 + 7e0a18b commit 0c31151
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion db/dialect_clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ func convertToType(value string, valueType reflect.Type) (any, error) {
if strings.Contains(value, "T") && strings.HasSuffix(value, "Z") {
v, err = time.Parse("2006-01-02T15:04:05Z", value)
} else if dateRegex.MatchString(value) {
v, err = time.Parse("2006-01-02", value)
// we just check here as the Clickhouse Date type doesn't handle int64 input data
_, err = time.Parse("2006-01-02", value)
if err != nil {
return "", fmt.Errorf("could not convert %s to time: %w", value, err)
}
return value, nil
} else {
v, err = time.Parse("2006-01-02 15:04:05", value)
}
Expand Down

0 comments on commit 0c31151

Please sign in to comment.