Fix SQL insert statement to properly quote column names in monthly aggregates
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-18 11:19:44 +11:00
parent e4d73ee294
commit 9419103709
2 changed files with 48 additions and 5 deletions

View File

@@ -679,11 +679,15 @@ func (c *CronTask) insertMonthlyAggregates(ctx context.Context, summaryTable str
"PoolTinPct", "PoolBronzePct", "PoolSilverPct", "PoolGoldPct",
"Tin", "Bronze", "Silver", "Gold",
}
quotedColumns := make([]string, len(columns))
for i, col := range columns {
quotedColumns[i] = fmt.Sprintf(`"%s"`, col)
}
placeholders := make([]string, len(columns))
for i := range columns {
placeholders[i] = "?"
}
stmtText := fmt.Sprintf(`INSERT INTO %s (%s) VALUES (%s)`, summaryTable, strings.Join(columns, ","), strings.Join(placeholders, ","))
stmtText := fmt.Sprintf(`INSERT INTO %s (%s) VALUES (%s)`, summaryTable, strings.Join(quotedColumns, ","), strings.Join(placeholders, ","))
stmtText = dbConn.Rebind(stmtText)
tx, err := dbConn.BeginTxx(ctx, nil)