Commit Graph

331 Commits (4be72074a9e1dfe1e328aa97cff647cf431fb222)

Author SHA1 Message Date
Christian Ehrlicher f9d6c8b14c QSqlDriver/doc: Add a note about features depending on the db server
Some features are server-dependent and therefore an open db connection
is needed to make sure that the feature is available.

Pick-to: 6.7 6.5
Fixes: QTBUG-10016
Change-Id: Ia9a117a64ba5fe7cdd69bf95a41cfc301ab5fd94
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 139b8779469244dd1aa226dd3222e6e4aeb2c932)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-22 21:00:12 +00:00
Christian Ehrlicher 371113810e SQL/QSqlField: move deprecated functions decls to correct place
Don't move them around during deprecation.

Change-Id: I647fec5a440ea063463dc285def5d793726a9e61
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 70475a652a9a44651c25126f6615770e8b43ca1b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-13 14:18:27 +00:00
Christian Ehrlicher b34fa2f61f SQL: Code cleanup - move Q_PROPERTY to the correct place
... which is directly after Q_OBJECT/Q_GADGET

Change-Id: I3fb2b2e810a68e0ae811e55b286bc5f40364295f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 031eabe845c41ef98cb078d0fae0521156a75b9e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-13 06:26:15 +00:00
Christian Ehrlicher c8d8cfa333 SQL/Doc: add note about QAnyStringView
Add a note to all functions now taking a QAnyStringView that their
signature changed from QString to QAnyStringView

Change-Id: Ib9743b5b2c437724c6308e74ef3c5820136a34f5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit a736a3c670929e3b73e11b33cc1705957c42961b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-13 06:26:15 +00:00
Christian Ehrlicher 4735382122 QSqlRecord/QSqlQuery: Use QAnyStringView instead QStringView
Change all functions taking a QStringView to take a QAnyStringView and
remove all functions taking a const QStringRef since this can now be
fully handled by the QAnyStringView ones.

This amends f2dba19194 and
993f318014

[ChangeLog][QtSql][QSqlRecord] All functions taking a QString were
changed to take a QAnyStringView.

Change-Id: Ia1c968c4e2a7a93aa26d090ef6605271305c14a6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6b096271cf0aac38d80f292f8b37edd671a8d17f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-05 04:17:33 +00:00
Christian Ehrlicher 102670a82e SQL/QSqlRecord: rework QRecord::indexOf(QStringView)
Move it to the private implementation to be later used as a template
when switching to QAnyStringView.

Change-Id: If9977711757677546cfc058602ada9f54b978509
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-31 19:30:53 +02:00
Christian Ehrlicher 5a7c2cbabb QSqlDatabase: Rename currentThread() to thread()
... to be in sync with QObject naming.
This amends b4c63b89df.

Change-Id: I25301f65aa880205d8c0cfd6f4bfa9fdba34a01c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-05-31 19:30:53 +02:00
Jesus Fernandez 7c128f8866 Add -Wweak-vtables to headersclean
This requires some fixes in several classes that are also included
in this patch.

The QTestEvent hierarchy is all-inline and changes layout depending on
QT_GUI_LIB and QT_WIDGETS_LIB, so we can't just export it. Suppress the
warning in that header for now. Created QTBUG-104486 to track a fix for
the real issue.

The QFutureInterface hierarchy is also all-inline, but templates, so
doesn't trigger, except the <void> specialization. Created
QTBUG-125115 to track a fix for the real issue.

Done-with: Marc Mutz <marc.mutz@qt.io>
Task-number: QTBUG-45582
Change-Id: I96b3e109aa989b70e0d4809b90bd53a369e50d55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-05-19 15:56:17 +00:00
Christian Ehrlicher 5a7d41667d SQL/QSqlIndex: remove unused private function createField()
This function was forgotten when the Qt3 support was removed during
initial Qt5 porting (f306d18fe6).

Pick-to: 6.7
Change-Id: I83a0be0db7e81bd9d4f84683a013e1d4faab2dd8
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2024-04-26 16:37:55 +01:00
Christian Ehrlicher b4c63b89df QSqlDatabase: add moveToThread()/currentThread()
Add QSqlDatabase::moveToThread() to be able to move the driver instance
to another thread.

[ChangeLog][Sql][QSqLDatabase] QSqlDatabase gained two new functions
moveToThread() and currentThread() to be able to use it in another
thread than the one it was created in.

Fixes: QTBUG-39957
Change-Id: I9cb51358f73a3a2fa72813bfdbe059279d388bd7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-04-25 08:27:21 +02:00
Vladimir Belyavsky b8d92d2ef8 SQL: avoid potential detach in QtSqlGlobals dtor
Wrap `connections` to std::as_const() to avoid unexpected detach
due to use of QHash::asKeyValueRange() in range-based for loop.

Change-Id: I2bf69782dc9dc63df0b3f9dfe395427909fba310
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-04-21 15:09:52 +00:00
Christian Ehrlicher 2cd0bc729e SQL/QSqlDatabase: use categorized logger
Use the categorized logger qt.sql.qsqldatabase

Change-Id: I25216d0809ff0316371a62913b56e1f56ab37ab4
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-18 20:11:14 +02:00
Christian Ehrlicher 6bc454b247 SQL/QSqlQuery: use categorized logger
Use the categorized logger qt.sql.qsqlquery

Change-Id: Ib5c26751ef013261080207fc13b80b91c644a640
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-18 20:11:14 +02:00
Zhao Yuhang 90217f37ca QSqlField: fix missing deprecation macro
Change-Id: Ia544da629d495abdfdd0efe0e0991124a9f5d7ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-04-04 12:21:12 +00:00
Christian Ehrlicher e65dc19332 SQL/QSqlField: deprecate internal functions setSqlType()/typeID()
These functions set/get the db-specific internal sql type but it's not
used in any of the sql plugins since ages. Any external plugin using this for some reason must be ported away until Qt7.

Change-Id: Ifb33e9d3be0b80fb4d0979d31436e89ea6a8208b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-10 18:16:00 +00:00
Christian Ehrlicher e2e818483f SQL/MySQL: retrieve default column value for QSqlDatabase::record()
Retrieve the default value (if set) of a column during
QSqlDatabase::record() but not for QSqlQuery::record() as it's done for
the other drivers which support retrieving the default column value.

Fixes: QTBUG-122723
Change-Id: I92e052bfa6d88e019c0151fbcbc1483a65770c55
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-10 19:15:47 +01:00
Paul Wicking 99b9eb7177 Doc: Fix QDoc warnings for overloads
Change-Id: I9a77b6ea0026748c7f97f73b327118f7a9212d52
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2024-02-14 21:47:28 +01:00
Thiago Macieira f3832b63de QtSql: #include mocs
Pick-to: 6.7
Change-Id: I50e2158aeade4256ad1dfffd17b1f286a9001ae8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-02-10 02:39:14 -08:00
Christian Ehrlicher 74722411d3 QSqlQuery: remove unneeded friend tst_QSqlQuery
... as it is no longer needed.

Pick-to: 6.7
Change-Id: Ia60b6e53675260ef0e793ac1b44c913af1454b35
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-09 17:12:23 +01:00
Christian Ehrlicher 781135b0d2 QSqlDatabase: add Q_PROPERTY
Add Q_PROPERTY to follow the current Qt style and simplify the
documentation.

Task-number: QTBUG-120566
Change-Id: I23103a921cd391f24ce0ffd915a4ae2f98686d21
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-02-05 21:52:33 +01:00
Christian Ehrlicher 212e88889a QSqlQuery: add Q_PROPERTY
Add Q_PROPERTY to follow the current Qt style and simplify the
documentation.

Task-number: QTBUG-120566
Change-Id: I3803f5246c1814d627a16fa2569d1342b54f6adf
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-01-24 21:35:09 +01:00
Christian Ehrlicher 294da15696 QSqlIndex: add Q_PROPERTY
Add Q_PROPERTY to follow the current Qt style and simplify the
documentation.

Task-number: QTBUG-120566
Change-Id: Iaf844eb6f60427dab7fba6ac20b16ffa11f217b8
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-01-24 20:35:09 +00:00
Christian Ehrlicher c10530fd97 SQL: remove outdated \since tags
There is no need to know if a function was added in Qt4 or earlier so
remove all \since 4.x tags.
Amends 747581e0bf

Change-Id: I470bc785b1e31685caec561dafaec0ba97208d99
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2024-01-24 21:35:09 +01:00
Christian Ehrlicher 747581e0bf SQL: remove outdated \since tags
There is no need to know if a function was added in Qt4 or earlier so
remove all \since 4.x tags

Change-Id: I5cf4e89a3e30c13fac076f1ae7abb33a625e366c
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-01-21 10:12:31 +01:00
Christian Ehrlicher 6dfc988ea0 QSqlDriver: add Q_PROPERTY
Add Q_PROPERTY to follow the current Qt style and simplify the
documentation.

Task-number: QTBUG-120566
Change-Id: Ibbafde35bb5600453ed3a3de36b6bf2b5c560e5f
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-01-19 17:29:09 +01:00
Christian Ehrlicher 9806f54a58 QSqlField: add Q_PROPERTY
Add Q_PROPERTY to follow the current Qt style and simplify the
documentation.

Task-number: QTBUG-120566
Change-Id: I593ba9f322273991661c1d14fb51dcb23678ea0f
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-01-19 17:29:06 +01:00
Christian Ehrlicher b1e5d9275d SQL: rename enablePositionalBinding() to setPositionalBindingEnabled()
... and the getter to isPositionalBindingEnabled() for QSqlQuery and
QSqlResult.
This amends e532933a2a

[ChangeLog][QtSql][QSqlQuery] Add setPositionalBindingEnabled() to be
able to disable positional binding.

Pick-to: 6.7
Task-number: QTBUG-119952
Fixes: QTBUG-120548
Change-Id: I0a0afb652d0fc9421f5692b0927a66b2a9b7b854
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2024-01-10 04:32:49 +01:00
Christian Ehrlicher f2dba19194 QSqlQuery: Add QStringView overloads
Add an overload to QSqlQuery::isNull()/::value() taking a QStringView -
those two functions can now use the newly introduced
QSqlRecord::indexOf(QStringView)

[ChangeLog][QtSql][QSqlRecord] QSqlQuery::isNull() and value() gained a
new overload taking a QStringView.

Change-Id: Icebce88b94a7413130bdd7ec0098f51726d05892
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2024-01-10 04:11:52 +01:00
Christian Ehrlicher 993f318014 QSqlRecord: Add QStringView overloads
Add overloads to all functions taking a QString and internally using
QSqlRecord::indexOf() - no need to create a full-blown QString here.

[ChangeLog][QtSql][QSqlRecord] All functions taking a QString got an
overload taking a QStringView.

Change-Id: Ieb7ffcf572b5450ac81cb7d6108010052dc877ee
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2024-01-10 04:11:51 +01:00
Christian Ehrlicher ddad911f9b QSqlRecord: style fixes
Misc style fixes in preparation for the new overloads taking
QStringView.

Pick-to: 6.7 6.6 6.5
Change-Id: I3b838543aefd08bf115488e571b1bb6eec8d968d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-12-28 08:14:56 +01:00
Christian Ehrlicher d70b873c37 QSqlDatabase: check if QCoreApplication::instance() exists
Check if QCoreApplication::instance() and print a warning if not instead
creating and assertion later on.

Fixes: QTBUG-117621
Change-Id: Iffb4f7097edbbaf19cb584bff6e5ba1535bf88a0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-12 06:16:46 +02:00
Ivan Solovev 5a1a80861f Add QSqlField::swap() documentation
Fixes: QTBUG-116937
Pick-to: 6.6
Change-Id: Ic5f08c3a7d0f2c0c926ced0d194fd5a2aea191fd
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-12 02:35:03 +02:00
Paul Wicking 8f448d7ac7 Doc: Add missing since to enum value
Task-number: QTBUG-116848
Pick-to: 6.6
Change-Id: Ia137a21de5bab406a133ee032b6ccf3089de8d22
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Fredrik Ålund <fredrik.alund@mimer.com>
2023-09-11 17:50:15 +02:00
Ivan Solovev f081578ce0 QSqlIndex: implement member swap() and use a macro for move-assignment
Also declare the type as shared using Q_DECLARE_SHARED

Found during Qt 6.6 API review.

This commit amends 46e909a37a.

[ChangeLog][QtSql] QSqlIndex is now a relocatable type.

Pick-to: 6.6
Change-Id: I78394cba082b4df2e4d8a6aab8e8e87f2340962c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-08-23 14:21:57 +00:00
Ivan Solovev 2f87711913 SQL: add missing Q_DECLARE_SHARED to the value types
QSqlField and QSqlRecord implemented all special member functions and
the member swap() function, but were missing the Q_DECLARE_SHARED
macro.

Found during Qt 6.6 API review

[ChangeLog][QtSql] QSqlField and QSqlRecord are now relocatable
types.

Pick-to: 6.6
Change-Id: Ia10f1d3fd9f634864be5b36d1d3903301adfa9ab
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-08-23 16:21:57 +02:00
Kai Köhne 3883b0a7b6 Doc: Fix warning about undocumented parameter
Fixes
 (qdoc) warning: Undocumented parameter 'enable' in QSqlQuery::enablePositionalBinding()

Amends the documentation introduced in e532933a2a

Change-Id: I638cf7e1dc1c9af911f6ca52bc27e6072fae1035
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-08-08 09:12:16 +02:00
Christian Ehrlicher 3d284d9b8d SQLDatabase: merge two global statics into one
Merge the two global statics into one.

Change-Id: I8a93ba848abe31527551313c8a4a449d05e3d680
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2023-07-23 16:49:16 +02:00
Christian Ehrlicher e532933a2a SQL/PSQL: Handle jsonb operators in prepared queries
Add an option to disable handling of positional binding so jsonb
operators are not screwed up

[ChangeLog][QtSql][QSqlQuery] Add setEnablePositionalBinding() to be
able to disable positional binding.

Fixes: QTBUG-96636
Change-Id: I428a9d3b10274b97292ab86a74d9b3971d6f10e9
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2023-07-23 16:49:15 +02:00
Alexey Edelev 1e3bf10786 Do not generate the deprecated 'QtSql/qsql.h'
Task-number: QTBUG-115029
Change-Id: I1fe496864ce25f20421ca78fbde3fe4eb4b9fc49
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2023-07-19 13:51:36 +02:00
Christian Ehrlicher 7a732413ff QtSql: Stylistic fixes based on the Qt 6.6 api review
Amends 12909d7c3d and 0efd8854c4.

Pick-to: 6.6
Change-Id: Id7cb7377bcd1f32092330d2fc5b2fa5b83ce941f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-08 18:34:10 +00:00
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
Christian Ehrlicher 048a68c1e9 SQL: Make QSqlDatabase::DriverDict creation thread-safe
Make the QSqlDatabase::DriverDict thread-safe and make sure it's
properly cleaned up on destruction.

Pick-to: 6.5 6.2 5.15
Fixes: QTBUG-112961
Change-Id: I1ff70e477579231754ef829fdede944d6042894d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-24 17:27:55 +02:00
Christian Ehrlicher 67b8dec0d0 QSqlDatabase: use a QReadWriteLock to access DriverDict
DriverDict might be accessed from different threads so we have to make
sure it's thread-safe. Use the already existing QReadWriteLock from
QConnectionDict for later merging of these two global instances. The two
instances do not interfere each other (DriverDict is a dictionary for
custom registered sql drivers, QConnectionDict contains all current
active database connections) so the dual-use of the mutex is fine.

Pick-to: 6.5 6.2 5.15
Change-Id: I84c77df666e72e826d0d3d291cecd5417bbd1baf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-23 06:20:09 +02:00
Christian Ehrlicher 1f27dc6871 QSqlField: add move ctor & move operator
Add the move ctor and move operator for QSqlField

Task-number: QTBUG-109938
Change-Id: Ib66eff76c3a920de9cfb3288f4219555005e7ae5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-04-26 19:56:07 +00:00
Christian Ehrlicher 204f1764ca QSqlRecord: use QSharedData for private class
Use QSharedData for the private class instead a home-brew version.

Change-Id: Id3625bb0eb8f81c9caa672e2453dab3d44b15ea9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-04-26 19:56:07 +00:00
Christian Ehrlicher d71dc36f47 QSQLDatabase: avoid some code duplication
Avoid some code duplication and enhance the documentation about
thread-safeness of QSQLDatabase::cloneDatabase()

Fixes: QTBUG-60505
Change-Id: I6ca6b9f47d818d49ca51395da14051e40317cef6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-14 19:25:55 +02:00
Christian Ehrlicher d7607a463d QSqlError: Make QSqlErrorPrivate implicitly shared
Make QSqlError implicitly shared and adjust the ctors / assignment
operators to be consistent with other implicitly shared Qt classes.

Fixes: QTBUG-91912
Change-Id: Ie73292817fd4e7b274a3033a74d62e712a01c2b0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-04-12 21:00:11 +02:00
Christian Ehrlicher 3983babd71 QSqlQuery: add boundValueName()/boundValueNames()
[ChangeLog][SQL][SqlQuery] Added two new functions
boundValueName()/boundValueNames() to return the names of the bound
values.

Fixes: QTBUG-97847
Change-Id: I8df5f15e8df13141a34d38b0a2e13b37f4e7829c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-07 14:25:28 +02:00
Christian Ehrlicher 2f709952cf QSqlError: also compare nativeErrorCode() in operator==() / operator!=()
A QSqlError is not equal when the native error code differs. The
database and driver text should not be considered during the
comparison because they might differ due to e.g. different locales.

[ChangeLog][QtSql][QSqlError] The comparison operators have been fixed to
take both error type and error code into account.

Change-Id: Ie7511f183f88dd454eb165c6ff237e51b79d1c08
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-03 15:52:03 +00:00
Christian Ehrlicher b5fe88a6e5 QSqlError: misc cleanup
- fix formatting for qsqlerror.cpp/.h
- replace a size() == 1 "x"_L1 with u'x'

Pick-to: 6.5
Change-Id: I74c92f27be4345737fcfc73368f834a2f7920808
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-04-01 11:31:43 +00:00