summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorIsrael Lins Albuquerque <israel@proabakus.com.br>2014-04-15 17:37:18 -0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-26 20:22:42 +0200
commit3e6e70bddd84536deaae69421d05785ae6ce28cd (patch)
tree227484a53c825f5ec17e9a4069d85bc460d4e861 /tests/auto
parenta2ad5cf1aadd5a3bec09595be7e8611abab31bb6 (diff)
[QSqlQuery] misbehavior of seek in special query positions
When QSqlQuery::at() == QSql::BeforeFirstRow and seek(1, true) (seek to next record) is called the expected result is go to first row. When QSqlQuery::at() == QSql::AfterLastRow and seek(-1, true) (seek to previous record) is called the expected result is go to last row. But in all cases the first and last are skipped. Change-Id: I584138b3d397ce1c790bf89688ee92289a99611c Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 55cb67eed9..301c7bca51 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -1247,6 +1247,26 @@ void tst_QSqlQuery::seek()
QVERIFY( q.seek( 0 ) );
QCOMPARE( q.at(), 0 );
QCOMPARE( q.value( 0 ).toInt(), 1 );
+
+ QVERIFY(!q.seek(QSql::BeforeFirstRow));
+ QCOMPARE(q.at(), int(QSql::BeforeFirstRow));
+ QVERIFY(q.seek(1, true));
+ QCOMPARE(q.at(), 0);
+ QCOMPARE(q.value(0).toInt(), 1);
+
+ qint32 count = 1;
+ while (q.next()) ++count;
+
+ QCOMPARE(q.at(), int(QSql::AfterLastRow));
+
+ if (!q.isForwardOnly()) {
+ QVERIFY(q.seek(-1, true));
+ QCOMPARE(q.at(), count - 1);
+ QCOMPARE(q.value(0).toInt(), count);
+ } else {
+ QVERIFY(!q.seek(-1, true));
+ QCOMPARE(q.at(), int(QSql::AfterLastRow));
+ }
}
void tst_QSqlQuery::seekForwardOnlyQuery()