TableIndexes returns a name grouped map with all non empty index of the specified table. Note: This method doesn't return an error on nonexisting table.
(tableName string)
| 54 | // |
| 55 | // Note: This method doesn't return an error on nonexisting table. |
| 56 | func (app *BaseApp) TableIndexes(tableName string) (map[string]string, error) { |
| 57 | indexes := []struct { |
| 58 | Name string |
| 59 | Sql string |
| 60 | }{} |
| 61 | |
| 62 | err := app.ConcurrentDB().Select("name", "sql"). |
| 63 | From("sqlite_master"). |
| 64 | AndWhere(dbx.NewExp("sql is not null")). |
| 65 | AndWhere(dbx.HashExp{ |
| 66 | "type": "index", |
| 67 | "tbl_name": tableName, |
| 68 | }). |
| 69 | All(&indexes) |
| 70 | if err != nil { |
| 71 | return nil, err |
| 72 | } |
| 73 | |
| 74 | result := make(map[string]string, len(indexes)) |
| 75 | |
| 76 | for _, idx := range indexes { |
| 77 | result[idx.Name] = idx.Sql |
| 78 | } |
| 79 | |
| 80 | return result, nil |
| 81 | } |
| 82 | |
| 83 | // DeleteTable drops the specified table. |
| 84 | // |
nothing calls this directly
no test coverage detected