diff options
author | Michael Goddard <michael.goddard@nokia.com> | 2010-11-02 02:14:03 (GMT) |
---|---|---|
committer | Michael Goddard <michael.goddard@nokia.com> | 2011-02-04 05:41:01 (GMT) |
commit | 9c61e9a40e774fe32b16c133a5cdd6b9d9d29d83 (patch) | |
tree | 081b136915ae1bf29c1567bd5bdca841099860d1 /tests/auto/qsqldatabase | |
parent | accc1acc8632e5b21114600b5bcb92cf74004097 (diff) | |
download | Qt-9c61e9a40e774fe32b16c133a5cdd6b9d9d29d83.zip Qt-9c61e9a40e774fe32b16c133a5cdd6b9d9d29d83.tar.gz Qt-9c61e9a40e774fe32b16c133a5cdd6b9d9d29d83.tar.bz2 |
QSqlTableModel/QSqlQueryModel and insertColumns problem.
After inserting a column, fetching data through QSqlTableModel was
off by one or more, since it passed the indexInQuery through to
QSQM. Also, the headerData would sometimes return a blank string
for an inserted column, and sometimes the column number.
The autotests have been beefed up a little to check insertRows and
insertColumns play nicely.
Change-Id: I7399d4c4d94f958884b67ab9b39b5cf2485d8416
Task-number: QTBUG-12626
Reviewed-by: Charles Yin
Diffstat (limited to 'tests/auto/qsqldatabase')
-rw-r--r-- | tests/auto/qsqldatabase/tst_databases.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index 5dcf754..350e0d0 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -51,6 +51,7 @@ #include <QDir> #include <QVariant> #include <QDebug> +#include <QSqlTableModel> #include <QtTest/QtTest> @@ -166,6 +167,29 @@ public: return count; } + int fillTestTableWithStrategies( const QString& driverPrefix = QString() ) const + { + QTest::addColumn<QString>( "dbName" ); + QTest::addColumn<int>("submitpolicy_i"); + int count = 0; + + for ( int i = 0; i < dbNames.count(); ++i ) { + QSqlDatabase db = QSqlDatabase::database( dbNames.at( i ) ); + + if ( !db.isValid() ) + continue; + + if ( driverPrefix.isEmpty() || db.driverName().startsWith( driverPrefix ) ) { + QTest::newRow( QString("%1 [field]").arg(dbNames.at( i )).toLatin1() ) << dbNames.at( i ) << (int)QSqlTableModel::OnFieldChange; + QTest::newRow( QString("%1 [row]").arg(dbNames.at( i )).toLatin1() ) << dbNames.at( i ) << (int)QSqlTableModel::OnRowChange; + QTest::newRow( QString("%1 [manual]").arg(dbNames.at( i )).toLatin1() ) << dbNames.at( i ) << (int)QSqlTableModel::OnManualSubmit; + ++count; + } + } + + return count; + } + void addDb( const QString& driver, const QString& dbName, const QString& user = QString(), const QString& passwd = QString(), const QString& host = QString(), int port = -1, const QString params = QString() ) |