summaryrefslogtreecommitdiffstats
path: root/src/sql
Commit message (Collapse)AuthorAgeFilesLines
...
* SQL/MySQL: add option MYSQL_OPT_TLS_VERSION & MYSQL_OPT_SSL_MODEChristian Ehrlicher2023-04-061-0/+10
| | | | | | | | | | | | | | Add the two options MYSQL_OPT_TLS_VERSION and MYSQL_OPT_SSL_MODE to properly support encrypted connections to MySQL 8.0 servers. MYSQL_OPT_SSL_MODE will not work when compiled against the MariaDB C-Connector since it's not supported by the MariaDB client. [ChangeLog][QtSql][MySQL] Added the two new connect options MYSQL_OPT_TLS_VERSION and MYSQL_OPT_SSL_MODE. Fixes: QTBUG-84797 Change-Id: Iec7d682fc00072ce5b2a824c4ea00fca4575a93e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QSqlError: also compare nativeErrorCode() in operator==() / operator!=()Christian Ehrlicher2023-04-031-4/+8
| | | | | | | | | | | | 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>
* Use Qt CMake APIs to exclude files from Unity BuildAmir Masoud Abdol2023-04-031-3/+0
| | | | | | | | | | | | | | | | | | | | This is a bit of a cleanup, mainly around unity build, and a few other minor things: - I replaced the direct inclusion of sources files using `set_source_files_properties`, and instead used `NO_UNITY_BUILD_SOURCES` when possible. In most cases, they are being excluded in their respective `qt_internal_extend_target` but sometimes I had to make a new extension. - In few cases, we had to manually exclude the NO_PCH files, so, I instead passed them directly to the NO_PCH_SOURCES which also exclude them from the unity build as well. - Removed a few unnecessary "" Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I466576592c1d115a2da4d88672c1e4b9f995f2ed Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QSqlError: misc cleanupChristian Ehrlicher2023-04-012-10/+10
| | | | | | | | | - 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>
* QSqlIndex: add move ctor & move operatorChristian Ehrlicher2023-03-312-0/+24
| | | | | | | | | Add the move ctor and move operator for QSqlIndex, also add an explicit testcase for QSqlIndex Task-number: QTBUG-109938 Change-Id: I46cc6a24c2e7d5b23d2ac3427cafd01b9ba257ed Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* SQL/SQLDatabase: do not copy q within QSqlDatabasePrivate::copy()Christian Ehrlicher2023-03-161-9/+5
| | | | | | | | | | Copying the QSqlDatabase pointer inside QSqlDatabasePrivate::copy() is not a good idea since it must point to the owning instance and not another one. Since it's not used anywhere we can safely remove it. Change-Id: Ie45b594305059afd9b8d8b25d4864dd77769acf7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* SQL: add QIBASE to tocChristian Ehrlicher2023-03-121-0/+1
| | | | | | | | | Add QIBASE in the toc for the supported sql drivers - was removed by accident. Pick-to: 6.5 6.2 Change-Id: I70a295e59939317e6b99bb2bd4aad39b0b813509 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* SQL/ODBC: Return all native error codesChristian Ehrlicher2023-03-071-3/+3
| | | | | | | | | | | | | | ODBC can (similar to DB2) return more than one native error code for an error but only the last one was recorded which may made the error diagnostic more complicated. Therefore return a concatenated list of native error codes the way it's done for DB2. [ChangeLog][SQL][ODBC] QSqlError::errorCode() might return a semicolon separated list of native error codes. Fixes: QTBUG-45087 Change-Id: I70d02adeb33e72897f13e0c72fbbd2c60f307e2f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QSqlDatabase: deprecate QSqlDatabase::exec()Christian Ehrlicher2023-03-062-4/+6
| | | | | | | | The note that QSqlDatabase::exec() is deprecated was added more than 12 years ago so it's time to also mark the function as such. Change-Id: Ic5e7c31b3ff5b21e16e2640548cba1a4baaeeb1c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Remove duplicate wordsAndreas Eliasson2023-02-281-1/+1
| | | | | | Change-Id: Ia7a38a1035bd34d00f20351a0adc3927e473b2e7 Pick-to: 6.5 6.4 6.2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* A QtSql driver for Mimer SQLFredrik Ålund2023-02-207-2/+179
| | | | | | | | | | | | | | | | | The QtSql for Mimer SQL sqldriver makes it possible to work with the Mimer SQL database on different plattforms. There are drivers for several other databases in QtSql and a driver for Mimer SQL will benefit many users. To build the Mimer SQL driver, download Mimer SQL from https://developer.mimer.com [ChangeLog][QtSql] Added a QtSql plugin to work with the Mimer SQL database Fixes: QTBUG-111219 Change-Id: Id6ba5de4de01189d0516ffbfa89efcb0d013115f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add some exclusions for CMake Unity (Jumbo) buildsFriedemann Kleint2023-02-161-0/+3
| | | | | | | | | | | | | Add exclusions for issues that are likely not fixable (3rd party code, X11 define clashes, etc) in 3rd party, tools and plugins. Pick-to: 6.5 Task-number: QTBUG-109394 Done-with: Amir Masoud Abdol <amir.abdol@qt.io> Change-Id: I698c004201a76a48389271c130e44fba20f5adf7 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* SQL/MySQL: add options to explicitly specify the protocol typeChristian Ehrlicher2023-02-121-1/+12
| | | | | | | | | | | | [ChangeLog][QtSql] Added the ability to specify the MySQL/MariaDB connection type using the "MYSQL_OPT_PROTOCOL" connection string option. In case the connection type is "MEMORY" for shared memory, applications can specify the shared memory segment name using the "MYSQL_SHARED_MEMORY_BASE_NAME" option. Fixes: QTBUG-2551 Change-Id: I91e0981994c045fb74478d0e765e2ec24eefeece Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* src: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-101-5/+0
| | | | | | Pick-to: 6.5 Change-Id: Id644d322a602038403bb7f46c532744575fbf6d3 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Doc: Fix usages of deleted QVariant constructorsSze Howe Koh2023-01-253-4/+4
| | | | | | | | Finish the job started at 879d30394a41b7b7124fc8139e787a9bdbe0dfee Pick-to: 6.5 6.4 6.2 Change-Id: I217a4830ac8e17d5d1f8900e2d3134fbabf8b9a2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* SQL: use qsizetype and range-based for loops where possibleChristian Ehrlicher2023-01-207-53/+48
| | | | | | | | Some public functions are still using int instead qsizetype which can't be changed until Qt7. Change-Id: Ib6f210c344acce9f3836e8a5493a741eb8b2b385 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* SQL: include cleanupChristian Ehrlicher2023-01-187-12/+4
| | | | | | | | Removed some unused includes in the sql sources Change-Id: Ifbe1df401e0f4042650f8ce9902cb9977d2aa484 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QSqlRecord: add missing C++11 move SMFsMarc Mutz2023-01-132-2/+38
| | | | | | | | | | [ChangeLog][QtSql][QSqlRecord] Added move constructor, -assignment operator, and swap(). Task-number: QTBUG-109938 Change-Id: I54f2666defbf56f5ba2faea6358722ebd7cac157 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QtSql: Disambiguate typedefsFriedemann Kleint2023-01-122-26/+26
| | | | | | | | | They cause clashes in CMake Unity (Jumbo) builds. Task-number: QTBUG-109394 Pick-to: 6.5 6.4 6.2 Change-Id: I3f94044671cdbd0a1bb0964bf291e36508223b50 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* SQL: more documentation and test cleanupsChristian Ehrlicher2023-01-063-77/+20
| | | | | | | | Remove some stuff no longer supported and refine others. Pick-to: 6.5 Change-Id: I29730d5acfcf4a7ef3f569f101d3a4f72dd8b3aa Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* SQL: rework the connection options documentation (typos)Christian Ehrlicher2022-12-291-15/+17
| | | | | | | | Fix some typos found after the initial commit for the connect options documentation update Change-Id: I9cf201363117a2f05e611c26a058f035fa945ddb Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* QSqlDatabase: remove a pointless const_castGiuseppe D'Angelo2022-12-231-1/+1
| | | | | | | | | | | | The history of that one line of code is... interesting, to say the least. `defaultConnection` was originally declared as `char *`, which happened to work on older MSVC versions. Then it gained a workaround for other platforms by conditionally marking it const, with a const_cast to keep the code working on MSVC. Now it is unconditionally declared as a const char *, but the const_cast is still there. Get rid of it. Change-Id: Ibfb6728e05f15f540137c94f2d278bd5db988b63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Support connecting Oracle DB as system userJohannes Oikarinen2022-12-221-0/+7
| | | | | | | | Adding support to different authentication modes to Oracle DB. Adjust the connection string parsing a little bit as a drive-by. Change-Id: I24ed70ed5085f22ba58eff70caa685579d31c96f Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* SQL: rework the connection options documentationChristian Ehrlicher2022-12-222-92/+199
| | | | | | | | | Move the documentation of the connection options to the SQL Drivers page and try to add a small but useful documention to each option. Fixes: QTBUG-109507 Change-Id: Id1d51d7a666ac0f15cde8d73bff153dad271d34b Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* SQL: misc cleanup in QSqlRecord/QSqlFieldChristian Ehrlicher2022-12-222-35/+19
| | | | | | | | Cleanup an unused function in QSqlRecordPrivate and use member initializers for the ctors in QSqlRecord/QSqlField Change-Id: I7d585e70c83373b3092e9f1425233af42b8c379d Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* SQL/MySQL: add connect option MYSQL_OPT_LOCAL_INFILEChristian Ehrlicher2022-12-081-0/+1
| | | | | | | | | Add the connect option MYSQL_OPT_LOCAL_INFILE to be able to specify the client-side LOCAL capability for LOAD DATA operations Fixes: QTBUG-104916 Change-Id: I9914250059e7dc1a705941d3b409fa624e105ecd Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* SQL/MySQL: rework driver option parsingChristian Ehrlicher2022-10-221-5/+12
| | | | | | | | | | Rework the parsing of client option to make it easier to add new options. Add the two options MYSQL_OPT_SSL_CRL and MYSQL_OPT_SSL_CRLPATH and deprecate the SSL_foo options without the MYSQL_OPT_ prefix. Change-Id: Ibaf5f553d77d9c102ca2bfef2fe68be0572f594b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-046-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Introduce the qt_deprecates pragmaAlexey Edelev2022-09-061-0/+1
| | | | | | | | | | | | | | The qt_deprecates pragma indicates that the file passed as argument is deprecated and supposed to be replaced by the file where the pragma is defined. Syncqt procedure generates the file passed as argument automatically with the deprecation warning. After the deprecation period the pragma should be removed and the deprecated file will not be included to the Qt installation too. The pragma is only handled by the cpp version of syncqt cpp and supposed to replace the 'deprecatedheaders' record in sync.profiles. Change-Id: Ibe69423a5de67f58907a3edbc5961f5ab63944de Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-235-5/+5
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove QSqlTableModel::setQuery(const QSqlQuery &)Ivan Solovev2022-08-103-15/+11
| | | | | | | | | | | | | | | | | | | | | ... 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 14f9f00fdb2dc428610c08e3d9d03e38e9602166, 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>
* Make QSqlQueryModel::query() return a reference to the const QSqlQueryIvan Solovev2022-08-103-5/+17
| | | | | | | | | | | | | | | 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>
* QtSql: establish removed_api.cpp for upcoming QT_SQL_REMOVED_SINCEIvan Solovev2022-08-102-0/+27
| | | | | | | Pick-to: 6.4 Change-Id: I6614ed13deee733e0cc53b3d8bb6514b2c000a9b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QSqlQueryModel: guard the definition of deprecated methodIvan Solovev2022-08-101-1/+2
| | | | | | | | | | | | | ... to prevent compilation errors when built with QT_DISABLE_DEPRECATED_BEFORE >= 0x060200 This commit amends 14f9f00fdb2dc428610c08e3d9d03e38e9602166 Task-number: QTBUG-105048 Pick-to: 6.4 6.3 6.2 Change-Id: I33c586508353ccb4c0af3f5da0cdaf9abe9f590e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QSqlQuery: Do not use deleted constructor in docsFabian Kosmale2022-08-101-2/+2
| | | | | | | | | | QVariant(QMetaType::Type) is deleted since Qt 5 (sic!). Suggest usage of the constructor taking a meta-type instead. Pick-to: 6.2 6.3 6.4 Change-Id: I50949dac9dfc35c80108debdeabc791afe0998b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-035-0/+15
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add the qt_class pragma to file listed in sync.profile classnames mapAlexey Edelev2022-06-221-0/+4
| | | | | | | | | This makes header files self-contained and reduces the number of 'sources of truth' for syncqt procedure. Change-Id: I7f5865abc69934603139d23e1b5452da46ccb110 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-1656-2198/+112
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtSql: includemocsMarc Mutz2022-04-285-0/+10
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102886 Change-Id: Id758d672710ba998595824645e3e16e00537781d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Revise Qt SQL module landing pageAndreas Eliasson2022-04-251-14/+28
| | | | | | | | | | Include new CMake and qmake snippets and reorganize some of the sections structure. Task-number: QTBUG-100369 Pick-to: 6.3 Change-Id: I47cc9b24818c26740e49e6365bf881874942b79c Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Sql: replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-04-194-25/+27
| | | | | | Task-number: QTBUG-98434 Change-Id: Ia621f9d937649dda41a7b0d13a61e6f1397f6dde Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Sql: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-198-41/+51
| | | | | | Task-number: QTBUG-98434 Change-Id: Ie12ca82fd912617eabe4f602c08914f12878cb32 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Sql: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-198-40/+36
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I03477e645a94948cac3e3e2abca52aa4e3e2efff Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Sql: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+1
| | | | | Change-Id: I9407c34c9fb6add655649dd7058bce7a25be5f5d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rest of QtBase: compile-optimize inline swap functionsMarc Mutz2022-03-173-7/+5
| | | | | | | | | | | | | | | | Instead of using the overly-generic qSwap() monster, use - qt_ptr_swap() for swapping raw pointers - member-swap for swapping smart pointers and owning containers In QtCore, this has proven to give a nice reduction in compile time for Qt users, cf. b1b0c2970e480ef460a61f37fa430dc443390358. Pick-to: 6.3 6.2 Task-number: QTBUG-97601 Change-Id: I53e031a021031d53a74a712cd0f5e6bb8bf800bd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QSqlTableModel: suppress deprecation warningMårten Nordheim2022-03-051-1/+1
| | | | | | | | It's just a proxy-setter so we cannot really avoid the call Pick-to: 6.3 6.2 Change-Id: I4230075a906c100ddb9722160859e7a2c8e26ebc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Treat invalid Q(Date)?Time as null when used as an SQL valueEdward Welbourne2022-02-211-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 5, QVariant::isNull() was true when the contained object had an isNull() that was true; this is no longer true in Qt 6, so we now have QSqlResultPrivate::isVariantNull() to test is-or-contains null. However, for date-times, QSqlDriver::formatValue() treats invalid QDateTime as NULL, since it needs its toString(Qt::ISODate), which will be empty if invalid. As QDateTime's isValid() is more stringent than its !isNull(), this can lead to one that's neither valid nor null, such as QDateTime(QDate(), QTime(0, 0)), producing an invalid entry in a database. Do the same for QTime, as its isValid() is more stringent than !isNull(), and its toString() likewise returns empty on invalid (although it's not clear it's possible to construct one that's neither valid nor null). For QDate valid and null are simply complementary. [ChangeLog][QSql] Handling of QDateTime and QTime values passed to SQL now consistently treats invalid as null. Some values of these types are neither valid nor null, which could lead to invalid data being given to the SQL database. Invalid values are now treated as null to prevent this. Task-number: QTBUG-98471 Pick-to: 6.3 Change-Id: I145411280d6bcc53dc0dc5f4a1cb938d995fd6bc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Check for null driver() before trying to exec()Edward Welbourne2022-01-251-1/+5
| | | | | | | | | | | | QSqlQuery::exec() took for granted that it can dereference driver(), which should be true for all sane usage; however, it should not crash if used misguidedly. Added regression test, based on bug report's reproducer, which crashes without the fix. Fixes: QTBUG-100037 Pick-to: 6.3 6.2 5.15 5.12 Change-Id: I94600bc60f89e82a1121b418144006a683921a38 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Adapt SQL drivers to Qt 6 change of QVariant::isNullVolker Hilsheimer2022-01-122-2/+34
| | | | | | | | | | | | | | | | | | | | | | | | In Qt 5, QVariant::isNull returned true if either the variant didn't contain a value, or if the value was of a nullable type where the type's isNull member function returned true. In Qt 6, QVariant::isNull only returns true for variants that don't contain a value; if the value contained is e.g. a null-QString or QDateTime, then QVariant::isNull returns false. This change requires a follow up in the SQL drivers, which must still treat null-values the same as null-variants, lest they write data into the data base. Add a static helper to QSqlResultPrivate that implements isNull-checking of variants that contain a nullable type relevant for Sql, and add a test case to the QSqlQuery test that exercises that code. Pick-to: 6.2 6.3 Fixes: QTBUG-99408 Fixes: QTBUG-98471 Change-Id: I08b74a33aa3235c37d974f182da1f2bdcfd8217e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>