MCPcopy Create free account
hub / github.com/apache/devlake / DropColumns

Method DropColumns

backend/impls/dalgorm/dalgorm.go:337–351  ·  view source on GitHub ↗

DropColumns drop one column from the table

(table string, columnNames ...string)

Source from the content-addressed store, hash-verified

335
336// DropColumns drop one column from the table
337func (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
354func (d *Dalgorm) GetPrimaryKeyFields(t reflect.Type) []reflect.StructField {

Callers

nothing calls this directly

Calls 2

ExecMethod · 0.95
convertGormErrorMethod · 0.95

Tested by

no test coverage detected