Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.6.3, 5.3.0 Alpha
-
None
Description
The position of the bound values is decided by their key in the used QMap. The key is generated by qFieldSerial(int i) in qsqlresult.cpp. This will only work for cases where the number of bindings is less than 16, since after that the new :fab value will be sorted by the QMap right after the first :f value.
Code reproducing the problem
#include <QtGui> #include <QtSql> int main(int argc, char *argv[]) { QApplication app(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(":memory:"); QSqlQuery query; query.prepare("INSERT INTO person (col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13, col14, col15, col16, col17, col18) " "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?. ?, ?)"); for(int i = 0; i < 18; ++i) query.bindValue(i, i); QMapIterator<QString, QVariant> i(query.boundValues()); while (i.hasNext()) { i.next(); qDebug() << i.key().toAscii().data() << ": " << i.value().toString().toAscii().data(); } return 0; }
Attachments
For Gerrit Dashboard: QTBUG-12186 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
72981,2 | Fix positional binding values order in QSqlQuery | stable | qt/qtbase | Status: MERGED | +2 | 0 |
81383,4 | add auto test for QTBUG-12186 | stable | qt/qtbase | Status: ABANDONED | -1 | 0 |