Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: handle negative time interval (#16914)
rebelice12672cded45e
diff --git a/backend/plugin/db/pg/query.go b/backend/plugin/db/pg/query.goindex a98c52c2a1..ff383f474b 100644--- a/backend/plugin/db/pg/query.go+++ b/backend/plugin/db/pg/query.go@@ -163,7 +163,11 @@ func padZeroes(rawStr string, acc int) string {if plusIndex := strings.Index(rawStr, "+"); plusIndex >= 0 {endIndex = plusIndex} else if minusIndex := strings.Index(rawStr, "-"); minusIndex >= 0 {- endIndex = minusIndex+ // For negative intervals like "-00:04:37.530865", ignore the leading minus+ // Only consider minus signs that appear after the decimal point (timezone indicators)+ if minusIndex > dotIndex {+ endIndex = minusIndex+ }}// Validate slice bounds to prevent runtime panicdiff --git a/backend/plugin/db/pg/query_test.go b/backend/plugin/db/pg/query_test.goindex 3769aba0a8..c955a5a770 100644--- a/backend/plugin/db/pg/query_test.go+++ b/backend/plugin/db/pg/query_test.go@@ -53,7 +53,31 @@ func TestPadZeroes(t *testing.T) {name: "Invalid format: timezone before decimal (edge case fix)",rawStr: "12:34-05:56.123",acc: 6,- expected: "12:34-05:56.123",+ expected: "12:34-05:56.123000",+ },+ {+ name: "Negative interval: leading minus should be ignored",+ rawStr: "-00:04:37.530865",+ acc: 6,+ expected: "-00:04:37.530865",+ },+ {+ name: "Negative interval with short precision",+ rawStr: "-00:02:45.25",+ acc: 6,+ expected: "-00:02:45.250000",+ },+ {+ name: "Negative interval without decimal",+ rawStr: "-00:05:00",+ acc: 6,+ expected: "-00:05:00",+ },+ {+ name: "Negative interval with timezone (minus after decimal)",+ rawStr: "-12:34:56.123-05:00",+ acc: 6,+ expected: "-12:34:56.123-05:00",},}