Description
I'm not sure that is a bug. Now I have a table and the primary key is ip. I want to do batch execution in the order of updated_at.
result := mysql.DB.Order("updated_at").FindInBatches(&ipLocations, 20,
func(tx *gorm.DB, batch int) error {
//xxxxxx
})
But I found that the primary key is used by default in FindInBatches to build SQL.
SELECT * FROM `ip_locations` ORDER BY updated_at,`ip_locations`.`ip` LIMIT 20
SELECT * FROM `ip_locations` WHERE `ip_locations`.`ip` > 'xxx' ORDER BY updated_at,`ip_locations`.`ip` LIMIT 20
SELECT * FROM `ip_locations` WHERE `ip_locations`.`ip` > 'xxx' ORDER BY updated_at,`ip_locations`.`ip` LIMIT 20
It is expected to be executed in batches through the updated_at field.
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 2 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: adamqazi
@00LT00 i am currently facing a similar issue, how were you able to work around this?
Comment From: rayjanoka
I think I'm running into this with a uuid primary key