Skip to content

Commit

Permalink
make fmt.Sprinf queries vars
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Nov 6, 2024
1 parent 4bf9e53 commit 29ae9d1
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions go/vt/vtorc/inst/instance_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 29ae9d1

Please sign in to comment.