mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 18:40:13 -06:00
add a check for valid querys
This commit is contained in:
@@ -10,6 +10,7 @@ SqliteTableModel::SqliteTableModel(QObject* parent, DBBrowserDB* db)
|
||||
, m_iSortColumn(0)
|
||||
, m_sSortOrder("ASC")
|
||||
, m_chunkSize(50000)
|
||||
, m_valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,11 +56,20 @@ void SqliteTableModel::setQuery(const QString& sQuery)
|
||||
m_rowCount = sCount.toInt();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Count query failed: " << sCountQuery;
|
||||
sqlite3_finalize(stmt);
|
||||
m_valid = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
// now fetch the first entries
|
||||
clearCache();
|
||||
fetchData(0, m_chunkSize);
|
||||
m_valid = true;
|
||||
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ public:
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
|
||||
bool valid() const { return m_valid; }
|
||||
|
||||
typedef QList<QByteArray> QByteArrayList;
|
||||
|
||||
signals:
|
||||
@@ -65,6 +67,8 @@ private:
|
||||
* to that row count.
|
||||
*/
|
||||
size_t m_chunkSize;
|
||||
|
||||
bool m_valid; //! tells if the current query is valid.
|
||||
};
|
||||
|
||||
#endif // SQLITETABLEMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user