MCPcopy
hub / github.com/go-gorm/gorm / onConflictOption

Function onConflictOption

callbacks/associations.go:360–376  ·  view source on GitHub ↗
(stmt *gorm.Statement, s *schema.Schema, defaultUpdatingColumns []string)

Source from the content-addressed store, hash-verified

358}
359
360func onConflictOption(stmt *gorm.Statement, s *schema.Schema, defaultUpdatingColumns []string) (onConflict clause.OnConflict) {
361 if len(defaultUpdatingColumns) > 0 || stmt.DB.FullSaveAssociations {
362 onConflict.Columns = make([]clause.Column, 0, len(s.PrimaryFieldDBNames))
363 for _, dbName := range s.PrimaryFieldDBNames {
364 onConflict.Columns = append(onConflict.Columns, clause.Column{Name: dbName})
365 }
366
367 onConflict.UpdateAll = stmt.DB.FullSaveAssociations
368 if !onConflict.UpdateAll {
369 onConflict.DoUpdates = clause.AssignmentColumns(defaultUpdatingColumns)
370 }
371 } else {
372 onConflict.DoNothing = true
373 }
374
375 return
376}
377
378func saveAssociations(db *gorm.DB, rel *schema.Relationship, rValues reflect.Value, selectColumns map[string]bool, restricted bool, defaultUpdatingColumns []string) error {
379 // stop save association loop

Callers 1

saveAssociationsFunction · 0.85

Calls 1

AssignmentColumnsFunction · 0.92

Tested by

no test coverage detected