in file: callbacks/query.go

192         db.Statement.Joins = nil

I have 2 models:

type User struct {
    models.Base
    NickName string
}
type Order struct {
    models.Base
    UserId int64
    User   User
}

I use join like this:

    var order Order
    db, _ := gorm.Open(mysql.Open(app.Config.Mysql.Connection), &gorm.Config{})

    tx := db.Joins("User")
    tx.Where("User.nick_name = ?", "bin")

    var count int64
    tx.Model(order)
    tx.Count(&count)
    tx.Find(&order)

    fmt.Println("name:", order.User.NickName)
    fmt.Println("count:", count)

I want to get both count and data, But I found order.User is empty. I check the code, and found after called tx.Count(&count), db.Statement.Joins will be set to nil. so tx.Find(&order) can't set association data.

So why set "db.Statement.Joins = nil", if delete this code will have any problems?

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