Skip to content

Commit

Permalink
suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Dec 19, 2024
1 parent 6fa29a7 commit 2cd13c3
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions flow/connectors/postgres/qvalue_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,22 +533,18 @@ func customTypeToQKind(typeName string) qvalue.QValueKind {
// in tstzrange.
// convertTimeRangeBound removes the +0000 UTC part
func convertTimeRangeBound(timeBound interface{}) (string, error) {
var convertedTime string
switch timeBound := timeBound.(type) {
case pgtype.InfinityModifier:
if timeBound, isInfinite := timeBound.(pgtype.InfinityModifier); isInfinite {
return timeBound.String(), nil
default:
layout := "2006-01-02 15:04:05 -0700 MST"
postgresFormat := "2006-01-02 15:04:05"
if timeBound != nil {
lowerParsed, err := time.Parse(layout, fmt.Sprint(timeBound))
if err != nil {
return "", fmt.Errorf("unexpected bound value in tstzrange. Error: %v", err)
}
convertedTime = lowerParsed.Format(postgresFormat)
} else {
convertedTime = ""
}

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

0 comments on commit 2cd13c3

Please sign in to comment.