Commit Graph

4 Commits (5ea248155654b58fcb52ef326dc4d94de83d0409)

Author SHA1 Message Date
Volker Hilsheimer 3f72b0d5fc 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>
2023-06-21 00:30:41 +02:00
Ivan Solovev c4fabe37b9 Remove QSqlTableModel::setQuery(const QSqlQuery &)
... and simply use the public methods of the base class instead.

We can't completely remove it, so we just add it to removed_api.cpp

By removing the setQuery() method in the QSqlTableModel class, we
open up name lookup to the base class, where the const ref overload
was already deprecated in 14f9f00fdb,
and the proper replacements were provided.

[ChangeLog][QtSql][QSqlTableModel] The setQuery(const QSqlQuery &)
method is removed, because QSqlQuery cannot be copied correctly.
Use the public setQuery() overloads of the base QSqlQueryModel class
instead. They allow passing of QSqlQuery by rvalue ref, or creation
of the query by specifying query string and database object.

Task-number: QTBUG-105048
Change-Id: I6f47067af6b4769578d4de9dbdbbbc7504ddf4ad
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-08-10 22:38:24 +02:00
Ivan Solovev 2ca3044083 Make QSqlQueryModel::query() return a reference to the const QSqlQuery
Returning QSqlQuery instance by value does not make much sense,
because it cannot be copied correctly. Also, its copy constructor
and copy-assignment operators are deprecated from Qt 6.2.

[ChangeLog][Potentially Source-Incompatible Changes][QSqlQueryModel]
QSqlQueryModel::query() now returns a reference to the const QSqlQuery
object associated with the model.

Task-number: QTBUG-105048
Change-Id: I04a2aa377b17d770d2a9855040f8c730190484d8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-08-10 22:38:24 +02:00
Ivan Solovev 62859ccaa6 QtSql: establish removed_api.cpp for upcoming QT_SQL_REMOVED_SINCE
Pick-to: 6.4
Change-Id: I6614ed13deee733e0cc53b3d8bb6514b2c000a9b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-08-10 22:38:24 +02:00