Replace executedQuery when executing a new query
Only the first successful query was stored in the variable. When a new query is executed the function QSqlResult::setActive was not replacing the last executed query. Fixes: QTBUG-28883 Change-Id: Ib4938c42e6264f9edd0764b4a392da7988f68fc0 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
parent
0bde49bd92
commit
9501e92841
@ -386,7 +386,7 @@ const QSqlDriver *QSqlResult::driver() const
|
|||||||
void QSqlResult::setActive(bool active)
|
void QSqlResult::setActive(bool active)
|
||||||
{
|
{
|
||||||
Q_D(QSqlResult);
|
Q_D(QSqlResult);
|
||||||
if (active && d->executedQuery.isEmpty())
|
if (active)
|
||||||
d->executedQuery = d->sql;
|
d->executedQuery = d->sql;
|
||||||
|
|
||||||
d->active = active;
|
d->active = active;
|
||||||
|
@ -158,6 +158,8 @@ private slots:
|
|||||||
void lastInsertId();
|
void lastInsertId();
|
||||||
void lastQuery_data() { generic_data(); }
|
void lastQuery_data() { generic_data(); }
|
||||||
void lastQuery();
|
void lastQuery();
|
||||||
|
void lastQueryTwoQueries_data() { generic_data(); }
|
||||||
|
void lastQueryTwoQueries();
|
||||||
void bindBool_data() { generic_data(); }
|
void bindBool_data() { generic_data(); }
|
||||||
void bindBool();
|
void bindBool();
|
||||||
void psql_bindWithDoubleColonCastOperator_data() { generic_data("QPSQL"); }
|
void psql_bindWithDoubleColonCastOperator_data() { generic_data("QPSQL"); }
|
||||||
@ -2813,6 +2815,25 @@ void tst_QSqlQuery::lastQuery()
|
|||||||
QCOMPARE( q.executedQuery(), sql );
|
QCOMPARE( q.executedQuery(), sql );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QSqlQuery::lastQueryTwoQueries()
|
||||||
|
{
|
||||||
|
QFETCH(QString, dbName);
|
||||||
|
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||||
|
CHECK_DATABASE(db);
|
||||||
|
|
||||||
|
QSqlQuery q(db);
|
||||||
|
|
||||||
|
QString sql = QLatin1String("select * from ") + qtest;
|
||||||
|
QVERIFY_SQL(q, exec(sql));
|
||||||
|
QCOMPARE(q.lastQuery(), sql);
|
||||||
|
QCOMPARE(q.executedQuery(), sql);
|
||||||
|
|
||||||
|
sql = QLatin1String("select id from ") + qtest;
|
||||||
|
QVERIFY_SQL(q, exec(sql));
|
||||||
|
QCOMPARE(q.lastQuery(), sql);
|
||||||
|
QCOMPARE(q.executedQuery(), sql);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QSqlQuery::psql_bindWithDoubleColonCastOperator()
|
void tst_QSqlQuery::psql_bindWithDoubleColonCastOperator()
|
||||||
{
|
{
|
||||||
QFETCH( QString, dbName );
|
QFETCH( QString, dbName );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user