I have 2 models as below:

type Banner struct {
    Base
    Description string       `json:"description"`
    LinkTo      string       `json:"link_to"`
    Priority    uint         ` json:"priority"`
    Images      []Attachment `gorm:"polymorphic:Attachment;polymorphicValue:BannerImages" json:"images,omitempty"`
    Medias      []Attachment `gorm:"polymorphic:Attachment;polymorphicValue:BannerMedias" json:"medias,omitempty"`
}

type Attachment struct {
    Base
    AttachmentID   uint   `json:"attachment_id"`
    AttachmentType string `json:"attachment"`
    Url            string `json:"url"`
    OriginalUrl    string `json:"original_url,omitempty"`
    OrgUrlV2       string `json:"-"`
}

When I'm trying to delete the Banner with Select, I check the debug log it work as expected. But I can't access any data in BeforeDelete Hook of Attachment Model. Do you have any idea about this?

var banner model.Banner
DB.Preload("Images").Where("id = ?", context.Param("id")).First(&banner)
DB.Debug().Select("Images").Delete(&banner)

UPDATE `attachments` SET `deleted_at`='2023-04-29 20:20:44.812' WHERE `attachments`.`attachment_type` = 'BannerImages' AND `attachments`.`attachment_id` = 17 AND `attachments`.`deleted_at` IS NULL

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking