From 1f6e461533f531a25bdb9cf60c1cafc125aa06ba Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Mon, 2 Dec 2013 14:01:59 +0100 Subject: Fix positional binding values order in QSqlQuery Adapt the stringification code, that is used to produce the keys for QSqlQuery::boundValues() return value, to keep the right order of the binding values. Task-number: QTBUG-12186 Change-Id: Ic11a455bfd9ffd1418b1b021ce5cf78cae9b4504 [ChangeLog][QtSql] Fixed the order of values with positional binding in a QSqlQuery Reviewed-by: Andy Shaw Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 38f561dbaa..5f1eb99524 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -211,6 +211,8 @@ private slots: void QTBUG_6852(); void QTBUG_5765_data() { generic_data("QMYSQL"); } void QTBUG_5765(); + void QTBUG_12186_data() { generic_data("QSQLITE"); } + void QTBUG_12186(); void QTBUG_14132_data() { generic_data("QOCI"); } void QTBUG_14132(); void QTBUG_18435_data() { generic_data("QODBC"); } @@ -3054,6 +3056,27 @@ void tst_QSqlQuery::QTBUG_551() QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2")); } +void tst_QSqlQuery::QTBUG_12186() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database(dbName); + + // make sure that query.boundValues() returns the values in the right order even for more than 16 placeholders + QSqlQuery query(db); + query.prepare("INSERT INTO person (col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13, col14, col15, col16, col17, col18) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + QList values; + + for (int i = 0; i < 18; ++i) + values << i; + + foreach (QVariant v, values) + query.bindValue(v.toInt(), v); + + QCOMPARE(query.boundValues().values(), values); +} + void tst_QSqlQuery::QTBUG_14132() { QFETCH( QString, dbName ); -- cgit v1.2.3