fix(storage): persist close_reason to issues table on close (#551)
CloseIssue was storing the reason only in the events table, not in the issues.close_reason column. This caused `bd show --json` to return an empty close_reason even when one was provided. - Update CloseIssue in queries.go and transaction.go to set close_reason - Clear close_reason when reopening issues (in manageClosedAt) - Add tests for close_reason in storage and CLI JSON output - Document the dual-storage of close_reason (issues + events tables)
This commit is contained in:
@@ -462,13 +462,14 @@ func applyUpdatesToIssue(issue *types.Issue, updates map[string]interface{}) {
|
||||
}
|
||||
|
||||
// CloseIssue closes an issue within the transaction.
|
||||
// NOTE: close_reason is stored in both issues table and events table - see SQLiteStorage.CloseIssue.
|
||||
func (t *sqliteTxStorage) CloseIssue(ctx context.Context, id string, reason string, actor string) error {
|
||||
now := time.Now()
|
||||
|
||||
result, err := t.conn.ExecContext(ctx, `
|
||||
UPDATE issues SET status = ?, closed_at = ?, updated_at = ?
|
||||
UPDATE issues SET status = ?, closed_at = ?, updated_at = ?, close_reason = ?
|
||||
WHERE id = ?
|
||||
`, types.StatusClosed, now, now, id)
|
||||
`, types.StatusClosed, now, now, reason, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to close issue: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user