DropColumns drop one column from the table
(table string, columnNames ...string)
| 335 | |
| 336 | // DropColumns drop one column from the table |
| 337 | func (d *Dalgorm) DropColumns(table string, columnNames ...string) errors.Error { |
| 338 | // work around the error `cached plan must not change result type` for postgres |
| 339 | // wrap in func(){} to make the linter happy |
| 340 | defer func() { |
| 341 | _ = d.Exec("SELECT * FROM ? LIMIT 1", clause.Table{Name: table}) |
| 342 | }() |
| 343 | for _, columnName := range columnNames { |
| 344 | err := d.Exec("ALTER TABLE ? DROP COLUMN ?", clause.Table{Name: table}, clause.Column{Name: columnName}) |
| 345 | // err := d.db.Migrator().DropColumn(table, columnName) |
| 346 | if err != nil { |
| 347 | return d.convertGormError(err) |
| 348 | } |
| 349 | } |
| 350 | return nil |
| 351 | } |
| 352 | |
| 353 | // GetPrimaryKeyFields get the PrimaryKey from `gorm` tag |
| 354 | func (d *Dalgorm) GetPrimaryKeyFields(t reflect.Type) []reflect.StructField { |
nothing calls this directly
no test coverage detected