From c0e5fba42f6c9259324e8aba0d050ae2e8647cd3 Mon Sep 17 00:00:00 2001 From: Amogh Bharadwaj <65964360+Amogh-Bharadwaj@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:09:26 +0530 Subject: [PATCH] TSTZRange: Account for infinity modifier (#2377) We need to explicity deal with infinity/-infinity tstzrange values as time.Parse cannot parse those --- flow/connectors/postgres/qvalue_convert.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flow/connectors/postgres/qvalue_convert.go b/flow/connectors/postgres/qvalue_convert.go index e3052a08f..9e8f75848 100644 --- a/flow/connectors/postgres/qvalue_convert.go +++ b/flow/connectors/postgres/qvalue_convert.go @@ -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 }