From 29ae9d1ffa9d5cb0d31a09c8d9876c6cfc9f0a40 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Wed, 6 Nov 2024 01:38:28 +0100 Subject: [PATCH] make fmt.Sprinf queries vars Signed-off-by: Tim Vaillancourt --- go/vt/vtorc/inst/instance_dao.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/go/vt/vtorc/inst/instance_dao.go b/go/vt/vtorc/inst/instance_dao.go index b2c828ce7c4..5be628941c4 100644 --- a/go/vt/vtorc/inst/instance_dao.go +++ b/go/vt/vtorc/inst/instance_dao.go @@ -114,15 +114,15 @@ func ExecDBWriteFunc(f func() error) error { func ExpireTableData(tableName string, timestampColumn string) error { writeFunc := func() error { - _, err := db.ExecVTOrc( - fmt.Sprintf(`DELETE - FROM %s - WHERE %s < DATETIME('now', PRINTF('-%%d DAY', ?))`, - tableName, - timestampColumn, - ), - config.Config.AuditPurgeDays, + query := fmt.Sprintf(`DELETE + FROM %s + WHERE + %s < DATETIME('now', PRINTF('-%%d DAY', ?)) + `, + tableName, + timestampColumn, ) + _, err := db.ExecVTOrc(query, config.Config.AuditPurgeDays) return err } return ExecDBWriteFunc(writeFunc) @@ -759,12 +759,17 @@ func mkInsert(table string, columns []string, values []string, nrRows int, inser } col := strings.Join(columns, ", ") - q.WriteString(fmt.Sprintf(`%s %s + query := fmt.Sprintf(`%s %s (%s) VALUES %s `, - insertStr, table, col, val.String())) + insertStr, + table, + col, + val.String(), + ) + q.WriteString(query) return q.String(), nil }