diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-06-11 10:49:50 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-06-22 06:54:16 +0200 |
commit | 8ba9d2e0220777bc1a2322eeece7fa9a5c55a96d (patch) | |
tree | 9231f5edac1f2a23c9a4b3537ab2d6e22cf5421b /src/sql/doc/snippets/sqldatabase/sqldatabase.cpp | |
parent | 590ac717a2c073292027111d5c99d68fb17b160c (diff) |
Change boundValues() to return a QVariantList
This enables the order of boundValues to be consistent as with a QMap
it could have been reordered which can be a problem for positional
bindings.
[ChangeLog][QtSQL] Changed signature of QSqlQuery::boundValues() to
return a QVariantList
Fixes: QTBUG-51609
Change-Id: I1c80fa8522fa7352723420b6fc9ec466406315fb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/sql/doc/snippets/sqldatabase/sqldatabase.cpp')
-rw-r--r-- | src/sql/doc/snippets/sqldatabase/sqldatabase.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp index c28e750b16..001e2ba3b2 100644 --- a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp +++ b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp @@ -50,7 +50,6 @@ #include <QCoreApplication> #include <QtSql> -#include <QMap> #include <iostream> using namespace std; @@ -202,23 +201,12 @@ void QSqlQuery_snippets() QSqlQuery query; { - // examine with named binding + // examine with named or positional binding //! [14] - QMap<QString, QVariant> sqlIterator(query.boundValues()); - for (auto i = sqlIterator.begin(); i != sqlIterator.end(); ++i) { - cout << i.key().toUtf8().data() << ": " - << i.value().toString().toUtf8().data() << "\n"; - } -//! [14] - } - - { - // examine with positional binding -//! [15] - QList<QVariant> list = query.boundValues().values(); + QVariantList list = query.boundValues(); for (int i = 0; i < list.size(); ++i) cout << i << ": " << list.at(i).toString().toUtf8().data() << "\n"; -//! [15] +//! [14] } } |