QSqlTableMode::selectRow(): lack of WHERE clause is an error

Since we only want one row, never ever run a SELECT without a WHERE
clause.

Change-Id: I40a78935f5573111faa3922eae97e6d5961be5f2
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
Mark Brand 2012-09-17 15:49:31 +02:00 committed by The Qt Project
parent 3c2733e45f
commit 7b95df2da0
1 changed files with 9 additions and 1 deletions

View File

@ -427,10 +427,18 @@ bool QSqlTableModel::selectRow(int row)
static const QString wh = Sql::where() + Sql::sp();
if (d->filter.startsWith(wh, Qt::CaseInsensitive))
d->filter.remove(0, wh.length());
const QString stmt = selectStatement();
QString stmt;
if (!d->filter.isEmpty())
stmt = selectStatement();
d->sortColumn = table_sort_col;
d->filter = table_filter;
if (stmt.isEmpty())
return false;
{
QSqlQuery q(d->db);
q.setForwardOnly(true);