Closed zishiguo closed 1 year ago
ShardingMigrator
need impl BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{})
So I copy migrator.Migrator.BuildIndexOptions
[v1.25.1] to ShardingMigrator
for impl
var _ = migrator.BuildIndexOptionsInterface(sharding.ShardingMigrator{}) // check impl
// BuildIndexOptions build index options
func (m ShardingMigrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{}) {
for _, opt := range opts {
str := stmt.Quote(opt.DBName)
if opt.Expression != "" {
str = opt.Expression
} else if opt.Length > 0 {
str += fmt.Sprintf("(%d)", opt.Length)
}
if opt.Collate != "" {
str += " COLLATE " + opt.Collate
}
if opt.Sort != "" {
str += " " + opt.Sort
}
results = append(results, clause.Expr{SQL: str})
}
return
}
@jinzhu suggest fix this bug, thanks
GORM Playground Link
569
Description
detailed error as follows