RunWithValue run migration with statement value
(value interface{}, fc func(*gorm.Statement) error)
| 60 | |
| 61 | // RunWithValue run migration with statement value |
| 62 | func (m Migrator) RunWithValue(value interface{}, fc func(*gorm.Statement) error) error { |
| 63 | stmt := &gorm.Statement{DB: m.DB} |
| 64 | if m.DB.Statement != nil { |
| 65 | stmt.Table = m.DB.Statement.Table |
| 66 | stmt.TableExpr = m.DB.Statement.TableExpr |
| 67 | } |
| 68 | |
| 69 | if table, ok := value.(string); ok { |
| 70 | stmt.Table = table |
| 71 | } else if err := stmt.ParseWithSpecialTableName(value, stmt.Table); err != nil { |
| 72 | return err |
| 73 | } |
| 74 | |
| 75 | return fc(stmt) |
| 76 | } |
| 77 | |
| 78 | // DataTypeOf return field's db data type |
| 79 | func (m Migrator) DataTypeOf(field *schema.Field) string { |
no test coverage detected