fix: migration 022 fails with SQL syntax error on v0.30.3 upgrade
db.Exec was being passed %s format specifiers directly in the SQL string, but db.Exec does not do printf-style formatting - it uses the variadic args as SQL parameter bindings. This caused the literal %s to be sent to SQLite, which failed with near percent: syntax error. Fixed by using fmt.Sprintf to interpolate the column expressions into the SQL string before passing to db.Exec. Added regression test that creates an old-schema database with edge columns (replies_to, relates_to, duplicate_of, superseded_by) and verifies migration 022 completes successfully. Fixes #809 Generated with Claude Code Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -183,7 +183,9 @@ func MigrateDropEdgeColumns(db *sql.DB) error {
|
||||
}
|
||||
|
||||
// Copy data from old table to new table (excluding deprecated columns)
|
||||
_, err = db.Exec(`
|
||||
// NOTE: We use fmt.Sprintf here (not db.Exec parameters) because we're interpolating
|
||||
// column names/expressions, not values. db.Exec parameters only work for VALUES.
|
||||
copySQL := fmt.Sprintf(`
|
||||
INSERT INTO issues_new (
|
||||
id, content_hash, title, description, design, acceptance_criteria,
|
||||
notes, status, priority, issue_type, assignee, estimated_minutes,
|
||||
@@ -203,6 +205,7 @@ func MigrateDropEdgeColumns(db *sql.DB) error {
|
||||
COALESCE(close_reason, '')
|
||||
FROM issues
|
||||
`, pinnedExpr, isTemplateExpr, awaitTypeExpr, awaitIDExpr, timeoutNsExpr, waitersExpr)
|
||||
_, err = db.Exec(copySQL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to copy issues data: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user