Commit Graph

334 Commits

Author SHA1 Message Date
Edward Welbourne
2f440169c0 Adapt to QTimeZone replacing Qt::TimeSpec usage
In the process actually handle all time-spec cases in various places
that only handled UTC or LocalTime, or at least note that they don't
where that's not practical. Also tidy up header ordering and ensure
QDateTime's header is included wherever it's used, while adding the
include for QTimeZone where needed.

Task-number: QTBUG-108199
Change-Id: Ic1a5cdf0aaf737bf1396aa8ac58ce2004cef7e19
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-10 06:39:44 +01:00
Christian Ehrlicher
9d27c07e28 SQL/MySQL: fix handling of json column
Add handling for MYSQL_TYPE_JSON by treating it the same as
MYSQL_TYPE_BLOB (which is used by current MariaDB Server for a json
column)

Pick-to: 5.15 6.2 6.4
Fixes: QTBUG-101680
Change-Id: I4d4b0cdad73cd12e0db4df4021fddbd6a649c8ed
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-05 01:56:45 +00:00
Marc Mutz
1c6bf3e09e Port from container::count() and length() to size() - V5
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>
2022-11-03 14:59:24 +01:00
Christian Ehrlicher
05ec29f76c SQL/Tests: fix tst_qsqldatabase::caseSensivity() for MySQL on linux
MySQL has a different default setting for case sensitive table names on
linux and windows which makes the test fail on linux but work on
windows when using the database with the default settings. Read out the
respecitive setting so the test will pass every time.

Change-Id: I8651858d47652022ddc4b6386a6153cf70c6fed6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-10-24 19:08:17 +00:00
Mårten Nordheim
30077d462d tst_QSql*/sqlite: Don't use random output in the datatags
It makes it impossible to rerun it, bad for both CI and local test runs.

As a drive-by name the database file sqlite.db instead of foo.db

Pick-to: 6.2 6.4
Fixes: QTBUG-100245
Change-Id: I2e4ee01189ccbad2a6add5db7771d35fd7248da8
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-10-18 16:15:50 +02:00
Christian Ehrlicher
5caf808750 SQL/tests: fix tst_qsqlquery
Fix two tests which got broken due to the latest changes without
notifying because those tests are not run automatically.

Change-Id: Ibe9d9601f0a2ad4ce8f06ca21e7503e77fa55781
Reviewed-by: Fredrik Ålund <fredrik.alund@mimer.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-10-16 06:05:34 +02:00
Marc Mutz
aa37e67ef7 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace, with manual
unstaging of the actual definition and documentation in dist/,
src/corelib/doc/ and src/corelib/global/.

Task-number: QTBUG-99313
Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-11 23:17:18 +02:00
Marc Mutz
df9d882d41 Port from container.count()/length() to size()
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>
2022-10-04 07:40:08 +02:00
Ivan Solovev
2e69ef6af9 Rest of QtBase tests: port away from deprecated methods
Small changes to fix builds with
QT_DISABLE_DEPRECATED_UP_TO >= 0x060500

Task-number: QTBUG-104858
Change-Id: Ia531a3cee97f13827e36b3d63f28eed879fe9a40
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-08-30 22:46:35 +02:00
Lucie Gérard
32df595275 Change the license of all CMakeLists.txt and *.cmake files to BSD
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>
2022-08-23 23:58:42 +02:00
Lucie Gérard
fb1b20eab3 Add license headers to cmake files
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>
2022-08-03 17:14:55 +02:00
Alexandru Croitor
4d22405e48 CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers
Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-28 14:46:53 +02:00
Lucie Gérard
05fc3aef53 Use SPDX license identifiers
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>
2022-05-16 16:37:38 +02:00
Sona Kurazyan
80363889fe Replace uses of _qba with _ba
Task-number: QTBUG-101408
Change-Id: I5175428c2be934b09f45bd06b0b47643003e25c7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-04-07 19:30:17 +02:00
Sona Kurazyan
a885f28933 Replace uses of _qs with _s in tests
Task-number: QTBUG-101408
Change-Id: If092a68828a1e8056259cf90d035d9a87989244b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-04-07 19:30:17 +02:00
Sona Kurazyan
6585963583 Deprecate {QString, QByteArray}::count()
And remove their uses.

[ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count()
and QByteArray::count() that take no parameters, to avoid confusion
with the algorithm overloads of the same name. They can be replaced
by size() or length() methods.

Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-12 01:05:45 +01:00
Edward Welbourne
1a693b058f Add spaces round operators and at starts of comment texts
More mindless coding-style conformance. Includes moving & or * to
after the space, not before, in declarations; and spaces after commas.

Change-Id: I221fef1e4de69d6c55d33dfc533aa74e2fd72df0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-17 15:51:31 +01:00
Edward Welbourne
c5645a48d4 Purge stray spaces immediately inside parentheses
With one exception: in a macro-definition with a backslash-newline
immediately following the open-parenthesis.

Change-Id: I0fc8d7492676402636785d571e4667881334af6a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:31 +01:00
Edward Welbourne
426f032119 Invert a condition to save a lot of indentation
Simply if (!condition) QSKIP(...) instead of having a long block
depend on the condition with the QSKIP() in its else block (which
should have had braces, as it was).

While dedenting the code block, tidied up spacing: only include blank
lines where they break up the code into blocks that go together, don't
leave spaces just inside parentheses.

Change-Id: I0196150088be88a7c6073b997a315b8f14d5f392
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:31 +01:00
Edward Welbourne
b3f67d2ba3 tst_QSqlQuery: fix usage of QtTest macros
Use QVERIFY() rather than comparison to true; QVERIFY() the negation
rather comparing to false; prefer QCOMPARE() otherwise for
comparisons, except for a few special cases involving very long
strings. Fix up the phrasing of a few QSKIP()s in the process.

Also, QCOMPARE() can handle an enum as expected value without
int-casting.

Change-Id: I9a1b82e5f4e10df6427bcc184b7757737df7db4f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:31 +01:00
Edward Welbourne
43209d0f0a tst_QSqlQuery coding style: split lots of long lines
In some cases by adjusting where the splits happen within concatenated
strings.

Change-Id: I4cffc41cda4582654151ba45d1478285caee7c81
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:31 +01:00
Edward Welbourne
7e59139f5c tst_QSqlQuery coding style: clean up loops
Prefer pre-decrement over post-decrement, turn a while into a for,
Don't put a while's body on the same line.

Change-Id: I5653a9bcec7901d205a91927c4b08e3dc13e0ca6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
e94b579679 tst_QSqlQuery coding style: clean up comments
Reflowed some over-long ones, fixed some typos, capitalise starts of
sentences (and end them with suitable punctuation). Removed one as
redundant, made another pair redundant by changing the code (use an
overt NaN instead of commenting that it's happening). Prefer C++-style
when single-line. Don't pretend to be QDoc comments, or have other
eccentricities about start-markers.

Change-Id: I5a30e1b22a08866124f09060bb35f5bd27cd443b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
5b7b8e123b tst_QSqlQuery coding style: use vertical spacing to group lines
Much of the test code simply had a blank line after each check. Keep
the ones that separate groups of related statements, but remove the
ones that separated members of such groups. In some cases swap a blank
line and a code line to put the code with things it relates to.

Change-Id: Ie33863080d407898b2b2f044599398980ab9793d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
f8d31aa7de tst_QSqlQuery coding style: clean up declarations
Split some long declarations of two variables in one line into two
separate declarations. Made more things const, made some consts
constexpr. Skip a variable entirely when it's only used once (and not
giving us some other benefit). Moved some declarations closer to their
variables' first uses.

Replace some Capitalised variable names with lower-case ones.

Change-Id: I3b8dac46530ba1c2e6100cb007b5487253304526
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
915469e4de Prefer QLatin1String::arg() over adding more than two strings
It saves the conversion to UTF-16 until the formatting. Split up long
lines, purge spaces just inside parentheses, and otherwise tidy
affected lines. Don't use backslash-newline for line continuation
within string literals; juxtaposition is cleaner.

Change-Id: I9c3d3e33f5ecbdb530538679147f7bc32afbeb05
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
afe23239cb Prefer u"..." and u"..."_qs over QStringLiteral() or QString("...")
It's terser and cleaner to read. Likewise for
QString::fromLatin1(). QCOMPARE() can take a QStringView, hence u"..."
as its expected string; other uses need u"..."_qs.

Change-Id: Iaf96569ff3ce69c890badfb6e40f702a78b100b3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
203f4b93cf Prefer QString::asprintf() over QString::arg when formatting numbers
Marc alleges it is more efficient.
Corrected part of a message to be more accurate in the process.
Save some casting by using suitable format specifiers.

Change-Id: Ic31a4e17b8910d35781a494ec860c7a08f08f33b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
e63b3b48ac Prefer QLatin1String::arg() over QString::arg() for ASCII literals
When the format is an ASCII string, there's no point widening it to
UTF-16 before the actual formatting step. Also, don't construct the
format string using string arithmetic, when passing another parameter
to arg() will do just as well. In the process, restructured
generic_data(), split long lines and conform spacing to Qt coding
style on affected lines. Simplified initialization of two string
fragments by using QL1S instead of QString, too.

Change-Id: Ib101dcf9296cc532291518bcef8e0a8de597b8a0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:29 +01:00
Edward Welbourne
e5ba838045 tst_qsqlquery coding style: use braces correctly
Single-line bodies of single-line controls don't need braces.
If one block of an if/else chain needs braces, the rest get them too.
One long condition needed a split that forced its body to need braces.

Change-Id: Ic4116b1273e16a586fdec18e6d8228e48a9cb07c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 17:32:47 +01:00
Edward Welbourne
1013cf49c7 Prefer QString(count, character) over QString::fill()ing
It lets the string be const, if nothing else.

Change-Id: Iffc1cfe71c5f6030b3f7434f964f2f2c102bf9c0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 17:32:47 +01:00
Edward Welbourne
ed0657b5e1 Avoid repeated qTableName() calls by saving in local variables
This saves repetition of the call in the midst of query strings.
This incidentally makes it possible to give informative names.

In the process, build those query strings using QLatin1String::arg(),
instead of implicitly converting ASCII strings to QString in order to
then do arithmetic with them, at least when the arithmetic involves
more than one addition. In one instance, where two branches did the
same thing with different format strings, limit the branching to
selecting which string to use, then do the common thing once.

Change-Id: I60fd7457a727bcc3872d3052d8fd638ebaf36ac2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 17:32:47 +01:00
Edward Welbourne
7bac62f8cd Use lists and arrays more gracefully in tst_qsqlquery
Use initializer lists rather than << entries.
Use arrays where we don't need the lists at all.
Make them const when they can be.
Replace foreach with ranged-for.
Use auto rather than naming iterator types and save end() at the start
of the iteration to save re-requesting it each time round the loop.

Reverse arguments to a QCOMPARE() as actual should come first and
expected after, not the other way round. Change some casts from
C-style to type-as-function-style, use QString literals rather than
C-string literals that would need conversion at compile time and
QLatin1String::arg in preference to arithmetic where the same format
is duplicated.

In the process, reworked one test to put its two iterations, one over
good query strings, one over bad ones, into separate blocks using
separate const arrays, instead of reusing a list with an uninformative
name.

Change-Id: I4a272be3eb58e9dca136238277b92379d6ca076d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-15 17:32:47 +01:00
Edward Welbourne
abf4175436 Use function-style casts in preference to C-style ones
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>
2022-02-10 19:20:59 +01:00
Edward Welbourne
3acaf3160d Convert some if/else-if/else chains into switch()es
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>
2022-02-10 19:20:59 +01:00
Edward Welbourne
35ec6283dc Convert some QVERIFY2() with useless messages to QVERIFY()
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>
2022-02-10 19:20:59 +01:00
Edward Welbourne
3253037329 Suppress, and thus verify we do get, two warnings in tst_QSqlQuery
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>
2022-02-10 19:20:59 +01:00
Edward Welbourne
9030ffdffb Use qScopeGuard() to take care of post-test tidy-up
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>
2022-02-10 19:20:59 +01:00
Edward Welbourne
69e445721c Get rid of empty optional methods in tst_QSqlQuery
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>
2022-02-09 21:46:24 +01:00
Edward Welbourne
06942138d6 Move prematureExec() to the end of tst_qsqlquery's testing
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>
2022-02-03 12:28:42 +01:00
Edward Welbourne
78eac57f3d Check for null driver() before trying to exec()
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>
2022-01-25 16:18:35 +01:00
Volker Hilsheimer
999d856bc8 Adapt SQL drivers to Qt 6 change of QVariant::isNull
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>
2022-01-12 17:41:07 +01:00
Tor Arne Vestbø
bef57b317f testlib: Deprecate QWARN() in favor of qWarning()
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>
2021-08-04 19:31:51 +02:00
Friedemann Kleint
21b3b54193 QSqlTableModel::orderByClause(): Quote the table name
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>
2021-05-03 14:10:36 +00:00
Andy Shaw
66acee69a1 SQLite: Handle tables and fields with a dot in the name correctly
Fixes: QTBUG-91885
Pick-to: 6.1 6.0 5.15
Change-Id: Iba76bb50266dd4fb5f50e4ea1549d1d2bb6e3431
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-04-23 10:46:58 +02:00
Volker Hilsheimer
5f31da62bb Disable warnings for tests using QSqlQuery assignment
Copying is deprecated as of 14f9f00fdb.

Pick-to: 6.1
Change-Id: I235d45ff6769a29a4fdfd888c20dd9fe2fe81346
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-04-11 23:08:32 +02:00
Giuseppe D'Angelo
14f9f00fdb QSqlQuery: make it a move only type
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>
2021-03-21 10:16:56 +01:00
Allan Sandfeld Jensen
bde773ec6a Fix a few compiler warnings in tests
Change-Id: I22f6ac8ed02dd4ef4083ce3c781552623a0b08da
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-02-02 12:06:05 +01:00
Andy Shaw
c2657f9762 QODBC: Preserve the whole value when using HighPrecision
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>
2021-01-14 07:02:43 +00:00
Christian Ehrlicher
b211148e4b Sql ODBC driver: add direct support for float and short datatype
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>
2021-01-10 13:02:14 +01:00