Correct check for single column pk to handle multi column pk

This commit is contained in:
Keith Martin 2025-05-12 22:21:23 +10:00
parent f121f183b0
commit 0fe079686b

View File

@ -228,7 +228,7 @@ func (db *DB) FindInBatches(dest interface{}, batchSize int, fc func(tx *DB, bat
// Optimize for-break
resultsValue := reflect.Indirect(reflect.ValueOf(dest))
if result.Statement.Schema.PrioritizedPrimaryField == nil {
if result.Statement.Schema.PrioritizedPrimaryField == nil && result.Statement.Schema.PrimaryFields != nil && len(result.Statement.Schema.PrimaryFields) == 1 {
tx.AddError(ErrPrimaryKeyRequired)
break
}