diff options
author | Mark Brand <mabrand@mabrand.nl> | 2013-01-26 23:09:24 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-06 07:57:13 +0100 |
commit | a694b9f8d204d6555caf4e30dbd18f536859c5bd (patch) | |
tree | c1c58300e4f97468fa9d34fa07b7df14e7507c0e /tests/auto/sql/models | |
parent | 04478614c1f21de8ff9abb7fe9dc64c672065695 (diff) |
fix QSqlTableModel::headerData() for empty query with inserted row
QSqlQueryModel::headerData() relied on virtual indexInQuery() to
detect whether the requested column at row 0 mapped to an index in
the query. This failed when row 0 was a pending insert managed by
QSqlTableModel, and therefore not in the query.
The only thing that matters here is the column.
Task-number: QTBUG-29108
Change-Id: I3e0ae85ba223e444781ec8033386d394bb44f0e8
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'tests/auto/sql/models')
-rw-r--r-- | tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index 92356e6707..e4223ae53a 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -1433,6 +1433,14 @@ void tst_QSqlTableModel::emptyTable() QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 0); QCOMPARE(model.columnCount(), 1); + + // QTBUG-29108: check correct horizontal header for empty query with pending insert + QCOMPARE(model.headerData(0, Qt::Horizontal).toString(), QString("id")); + model.setEditStrategy(QSqlTableModel::OnManualSubmit); + model.insertRow(0); + QCOMPARE(model.rowCount(), 1); + QCOMPARE(model.headerData(0, Qt::Horizontal).toString(), QString("id")); + model.revertAll(); } void tst_QSqlTableModel::tablesAndSchemas() |