GORM Playground Link

https://github.com/go-gorm/playground/pull/1

To be added

Description

To do an update currently, I have to call .Find() to verify the primaryKey exists before calling .Update(). To avoid the first Find call, I thought I could check RowsAffected for the update call, but it will return 0 even if the primaryKey is found but the data I'm updating is the exact same as what's in the DB.

MySQL has an option ClientFoundRows which changes the return result to whether the db found any rows to update, regardless of whether any rows were actually updated. This is what I want to return to indicate that rows were found, so that I don't need to call Find first. Unfortunately, this configuration does not seem to change the result of RowsAffected when testing:

db, err := gorm.Open(
    mysql.New(
        mysql.Config{
            DSN: dbConns[1],
            DSNConfig: &gosqldriver.Config{
                ClientFoundRows: true,
            },
        },
    ),
    &gorm.Config{Logger: logger.Default.LogMode(logger.Info)},
)

Thus I think there's a bug in how gorm is handling the ClientFoundRows option for MySQL?

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