TableInfo returns the "table_info" pragma result for the specified table.
(tableName string)
| 32 | |
| 33 | // TableInfo returns the "table_info" pragma result for the specified table. |
| 34 | func (app *BaseApp) TableInfo(tableName string) ([]*TableInfoRow, error) { |
| 35 | info := []*TableInfoRow{} |
| 36 | |
| 37 | err := app.ConcurrentDB().NewQuery("SELECT * FROM PRAGMA_TABLE_INFO({:tableName})"). |
| 38 | Bind(dbx.Params{"tableName": tableName}). |
| 39 | All(&info) |
| 40 | if err != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | |
| 44 | // mattn/go-sqlite3 doesn't throw an error on invalid or missing table |
| 45 | // so we additionally have to check whether the loaded info result is nonempty |
| 46 | if len(info) == 0 { |
| 47 | return nil, fmt.Errorf("empty table info probably due to invalid or missing table %s", tableName) |
| 48 | } |
| 49 | |
| 50 | return info, nil |
| 51 | } |
| 52 | |
| 53 | // TableIndexes returns a name grouped map with all non empty index of the specified table. |
| 54 | // |
nothing calls this directly
no test coverage detected