forked from mirror/gorm
style: fix linter check for NamingStrategy and onConflictOption (#5174)
This commit is contained in:
parent
0097b39a77
commit
2d5cb997ed
|
@ -323,7 +323,7 @@ func SaveAfterAssociations(create bool) func(db *gorm.DB) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func onConflictOption(stmt *gorm.Statement, s *schema.Schema, selectColumns map[string]bool, restricted bool, defaultUpdatingColumns []string) (onConflict clause.OnConflict) {
|
func onConflictOption(stmt *gorm.Statement, s *schema.Schema, defaultUpdatingColumns []string) (onConflict clause.OnConflict) {
|
||||||
if len(defaultUpdatingColumns) > 0 || stmt.DB.FullSaveAssociations {
|
if len(defaultUpdatingColumns) > 0 || stmt.DB.FullSaveAssociations {
|
||||||
onConflict.Columns = make([]clause.Column, 0, len(s.PrimaryFieldDBNames))
|
onConflict.Columns = make([]clause.Column, 0, len(s.PrimaryFieldDBNames))
|
||||||
for _, dbName := range s.PrimaryFieldDBNames {
|
for _, dbName := range s.PrimaryFieldDBNames {
|
||||||
|
@ -349,7 +349,7 @@ func saveAssociations(db *gorm.DB, rel *schema.Relationship, rValues reflect.Val
|
||||||
|
|
||||||
var (
|
var (
|
||||||
selects, omits []string
|
selects, omits []string
|
||||||
onConflict = onConflictOption(db.Statement, rel.FieldSchema, selectColumns, restricted, defaultUpdatingColumns)
|
onConflict = onConflictOption(db.Statement, rel.FieldSchema, defaultUpdatingColumns)
|
||||||
refName = rel.Name + "."
|
refName = rel.Name + "."
|
||||||
values = rValues.Interface()
|
values = rValues.Interface()
|
||||||
)
|
)
|
||||||
|
|
|
@ -85,9 +85,9 @@ func (ns NamingStrategy) IndexName(table, column string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ns NamingStrategy) formatName(prefix, table, name string) string {
|
func (ns NamingStrategy) formatName(prefix, table, name string) string {
|
||||||
formattedName := strings.Replace(strings.Join([]string{
|
formattedName := strings.ReplaceAll(strings.Join([]string{
|
||||||
prefix, table, name,
|
prefix, table, name,
|
||||||
}, "_"), ".", "_", -1)
|
}, "_"), ".", "_")
|
||||||
|
|
||||||
if utf8.RuneCountInString(formattedName) > 64 {
|
if utf8.RuneCountInString(formattedName) > 64 {
|
||||||
h := sha1.New()
|
h := sha1.New()
|
||||||
|
|
Loading…
Reference in New Issue