Skip to content

Commit

Permalink
TSTZRange: Account for infinity modifier (#2377)
Browse files Browse the repository at this point in the history
We need to explicity deal with infinity/-infinity tstzrange values as
time.Parse cannot parse those
  • Loading branch information
Amogh-Bharadwaj authored Dec 19, 2024
1 parent bc5fff5 commit c0e5fba
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions flow/connectors/postgres/qvalue_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,18 +584,18 @@ func customTypeToQKind(typeName string) qvalue.QValueKind {
// in tstzrange.
// convertTimeRangeBound removes the +0000 UTC part
func convertTimeRangeBound(timeBound interface{}) (string, error) {
if timeBound, isInfinite := timeBound.(pgtype.InfinityModifier); isInfinite {
return timeBound.String(), nil
}

layout := "2006-01-02 15:04:05 -0700 MST"
postgresFormat := "2006-01-02 15:04:05"
var convertedTime string
if timeBound != nil {
lowerParsed, err := time.Parse(layout, fmt.Sprint(timeBound))
if err != nil {
return "", fmt.Errorf("unexpected lower bound value in tstzrange. Error: %v", err)
return "", fmt.Errorf("unexpected bound value in tstzrange. Error: %v", err)
}
convertedTime = lowerParsed.Format(postgresFormat)
} else {
convertedTime = ""
return lowerParsed.Format(postgresFormat), nil
}

return convertedTime, nil
return "", nil
}

0 comments on commit c0e5fba

Please sign in to comment.