Skip to content

soft_delete: support extra fields#21

Open
qqxhb wants to merge 2 commits intomasterfrom
feature-extra-fields
Open

soft_delete: support extra fields#21
qqxhb wants to merge 2 commits intomasterfrom
feature-extra-fields

Conversation

@qqxhb
Copy link
Member

@qqxhb qqxhb commented Mar 9, 2026

Allow updating additional columns in the same soft-delete SQL.

Usage:

  • Tag: gorm:"softDelete:flag,ExtraFields:DeletedBy" (multiple names separated by ; or |)
  • Pass values via: db.Set(soft_delete.ExtraSettingsKey, map[string]interface{}{"DeletedBy": userID})
  • In hooks: soft_delete.SetExtra(tx, map[string]interface{}{"DeletedBy": userID})

Notes:

  • ExtraSettingsKey is consumed per statement to avoid leaking values across operations.

Tests:

  • go test ./...

qqxhb added 2 commits March 9, 2026 11:09
Allow updating additional columns during soft delete via ExtraFields tag and values passed with statement settings.
Add SetExtra helper for hooks, clear extra settings after applying, and expand tests/README.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant