BuildIndexOptions build index options
(opts []schema.IndexOption, stmt *gorm.Statement)
| 806 | |
| 807 | // BuildIndexOptions build index options |
| 808 | func (m Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{}) { |
| 809 | for _, opt := range opts { |
| 810 | str := stmt.Quote(opt.DBName) |
| 811 | if opt.Expression != "" { |
| 812 | str = opt.Expression |
| 813 | } else if opt.Length > 0 { |
| 814 | str += fmt.Sprintf("(%d)", opt.Length) |
| 815 | } |
| 816 | |
| 817 | if opt.Collate != "" { |
| 818 | str += " COLLATE " + opt.Collate |
| 819 | } |
| 820 | |
| 821 | if opt.Sort != "" { |
| 822 | str += " " + opt.Sort |
| 823 | } |
| 824 | results = append(results, clause.Expr{SQL: str}) |
| 825 | } |
| 826 | return |
| 827 | } |
| 828 | |
| 829 | // BuildIndexOptionsInterface build index options interface |
| 830 | type BuildIndexOptionsInterface interface { |