In one case, cast an int to qsizetype rather than the other way round,
in order to compare them.
Change-Id: Id8dffe61f9565040f1a5ee24867956397f814a55
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Some of the else if lines exceeded 100 characters, so should have been
split; and some lines already were split. So each whole chain should
have had braces on its bodies. Instead make it a switch, as this makes
it more evident what's going on in any case. Furthermore, as each
branch did the same thing with dbType-specific strings, change to just
setting QLatin1String variables, so that the rest of the code needn't
be duplicated in each branch; it can simply be done once after the
switch, using the string's .arg() to embed fragments. In the process
break up the SQL query strings more gracefully, purge spaces just
inside C++ parentheses.
Change-Id: Ie26166e098ad74720bb6d7c4d9fe47718c33a13c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Telling us the condition tested should have been true is what
QVERIFY() does anyway, so don't go to the whole trouble of saying the
same thing - and wrapping it in in a QString() merely in order to then
qPrintable() it back out again, pointlessly converting a C-string to
unicode and back again.
At the same time, skip one other qPrintable(QString("...")) without
.arg() formatting; and change the check it's the message for to use
QL1S::arg() instead of QString::arg().
Change-Id: Ie71a79da8017916d301a38b69fc422e55a5a3649
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Expected warnings are clutter for anyone reding the output, so
suppress them when they're correct behavior.
Change-Id: Idf47ba4fab8069237067d9b20afef3041e0c2f8c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Doing the tidy-up after the last check has the problem that it gets
skipped if any check fails, as the premature return skips the tidy-up.
In the process, added the missing tidy-up to prematureExec().
Repackage the code for one tidy-up as a named lambda so that the
duplicate can share it with the scope guard. Made some existing scope
guards const, while I was about it, so that the one that isn't -
because it gets dismiss()ed - stand out.
Change-Id: I96d6834d5d7675f15018169a7093b0211db6f8a9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
No need for a virtual do-nothing destructor in a class that isn't
inherited from. Defining an empty init merely makes QTest go to the
trouble of calling it, which it could just as well skip.
Change-Id: Ifd44c473c05fdeaaa7923d2ccdd0a13c8921b6bd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
It leaves the system in a state that breaks at least one later test,
so put it last. (This was first seen when picking back to 6.2, but I
am now able to reproduce it on dev.)
Amends commit 78eac57f3d
Pick-to: 6.3
Change-Id: I918cf43cdfc27357329a175518d6f9755747bae5
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
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>
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>
The QtTest best practices documentations recommends using output
mechanisms such as qDebug() and qWarning() for diagnostic messages,
and this is also what most of our own tests do.
The QWARN() macro and corresponding internal QTest::qWarn() function
was added when QtTest was first implemented, but was likely meant as
an internal implementation detail, like its cousin QTestLog::info(),
which does not have any corresponding macro.
This theory is backed by our own QtTest self-test (tst_silent)
describing the output from QWARN() as "an internal testlib warning".
The only difference between QWARN() and qWarning(), besides the much
richer feature set of the latter, is that qWarning() will not pass
on file and line number information in release mode, but QWARN() will.
This is an acceptable loss of functionality, considering that the user
can override this behavior by defining QT_MESSAGELOGCONTEXT.
[ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning()
Pick-to: 6.2
Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This ensures correct handling of names with special characters.
Pick-to: 5.15 6.1
Fixes: QTBUG-92584
Change-Id: I95c7c54d9c7ee00b221a55f3d07ef1ec3a3bd217
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Copying is deprecated as of 14f9f00fdb.
Pick-to: 6.1
Change-Id: I235d45ff6769a29a4fdfd888c20dd9fe2fe81346
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
QSqlQuery is a broken value class. Copying one object would mean
copying database state (the result set, the cursor position, etc.)
which isn't generally available for all database drivers.
For that reason, the current implementation does not honor value
semantics -- modifying a QSqlQuery object has visible side effects
on its existing copies (!).
The correct solution is to accept that QSqlQuery is a move only
type, not a value type. Add move semantics to it, and deprecate
its copies.
(We can't just *remove* copies in Qt 6 due to SC/BC constraints).
[ChangeLog][QtSql][QSqlQuery] QSqlQuery copy operations have
been deprecated. QSqlQuery copy semantics cannot be implemented
correctly, as it's not generally possible to copy a result set
of a query when copying the corresponding QSqlQuery object. This
resulted in modifications on a QSqlQuery having visible (and
unintended) side effects on its copies. Instead, treat QSqlQuery
as a move-only type.
Fixes: QTBUG-91766
Change-Id: Iabd3aa605332a5c15c524303418bf17a21ed520b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Some ODBC drivers do not properly handle SQL_NO_DATA and therefore
decimal values returned with HighPrecision are cut off because the
decimal point is not taken into account.
Fixes: QTBUG-73286
Pick-to: 6.0 5.15 5.12
Change-Id: I905c947b4d0266a3245d5735300300ca00f77480
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This patch adds native support for SQL_REAL (float) and SQL_SMALLINT
(short). Previously those datatypes were mapped to double and integer.
[ChangeLog][QtSql] The ODBC driver now properly maps QMetaType::Float to
real sql datatype and QMetaType::Short to smallint
Fixes: QTBUG-8963
Fixes: QTBUG-57279
Change-Id: Ifec4c609734dbe6165c1ebdadb461c2aae47ba78
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Remove the qmake project files for most of Qt.
Leave the qmake project files for examples, because we still test those
in the CI to ensure qmake does not regress.
Also leave the qmake project files for utils and other minor parts that
lack CMake project files.
Task-number: QTBUG-88742
Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Complete search and replace of QtTest and QtTest/QtTest with QTest, as
QtTest includes the whole module. Replace all such instances with
correct header includes. See Jira task for more discussion.
Fixes: QTBUG-88831
Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This time based on grepping to also include documentation, tests and
examples previously missed by the automatic tool.
Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Modify special case locations to use the new API as well.
Clean up some stale .prev files that are not needed anymore.
Clean up some project files that are not used anymore.
Task-number: QTBUG-86815
Change-Id: I9947da921f98686023c6bb053dfcc101851276b5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Since an EXECUTE BLOCK statement can have a mix of ? and :var syntax
then a special case for this needs to be added so that it does not try
to convert the :var parts into positional placeholders as they need to
kept as-is when preparing such a statement.
Pick-to: 5.15
Fixes: QTBUG-83152
Change-Id: Iff891207ad6dea1681a1b3a335acbbbb668b465d
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This is added to Interbase in v7 and Firebird in v3 which has been
available for sometime now. This means the minimum supported for
Interbase is now v7.
[ChangeLog][QtSQL][Interbase] The minimum required version for Interbase
is now v7.
Fixes: QTBUG-83401
Change-Id: I9927fd962f25c935be8ed5d2b7c76c00fb88cd8c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Remove around 1000 compiler warnings about missing overrides
in our auto tests.
This significantly reduce the compiler warning noise in our auto
tests, so that one can actually better see the real problems
inbetween.
Change-Id: Id0c04dba43fcaf55d8cd2b5c6697358857c31bf9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The fix ensures that it can find the column for the array correctly
when reading/writing and also handles the integer typed arrays correctly
too.
Pick-to: 5.15
Fixes: QTBUG-83409
Change-Id: I92d982bdf0927e6ebc6dce84fec9ad6c44c26c25
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
When you bind more values than the query has placeholders,
indexes will be empty which causes an out-of-bounds access in indexes.first.
We can't check the parameter count because of multiple placeholders with the same name,
so we check if the name is null.
Tested with SQLite and PostgreSQL
Pick-to: 5.15
Change-Id: Id5d4bd15d7ed16603f47b87d6e0bf811a20157d8
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Add metaType()/setMetaType() methods to be used instead
of the type() methods taking a QVariant::Type.
Change-Id: Ieaba35b73f8061cd83288dd6b50d58322db3c7ed
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
isNull() would forward to the contained type and check that type's
isNull() method for some of the builtin types. Remove that behavior
and only return true in isNull(), if the variant is invalid, doesn't
contain data or contains a null pointer.
In addition, implement more consistent behavior when constructing
a QVariant using the internal API taking a copy from a void *.
isNull() should return true in both cases. This mainly changes behavior
for some corner cases and when using our internal API.
[ChangeLog][Important Behavior Changes] QVariant::isNull()
no longer returns true when the variant contains an object of some
type with an isNull() method, that returns true for the object;
QVariant::isNull() now only returns true when the variant contains
no object or a null pointer.
Change-Id: I3125041c4f8f8618a04aa375aa0a56b19c02dcf5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
And generate a few more test projects that were missing.
Change-Id: I5df51106549aa5ae09bc3c42360e14b143719547
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Use pro2cmake with '--api-version 2' to force regenerate
projects to use the new prefixed qt_foo APIs.
Change-Id: I055c4837860319e93aaa6b09d646dda4fc2a4069
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This is required to remove the ; from the macro with Qt 6.
Task-number: QTBUG-82978
Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Becaues the database objects were created as globals, there was a
possible use-after-free issue when deleting the objects on application
exit.
Move the initialization of the database objects into static variables
inside the test constructor.
As a drive-by, also add one missing test to the CMake projects.
Fixes: QTBUG-85357
Change-Id: I2c8f2c5daee96bb9d1d21dae37950a2da5ffdf27
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
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>
qDecodeMYSQLType() did not handle FIELD_TYPE_GEOMETRY and therefore the
type for a POINT column was incorrectly treated as QVariant::String.
Even the type can not (yet) be properly decoded to a QPoint, treating it
as QVariant::ByteArray is the better option here.
Fixes: QTBUG-72140
Change-Id: I12e75b326ae3acb75cb36f2e650464528bd43c0e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Remove the compat SQL plugin names (QMYSQL3, QOCI8, QODBC3, QPSQL7)
since they are not needed and just confuse the user
[ChangeLog][QtSql] The compat plugin names QMYSQL3, QOCI8, QODBC3 and
QPSQL7 are no longer available.
Change-Id: I6d88f449ef3e18881a6970fb374ba0ab074ef302
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Fix some tests in tst_QSqlQuery:
- make sure to use QSql::HighPrecision in tst_QSqlQuery::precision()
(needed for psql)
- remove outdated stuff for mysql 3.x
- psql_bindWithDoubleColonCastOperator: the placeholder are stored as
named placeholders in psql
- avoid some useless old-style casts
Change-Id: I54d29a7e24f17d853cce6baa09a67d9278098810
Reviewed-by: Robert Szefner <robertsz27@interia.pl>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>