Fixed creation of associated records with composite primary keys (go-gorm#3817) (#3818)

This commit is contained in:
Andrei Baibaratsky 2020-12-03 08:00:26 +01:00 committed by GitHub
parent 51568ba4ab
commit f2321ca164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -318,12 +318,8 @@ func onConflictOption(stmt *gorm.Statement, s *schema.Schema, selectColumns map[
if len(defaultUpdatingColumns) > 0 { if len(defaultUpdatingColumns) > 0 {
var columns []clause.Column var columns []clause.Column
if s.PrioritizedPrimaryField != nil { for _, dbName := range s.PrimaryFieldDBNames {
columns = []clause.Column{{Name: s.PrioritizedPrimaryField.DBName}} columns = append(columns, clause.Column{Name: dbName})
} else {
for _, dbName := range s.PrimaryFieldDBNames {
columns = append(columns, clause.Column{Name: dbName})
}
} }
return clause.OnConflict{ return clause.OnConflict{