summaryrefslogtreecommitdiffstats
path: root/src/sql/kernel/qsqlresult.h
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-04-07 11:58:38 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-06-21 00:30:41 +0200
commit3f72b0d5fc70d3cf7daa4badccd5a40fc8b0726a (patch)
tree4d2a0d0c6874c4014f04940ab7470c402236d3f9 /src/sql/kernel/qsqlresult.h
parent054a64ce67421b213df73a9bcfda3fa6e9c6e64f (diff)
QSqlResult: remove bad API returning non-const reference
QSqlResult::boundValues is a const member function, but returned a non- const reference to a QList<QVariant>. This is a bad and potentially dangerous API, as callers can modify the list stored in QSqlResult. Move that API into the removed_api translation unit, remove it from Qt 6.6 on and replace it with two suitable overloads where the const version returns a QVariantList by value, and the non-const overload returns a mutable reference. Driver implementations that used to call the const overload to get a mutable reference are now calling the non-const overload instead (those calls are all made in the non-const exec() or equivalent driver implementations). As a drive-by, replace "vector" with "list" in the documentation. Pick-to: 6.6 Change-Id: I6e4fd8f5749b939cdb609bf5876735e9b30b2b5a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/sql/kernel/qsqlresult.h')
-rw-r--r--src/sql/kernel/qsqlresult.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/sql/kernel/qsqlresult.h b/src/sql/kernel/qsqlresult.h
index c16564a516..1135caf765 100644
--- a/src/sql/kernel/qsqlresult.h
+++ b/src/sql/kernel/qsqlresult.h
@@ -69,8 +69,12 @@ protected:
QSql::ParamType bindValueType(const QString& placeholder) const;
QSql::ParamType bindValueType(int pos) const;
int boundValueCount() const;
- // ### Qt 7 - don't return a non-const reference from a const function
+#if QT_SQL_REMOVED_SINCE(6, 6)
QList<QVariant> &boundValues() const;
+#endif
+ QVariantList &boundValues(QT6_DECL_NEW_OVERLOAD);
+ QVariantList boundValues(QT6_DECL_NEW_OVERLOAD) const;
+
QString executedQuery() const;
QStringList boundValueNames() const;
QString boundValueName(int pos) const;