File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -48,19 +48,25 @@ func (dialector Dialector) Name() string {
48
48
}
49
49
50
50
func (dialector Dialector ) Apply (config * gorm.Config ) error {
51
- var namingStartegy * schema.NamingStrategy
51
+ if config .NamingStrategy == nil {
52
+ config .NamingStrategy = schema.NamingStrategy {
53
+ IdentifierMaxLength : defaultIdentifierLength ,
54
+ }
55
+ return nil
56
+ }
57
+
52
58
switch v := config .NamingStrategy .(type ) {
53
59
case * schema.NamingStrategy :
54
- namingStartegy = v
60
+ if v .IdentifierMaxLength <= 0 {
61
+ v .IdentifierMaxLength = defaultIdentifierLength
62
+ }
55
63
case schema.NamingStrategy :
56
- namingStartegy = & v
57
- case nil :
58
- namingStartegy = & schema.NamingStrategy {}
59
- }
60
- if namingStartegy .IdentifierMaxLength <= 0 {
61
- namingStartegy .IdentifierMaxLength = defaultIdentifierLength
64
+ if v .IdentifierMaxLength <= 0 {
65
+ v .IdentifierMaxLength = defaultIdentifierLength
66
+ config .NamingStrategy = v
67
+ }
62
68
}
63
- config . NamingStrategy = namingStartegy
69
+
64
70
return nil
65
71
}
66
72
You can’t perform that action at this time.
0 commit comments