fixed daos.SaveView test

This commit is contained in:
Gani Georgiev
2023-02-18 20:31:41 +02:00
parent 5fd7f61656
commit b184ef6c3a
3 changed files with 13 additions and 4 deletions

View File

@@ -39,8 +39,17 @@ func (dao *Dao) GetTableInfo(tableName string) ([]*models.TableInfoRow, error) {
err := dao.DB().NewQuery("SELECT * FROM PRAGMA_TABLE_INFO({:tableName})").
Bind(dbx.Params{"tableName": tableName}).
All(&info)
if err != nil {
return nil, err
}
return info, err
// mattn/go-sqlite3 doesn't throw an error on invalid or missing table
// so we additionally have to check whether the loaded info result is nonempty
if len(info) == 0 {
return nil, fmt.Errorf("empty table info probably due to invalid or missing table %s", tableName)
}
return info, nil
}
// DeleteTable drops the specified table.