Change-Id: I9bf7d61a65950eafcfe6b3ea9c437e353ff7b2ed
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
tst_QSqlQuery::bindBool() did not check if the bool is correctly bound
as part of the WHERE statement. Add a new test to query for the bool
column and check if there is exactly one row returned.
Fixes: QTBUG-38891
Change-Id: I0bd1ceb1b30e50f67f44f5b06d68683195b78b29
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This patch enabled json1 support for sqlite3 by defining
SQLITE_ENABLE_JSON1
[ChangeLog][QtSql][SQLite] Enable the json1-extension for
the SQLite3 plugin
Task-number: QTBUG-63498
Change-Id: Iaf1069ff1396c573125a5a3f490c0df5df560468
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Both sqlite3_open_v2 and sqlite3_close are documented to return an error code:
https://www.sqlite.org/c3ref/open.htmlhttps://sqlite.org/c3ref/close.html
However, those were ignored (other than checking whether the operation
succeeded), causing QSqlError::nativeErrorCode() to always be "-1" when there
was an error while opening/closing the database.
Additionally, the error string needs to be read (via sqlite3_errmsg16) in
qMakeError *before* d->access is set to 0, or the databaseText() will always be
"out of memory" no matter what error actually happened.
Task-number: QTBUG-70506
Change-Id: I75cbf178c9711442e640afd26c4502214d20c598
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
The default values for varchar columns were not decoded properly.
Task-number: QTBUG-46968
Change-Id: Ie13d48c316cd694240f7e287010b97afc8c6c341
Reviewed-by: Robert Szefner <robertsz27@interia.pl>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
When QSqlQueryModel or QSqlTableModel is created it will create a
QSqlQuery which defaults to using the default QSqlDatabase connection.
If this connection belongs to another thread then it will throw a
warning as this is not safe to use. Since the QSqlQuery is always
recreated when a query is set, the instance which is a member of
the class can effectively be invalid until a new one is set.
Task-number: QTBUG-69213
Change-Id: I68a5dd59fe62788f531d59a0680da11b118ee383
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Variable was declared outside #if-ery but only used inside,
leading to warnings when the define wasn't set.
Change-Id: Iad6a236bdf76b8ca0a58a84509d19f7e1a3e2df2
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
As the full range of TIME is '-838:59:59' to '838:59:59' then we cannot
use QTime as the object to store this data in. Therefore a QString is
used instead for passing the data to and from. This does not impact
existing code using QTime already as it will still convert it from
the QString to a QTime to give the same result as before.
[ChangeLog][QtSql][MySQL] The TIME data type is now treated like a
string-based type in order to respect the full range of the TIME data
type.
Task-number: QTBUG-57028
Change-Id: Ieb7105bff3043b845f76bc873d088e6bac1e4f10
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
When a QComboBox is used as the editor for a relation inside a view then
it could end up showing the contents of the EditRole. This would be the
field which is used to represent the entry as opposed to the DisplayRole
which is what the user would expect to see is.
Therefore, setEditorData() is overridden to ensure that it is showing
the right data to the user. When the model gets updated, it will take the
corresponding EditRole value as before to ensure it is updated correctly.
Task-number: QTBUG-59632
Change-Id: Ibbccc3e9477de1cdefb654051b97dd111df36382
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
This accounts for a case of a placeholder being duplicated in the
prepare query, but where only one placeholder was used. This amends
e4e87a2ece
Task-number: QTBUG-68299
Change-Id: Ia92ee912facd51a13e7222886debb219b24442b0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
OCIBindByPos2 is only needed when using execBatch(), binding data that
is longer than USHRT_MAX works for exec() so this is left unchanged.
Change-Id: Ifdcf91939d184f225d24c13052ea0b81611ecf91
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
If the db isn't valid, then that's the actual issue, not the fact that we're
getting the same invalid db (with the same driver QSqlNullDriver) in
multiple threads.
Change-Id: I95490818ed78e741c3823e115f139c2cff01b0b1
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Also expands the tst_qsqlquery::batchExec() test to account for this
case and generally test the functionality. In addition it is made to be
more robust to avoid any discrepencies with the testing data. The test
in general is also cleaned up to enable more of it being tested with
the different database drivers where possible.
An expected fail is added for MySQL due to the fact that it has a bug
where null timestamp entries are being converted to the current
datetime when adding it as a bind value.
Change-Id: I0061bd1c69ae35b4858afc49420f13ce59cf48ae
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This fixes the following:
- tst_QSqlDatabase::recordMySQL() to account for performance
improvements done for small integral types
- tst_QSqlQuery::nextResult() so that NUMERIC results are seen
as doubles
- tst_QSqlQuery::timeStampParsing() so that MySQL accepts the
CREATE TABLE statement
Change-Id: I68fb1d06dac12d500bb4596463f5bdd65cc9c226
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
When using a virtual table inside a SQLite database it is possible that
it does not report the right number of parameters. Therefore we need
to account for this case to prevent it from crashing when trying to
bind parameters it thinks does not exist.
Task-number: QTBUG-66816
Change-Id: I3ff70bb1fe73091f43c3df53616f75858e451cfd
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Postgresql needs a special value for nan and +/- inf. This was
considered during insert but not during select.
Also remove some pre-c++11 inf/nan - handling and replace it with
Qt equivalents.
Change-Id: I044ca58e9cf673f4b100b05a0d8e25c8a9c29ec5
Reviewed-by: Robert Szefner <robertsz27@interia.pl>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Currently there is a bug in Qt regarding the PostgreSQL driver as it
does not correctly escape the table names when constructing queries
internally. Therefore, these tests are marked as expected failures until
the bug itself is fixed in Qt.
Change-Id: I74dadc187f8a08509128dfea27be99787e57ea51
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This also accounts for some quirks on the PostgreSQL side:
- Null values for a related table are placed in a different
order when sorted.
- Functions (sum, count) return a different type than other databases
- Using quotes to account for case sensitivity with tables
Task-number: QTBUG-63861
Change-Id: Ib1894fa8d0c77d7045941f7c57be0d0acd8d117e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
In order to save having to always run a query to get the tablename for
a known oid then we cache the result on the driver side. The oid stays
the same while the table exists, so only on dropping it would it change.
Recreating the table causes it to get a new oid, so there is no risk of
the old one being associated with the wrong table when this happens, if
the driver is still open at that point.
The benchmark added shows the improvement from the previous code, before
the results for PostgreSQL was:
RESULT : tst_QSqlRecord::benchmarkRecord():"0_QPSQL@localhost":
259 msecs per iteration (total: 259, iterations: 1)
whereas now it is:
RESULT : tst_QSqlRecord::benchmarkRecord():"0_QPSQL@localhost":
0.000014 msecs per iteration (total: 59, iterations: 4194304)
Task-number: QTBUG-65226
Change-Id: Ic290cff719102743da84e2044cd23e540f20c96c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Robert Szefner <robertsz27@interia.pl>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Instead of having to modify the tst_databases.h file whenever you want
to add a test database, this will now read from a file to find what
databases are available. This defaults to dbs.json in the same directory
or the QT_TEST_DATABASES_FILE environment variable can be set to point
to the file that contains the databases. The latter makes it easier for
CI then to have something set up on a per configuration basis.
The SQLite database stays hardcoded so this will continue to be tested as
before without any additional changes.
Change-Id: I7e7ccde6a6be3e490dd640b1590e3b691a6b2ab3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
sqlite will reuse the index for bound parameters when the named
placeholder is duplicated so we only need to call bind one time for each
placeholder. Therefore we need to have just one instance of each value
when doing the bind.
Task-number: QTBUG-65150
Change-Id: I75c4bcc4563e43c180a59a7a4cbb770dbe994642
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
This change adds support for multiple result sets in PostgreSQL.
[Important Behavior Changes] The QPSQL driver now supports multiple
result sets. Since QPSQL previously did not support multiple result
sets, there may be some compatibility issues with the existing code
that executed several queries as one and were expecting to get
the results of the last one. In this case use QSqlQuery::nextResult()
to move to the last result set.
[ChangeLog][QtSql][QPSQL] Added support for multiple result sets
Change-Id: I2bfc91f512c4dac83116f3aa42833839a6da084c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
With this change, it is possible to significantly reduce memory
consumption of applications that fetch large result sets from databases.
The implementation is based on the new functionality called "single-row
mode" that was introduced in PostgreSQL version 9.2:
https://www.postgresql.org/docs/9.2/static/libpq-async.html
It also uses asynchronous commands PQsendQuery(), PQgetResult():
https://www.postgresql.org/docs/9.2/static/libpq-single-row-mode.html
[ChangeLog][QtSql][QPSQL] Added support for forward-only queries (requires
libpq version 9.2 or later)
[Important Behavior Changes] The QPSQL driver now supports forward-only
queries. To use this feature, you must build QPSQL plugin with PostreSQL
client library version 9.2 or later. See the Qt SQL documentation for
more information about QPSQL limitations of forward-only queries
(sql-driver.html).
[Important Behavior Changes] If you build the QPSQL plugin with PostgreSQL
version 9.2 or later, then you must distribute your application with
libpq version 9.2 or later. Otherwise, the QPSQL plugin will fail to load.
Task-number: QTBUG-63714
Change-Id: I15db8c8fd664f2a1f719329f5d113511fa69010c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
QSqlDatabase objects can only be used in the thread that the connection
was opened for. So if the driver was created already then we check if
the thread is correct. If it is not then we output a warning and return
an invalid QSqlDatabase.
[ChangeLog][QtSql][QSqlDatabase] QSqlDatabase::database() will return
an invalid QSqlDatabase if the calling thread does not own the requested
QSqlDatabase.
Task-number: QTBUG-216
Change-Id: Ib5a25aa62129e3925f9819109af05961e5178bc5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
As the numercialPrecisionPolicy can be set and subsequently retrieved
from the QSqlDatabase's driver, then when copying the QSqlDatabase, we
need to set that appropriately too.
Task-number: QTBUG-10452
Change-Id: I2c63748365ab4e9fbc29d8d460d80d2e2a0ee385
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
We haven't had support for anything older than 7.3 for a long time, so
this removes the code to save having to maintain it any further.
Task-number: QTBUG-644
Change-Id: If0635f3bef5138a00a0e77011a70f23d0bffda32
Reviewed-by: Robert Szefner <robertsz27@interia.pl>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Also blacklist tst_QNetworkReply::ioHttpRedirectErrors(too-many-redirects)
on RHEL 6.6 in CI.
Conflicts:
tests/auto/network/access/qnetworkreply/BLACKLIST
tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
Task-number: QTBUG-64569
Change-Id: I7514fc0660c18fd3a3e1d0d0af3f15d879e3c6f4
When looking for the primary index, it is possible that the
constraint_name in the all_ind_columns table does not match that of the
index_name. Whereas the index_name will match in this case, so the query
should set the where clause on the index_name in both tables.
Task-number: QTBUG-64427
Change-Id: I1bf1fb580e620b9f75f2fde1ecf408842e377365
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
This test contains Oracle specific queries and will fail for other DBMS.
Currently it doesn't fail, because it is skipped for drivers that doesn't
support BatchOperations and only QOCI supports batch operations.
Change-Id: I8f1e7c7244726fa11c841023dec186553747a6b5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
The TIMESTAMP type has been available in Oracle since Oracle 9i
which was released in June 2001 and contains more data than the
DATE type so it can be reliably used for the related data types.
This adds support for preserving milliseconds and the time zone
information if this is passed or in the database.
[ChangeLog][QtSql][OCI] Added support for the TIMESTAMP data type.
Task-number: QTBUG-23
Change-Id: Icf7a012dda75fb342ce6c6aa34eaa2a52755ff2d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Change-Id: Iffb81a37a517e58d48757d82f93f20e8c5100033
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Conflicts:
examples/examples.pro
qmake/library/qmakebuiltins.cpp
src/corelib/global/qglobal.cpp
Re-apply b525ec2 to qrandom.cpp(code movement in 030782e)
src/corelib/global/qnamespace.qdoc
src/corelib/global/qrandom.cpp
src/gui/kernel/qwindow.cpp
Re-apply a3d59c7 to QWindowPrivate::setVisible() (code movement in d7a9e08)
src/network/ssl/qsslkey_openssl.cpp
src/plugins/platforms/android/androidjniinput.cpp
src/plugins/platforms/xcb/qxcbconnection.cpp
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/widgets/widgets/qmenu.cpp
tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
Change-Id: If7ab427804408877a93cbe02079fca58e568bfd3
Based on a test-case from Israel Lins Albuquerque, that my planned
fixes to our parsing of ISODate date-times would break.
Change-Id: I5658df9c7daed59d43aa5574df25d4d9eac4677d
Reviewed-by: Israel Lins Albuquerque <israelins85@yahoo.com.br>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Commit 9e64fc9e1c caused a regression
which stored all QDateTime entries as if they were in localtime,
which causes them to be offset by the amount of local timezone
offset. This is fixed by adding "Z" if the time should be in UTC or
using "+/-hh:mm" if it should use fixed UTC offset or specific
timezone.
Task-number: QTBUG-57138
Change-Id: Ie60905dfb3a517db442b636ca41daf8348753d84
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
When you are using a query that pulls from a number of different tables
then it can be ambiguous as to which table a particular field belongs to.
So this will make it possible to determine the table that a given field
belongs to if it is set.
Task-number: QTBUG-7170
Change-Id: I49b7890c0523d81272a153df3860df800ff853d5
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
According to the test metrics this test failed 10 times in the last two
days. Interestingly the log shows that usually 5.5 seconds would have
let it pass.
Change-Id: I38f21f35bd6624f1d3de1e1e811a4d107136a241
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Also mark as shared-come-qt6 and add member-swap.
[ChangeLog][QtSql][QSqlError] Added swap().
Coverity-Id: 168223
Change-Id: Iaad4dee383900b9d11856e860b0647780a81a505
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
It's a Qt 3 compatibility vehicle, and as such inherits the now-alien
property to distinguish empty and null strings. Particularly worrisome
is the following asymmetry:
QString("") == QString::null // false
QString("") == QString(QString::null) // true
Instead of fixing this behavior, recognize that people might use it as
a weird way to call isNull(), albeit one that once was idiomatic, and
simply deprecate everything that deals with QString::null.
[ChangeLog][QtCore][QString] QString::null is now deprecated. When
used to construct a QString, use QString() instead. When used to
compare to a QString, replace with QString::isNull().
Change-Id: I9f7e84a92522c75666da15f49324c500ae93af42
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Since SQLite does not define a regexp function by default, provide a Qt
based implementation which can be enabled using QSQLITE_ENABLE_REGEXP as
an connect option. This way statements like
SELECT * FROM table WHERE col REGEXP '^[a-d]';
work out of the box.
[ChangeLog][QtSql] Add QSQLITE_ENABLE_REGEXP connect option for
QSQLiteDriver. If set a Qt based regexp() implementation is provided
allowing to use REGEXP in SQL statements.
Task-number: QTBUG-18084
Change-Id: I7f0e926fe4c5d6baea509f75497f46a61ca86679
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Sebastian Sauer <sebastian.sauer@kdab.com>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Change 3370ab9119 introduced
warnings from MSVC:
tst_qsqlquery.cpp(4005): warning C4805: '==': unsafe mix of type 'const bool' and type 'int' in operation
tst_qsqlquery.cpp(4059): note: see reference to function template instantiation 'void runIntegralTypesMysqlTest<bool>(QSqlDatabase &,const QString &,const QString &,const bool,const T,const T)' being compiled
with [ T=bool ]
tst_qsqlquery.cpp(4006): warning C4805: '==': unsafe mix of type 'const bool' and type 'int' in operation
tst_qsqlquery.cpp(4006): warning C4804: '/': unsafe use of type 'bool' in operation
tst_qsqlquery.cpp(4026): warning C4804: '+=': unsafe use of type 'bool' in operation
Extract an overload taking a QVector of values and use that for the
bool case instead of looping over min/max to generate a sequence of values
for bool.
Change-Id: I72583774e788b8df899f22ed1a64278217e664f6
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
5971b88e is not needed in new configure.
This merge also reverts "fix QMAKE_DEFAULT_*DIRS resolution with
apple SDK", 2c9d15d7, because it breaks iOS build with new
configure system.
Conflicts:
mkspecs/features/default_pre.prf
mkspecs/features/mac/toolchain.prf
mkspecs/features/toolchain.prf
src/dbus/qdbusconnection.cpp
src/plugins/sqldrivers/mysql/qsql_mysql.cpp
src/sql/drivers/mysql/qsql_mysql.cpp
src/widgets/widgets/qmenubar.cpp
src/widgets/widgets/qmenubar_p.h
tools/configure/configureapp.cpp
tools/configure/environment.cpp
tools/configure/environment.h
Change-Id: I995533dd334211ebd25912db05b639d6f908aaec
This has undesired effects when converting a QSqlRecord to JSON.
A char(0) e.g. has special semantics that are undesired when
reading a Tinyint column.
I don't think that returning bool for the special case of a
Tinyint(1) is required. This also did not happen before, and
is also not happening when not using a prepared statement.
Instead, a plain int/uint QVariant is returned.
This patch extends tst_QSqlQuery::integralTypesMysql to also
cover reading and writing booleans from/to a MySQL table column
of type Tinyint(1). Additionally, the reading is now also done
with a prepared statement and we also check the raw variant
value.
The broken behavior fixed by this patch was introduced by me in
commit 194403a348.
Change-Id: I028a3abd83fdd2b42d98d478950d205e5b6bbeb5
Task-number: QTBUG-53397
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
And blacklisted a few tests in tst_QUdpSocket.
Conflicts:
src/android/jar/src/org/qtproject/qt5/android/QtNative.java
src/corelib/global/qglobal.cpp
src/corelib/global/qsystemdetection.h
src/corelib/io/qfileselector.cpp
src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
tests/auto/network/socket/qudpsocket/BLACKLIST
Task-number: QTBUG-54205
Change-Id: I11dd1c90186eb1b847d45be87a26041f61d89ef6
The unsigned flag in columns was ignored when creating the list of
bound values in a mysql table. So the result iteration with
QSqlQuery::next stops after the first wrong truncated value.
[ChangeLog][QtSql] Fixed QSqlQuery::prepare value truncation error when
using UNSIGNED values in a MySQL database.
Task-number: QTBUG-53969
Task-number: QTBUG-53237
Change-Id: I10d977993445f2794f1dd8c88b2e83517ef524f3
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
This modification enables to use notification feature of SQLite with Qt
SQL driver, enables to subscribe for notifications and also to remove
notifications. close() is added to destructor to unregister
notifications in case it is used in multiple threads.
[ChangeLog][QtSql][SQLite] Adding notification feature to SQLite driver
Change-Id: I8b98787f5214a406357646a98711a8ff6045a0dd
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
The existing code derived a helper class from QSqlResult and
overloaded two protected functions as public ones so the test
could call them after casting QSqlResults to that helper class.
Both the cast (which is a C-style cast, but with combined
static_cast and const_cast semanics) and the following member
function call are undefined behavior.
Fix by making the test class a friend of QSqlResult, and
dropping the casts.
Change-Id: I09de2e2b46976d01cfce25892aec6ad36881d3eb
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Use the newly introduced QSysInfo::machineHostName() to determine
the host name in the shared header, removing the need to link
against the winsocket library. All Windows-specific .pro sections
can then be removed.
Task-number: QTBUG-51673
Change-Id: Iba990b886b16addd210639871065abde6de96516
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
This also reverts commit 018e670a26.
The change was introduced in 5.6. After the refactoring, 14960f52,
in 5.7 branch and a merge, it is not needed any more.
Conflicts:
.qmake.conf
src/corelib/io/qstandardpaths_mac.mm
src/corelib/tools/qsharedpointer_impl.h
tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
Change-Id: If4fdff0ebf2b9b5df9f9db93ea0022d5ee3da2a4
If the WHERE clause is used in a query involving multiple tables,
such as generated by QSqlRelationalTableModel, the table prefix
may be necessary to disambiguate column references. It is harmless
if not needed.
Task-number: QTBUG-43320
Change-Id: I39e1ab7359bf748afa8bcd8578220e3abb3ee24a
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This test ensure that a connection made to either an invalid host or an
unreachable host fails properly.
Task-number: QTBUG-47452
Change-Id: If31d23d815e496fc21ef2e1e19c34c2723bd3504
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)
Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Call begin/endResetModel() in QSqlQueryModel and all
derived classes.
Task-number: QTBUG-49404
Change-Id: I11492d6386efb4c945c246a6379aaa6ca4502a25
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Prefer QCOMPARE over QVERIFY for equality and use QLatin1String().
Change-Id: If226a0fc7b25be3e6774c7e36ca1e6f99234e5dd
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Use character literals where applicable.
Change-Id: I1a026c320079ee5ca6f70be835d5a541deee2dd1
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
The keyword no longer has a meaning for the new CI.
Change-Id: Ibcea4c7a82fb7f982cf4569fdff19f82066543d1
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Instead, we use the binary MySQL encoding and copy the data directly
into the QVariant of the desired type. This gets rid of the temporary
string allocations and greatly improves the performance of the added
benchmark. On my machine, the results are:
Before:
0.562 msecs per iteration (total: 563, iterations: 1000)
1,922,479.330 instructions per iteration (total: 1,922,479,330, iterations: 1000)
After:
0.381 msecs per iteration (total: 381, iterations: 1000)
774,132.957 instructions per iteration (total: 774,132,958, iterations: 1000)
Note that the same could be applied to floating point data types in
the future. Additionally, special support for MYSQL_TIME structure
coult be added to get rid of the string conversions there.
To ensure everything keeps working, a new auto test is added as well
that verifies the select statements and insertions of integral data
into a MySql table works as intended.
[ChangeLog][QtSql] Improve performance when reading integer values
from MySQL databases via prepared statements.
Change-Id: I21dd9277661971ded934546f09535014b63f8eb8
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
- Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer).
- Replace Q[TRY]_VERIFY(smartPointer == 0) by
Q[TRY]_VERIFY(smartPointer.isNull()).
- Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and
add casts where necessary. The values will then be logged
should a test fail.
Change-Id: I4e4a319c5918d697a33f6d6032c36b8c9660ca05
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
Preparing the replacement of Q[TRY]_VERIFY(a == b) by
Q[TRY]_COMPARE(a, b) for non-boolean types.
Change-Id: Iab6ec2f0a89a3adc79e18304573994965013dab5
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Addition of new options SSL_KEY, SSL_CERT, SSL_CA, SSL_CAPATH and SSL_CIPHER
to allow SSL-encrypted connections to MySQL databases.
When needed, these options must be specified in the function call
QSqlDatabase::setConnectOptions() before the call to QSqlDatabase::open().
SSL_KEY = the path name to the key file
SSL_CERT = the path name to the certificate file
SSL_CA = the path name to the certificate authority file
SSL_CAPATH = the path name to a directory that contains trusted SSL CA
certificates in PEM format.
SSL_CIPHER = a list of permissible ciphers to use for SSL encryption.
These options replace CLIENT_SSL (which should not be used any more).
Example:
db.setConnectOptions("SSL_KEY=client-key.pem;" \
"SSL_CERT=client-cert.pem;" \
"SSL_CA=server-ca.pem");
[ChangeLog][QtSql] SSL support for MySQL database connections has been added.
Option CLIENT_SSL replaced by SSL_KEY, SSL_CERT, SSL_CA, SSL_CAPATH and
SSL_CIPHER, so that the keys, certificates and cipher can be specified.
Task-number: QtBUG-3500
Change-Id: I8197234b169a818658678d6fcc953c90e83db23e
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Introduce a template function to determine the special values
via macro and use that for QVariant::Double and QMetaType::Float.
Task-number: QTBUG-44381
Change-Id: I379dd82b22d467b0aebaa42f4f0f5c52472a5c47
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.
Outdated header.LGPL removed (use header.LGPL21 instead)
Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing
combination. New header.LGPL-COMM taken in the use file which were
using old header.LGPL3 (src/plugins/platforms/android/extract.cpp)
Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license
combination
Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe
Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
Until now, QSqlQuery::execBatch did not call resetBindCount, which lead
the next call to QSqlQuery::addBindValue to start at non zero index.
This is problematic in case of a prepared query which is called several
times.
Task-number: QTBUG-43874
Change-Id: I1a0f46e39b74d9538009967fd98a269e05aac6f2
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
The ROUND function for PostgreSQL only accept NUMERIC field as argument
Change-Id: I0c3753bfe4167cd47158e21b407cca8771816104
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This patch adds correct timezone support in PSQL plugin. Prior to this
patch, no timezone support was provided, so only the following case
worked :
* using local time in both client application and postgresql server
* datetime were using second precision
This patch tries to take care that postgresql has two different
datatypes for date time, respectively :
* timestamp with time zone
* timestamp without time zone
Both are internally stored as UTC values, but are not parsed the same.
* timestamp with time zone assumes that there is a time zone
information and will parse date time accordingly, and then, convert
into UTC before storing them
* timestamp without time zone assumes that there is no time zone
information and will silently ignore any, unless the datetime is
explicitly specified as having a time zone, in case it will convert
it into UTC before storing it
Both are retrieved as local time values, with the following difference
* timestamp with time zone includes the timezone information
(2014-02-12 10:20:12+0100 for example)
* timestamp without time zone does not include it
The patch does the following :
* parse the date retrieved by postgresql server using QDateTime
functions, which work correctly
* always convert the date to UTC before giving it to postgresql
* force time zone so that timezone information is taken into account
by postgresql
* also adds the milliseconds when storing QDateTime values
The following configurations are tested to work :
* client and server using same timezone, timestamp with or without tz
* client and server using different timezone, timestamp with tz
The following configuration will *not* work :
* client and server using different timezones, timestamp without tz
Because data will be converted to local time by the postgresql server,
so when returned it will be different from what had been serialized.
Prior to this patch, it gave the illusion to work because since TZ
information was lost, time was stored as local time from postgresql.
Lots of inconsistencies occurred, though, in case client tz changes...
I don't expect this to be an issue since having different TZ in server
and client and *not* handling this is a broken setup anyway.
Almost based on changes proposed by julien.blanc@nmc-company.fr
[ChangeLog][QtSql] Added timezone support for datetime fields in PSQL
Task-number: QTBUG-36211
Change-Id: I5650a5ef60cb3f14f0ab619825612831c7e90c12
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
The enum was made public in f84b00c6d2, but this
makes it follow the convention to camel case acronyms too before it's too late
to change it.
Change-Id: Ibb81e9221cb73fe0502d0a26f2d73512dd142f08
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
dbmsType was previously kept as a private variable in QSqlDriverPrivate,
however it's particularly useful for QODBC users.
[ChangeLog][QtSql][QSqlDriver] Add support for determining DBMS type from SQL driver.
Change-Id: If1c221520da9ac4ccef85a02db078679d76eac92
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
With VS2013 Update 3, Win32 sockets are now allowed in Windows Store
Apps. Upgrading VS meant that gethostname was visible to the application,
but failed to link as the mkspec doesn't link to ws2_32. Adjust the
workaround not to call the newly visible symbol on WinRT.
Change-Id: Ide6d8759cca7acab6c466a9bf4d6b876f6ca7605
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@digia.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Useful if someone is ever forced to try diagnose what goes wrong with this test.
Change-Id: I4b5e607e6329b6ebad2b40b3f65d6cacbb6b7fcf
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Reduces the average runtime of this test for me by ~600ms, but due to the
threading variance the exact reduction is hard to tell.
Change-Id: I96a9f949ae2381f69d9364e6637db0db4bd3b165
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Makes the test behavior identical across all platforms.
Change-Id: I5e564598d8e61588af2b73f04b4ca7c9b899c02a
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
sched_yield is standardized and on linux pthread_yield is implemented as sched_yield.
Building Qt for Android on OS X doesn't compile with the pthread version.
Change-Id: I1913afa83769805291e987f55b8f452299a43dce
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
When QSqlQuery::at() == QSql::BeforeFirstRow and seek(1, true) (seek to
next record) is called the expected result is go to first row.
When QSqlQuery::at() == QSql::AfterLastRow and seek(-1, true) (seek to
previous record) is called the expected result is go to last row.
But in all cases the first and last are skipped.
Change-Id: I584138b3d397ce1c790bf89688ee92289a99611c
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
And move the default argument from the deprecated constructor to
the new one
Also make sure that the error number is consistent across the
two constructor
Change-Id: I3721266b39ab493f0add35b2d1f892b2f6094992
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Initialize directory delayed in shared code and add checks to verify
that it is valid. Close attached / cloned databases to prevent locks
on files and leaking temporary directories caused by SQLite:
QTemporaryDir: Unable to remove "...\Temp\tst_qsqldatabase-P1XkOA" most likely due to the presence of read-only files.
QTemporaryDir: Unable to remove "...\Temp\tst_qsqltablemodel-P1XkOA" most likely due to the presence of read-only files.
QWARN : tst_QSql::concurrentAccess() QTemporaryDir: Unable to remove "...\Temp\tst_qsql-l0VAKJ" most likely due to the presence of read-only files.
Change-Id: If85bbaed04bb1a32e427d642be332996d967f796
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Adapt the stringification code, that is used to produce the
keys for QSqlQuery::boundValues() return value, to keep the
right order of the binding values.
Task-number: QTBUG-12186
Change-Id: Ic11a455bfd9ffd1418b1b021ce5cf78cae9b4504
[ChangeLog][QtSql] Fixed the order of values with positional binding in a QSqlQuery
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Each model test gets its own temporary directory, thus there is no problem parallelizing them.
This should reduce the time spent for a testrun of qtbase by around 3 minutes.
When running only the sql tests it saves less since there are no other tests to run in parallel.
=== Timing: =================== TEST RUN COMPLETED! ============================
Total: 4 minutes 43 seconds
Serial tests: 4 minutes 42 seconds
Parallel tests: 1 second
Estimated time spent on insignificant tests: (no time)
Estimated time saved by -j4: 1 second
=== Totals: 12 tests, 12 passes ================================================
After:
=== Timing: =================== TEST RUN COMPLETED! ============================
Total: 4 minutes 7 seconds
Serial tests: 50 seconds
Parallel tests: 3 minutes 17 seconds
Estimated time spent on insignificant tests: (no time)
Estimated time saved by -j4: 1 minute 23 seconds
=== Totals: 12 tests, 12 passes ================================================
Change-Id: I355ceed62fae852ad8cd442848e263438afb738e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Commit 773dd01 introduced a general mingw platform scope, which
is cleaner and more flexible than matching the spec name.
Change-Id: Ie3a9cb791a83f7c8a51bc4e23069190c452ab521
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
the diff -w for this commit is empty.
Started-by: Thiago Macieira <thiago.macieira@intel.com>
Change-Id: I77bb84e71c63ce75e0709e5b94bee18e3ce6ab9e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Some database systems (like PostgreSQL) use alphanumeric error codes.
Introduce a new method nativeErrorCode() which replaces number().
If the error code cannot be converted to int, number() will return 0.
Task-number: QTBUG-142
Change-Id: Ic7fba841737674b75c0c01c2263f51d2041da497
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Introduce isNull overload to take field name as a parameter.
This is corresponding to the commit
7e6e141234
Change-Id: I122f79707d26eaa09c2f38dc31aeee1dac7de33b
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
the method returns true if there is not such field.
Change-Id: I25db8de4561d3e0604f3e64edc1810140ba4aad2
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
- Remove irrelevant test subdirs via .pro files
- Follow WinCE codepaths where applicable
- Replace unsupported Win32 APIs with WinRT equivalents
This does not aim to fix any failures in the tests themselves; it only
makes them compile.
Change-Id: Ia82bc0cc402891f8f6238d4c261ee9152b51be80
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Except where we're actually testing QCoreApplication::applicationName()
and friends.
Change-Id: I25514884c11f43a4f82b1f818f822dc3d79f69a3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This removes some XFAILS that were no longer correct and
fixes some existing problems in the tests where ODBC is
concerned.
Change-Id: I91de526bb50ad4046ba07ddb5336aa3714966687
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Oracle has a limitation of 30 characters for a tablename so the main
change is to account for this, which meant changing all the usages of
qTableName(). Some other fixes are included that ensure the tests are
working correctly as far as Oracle is concerned.
Change-Id: I8ad8a5a33e6a70fcad235f6a7e82e91687b74fee
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
By moving it to QSqlDriverPrivate we make it easier to check what
database is actually connected which is particularly useful for the
autotests.
Change-Id: I54d1c2c998919c1d54efb1b6ac9303070ece54aa
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
The QODBCResult::exec() returns false when query is an delete
with no data do delete caused by SQLExecute function returning
SQL_NO_DATA, but the false return means error on execution.
Task-number: QTBUG-10569
Change-Id: I6c7ebadcf62ab404b60c7bcccdab6a10bf16a923
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Remove all trailing whitespace from the following list of files:
*.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README
excluding 3rdparty, test-data and auto generated code.
Note A): the only non 3rdparty c++-files that still
have trailing whitespace after this change are:
* src/corelib/codecs/cp949codetbl_p.h
* src/corelib/codecs/qjpunicode.cpp
* src/corelib/codecs/qbig5codec.cpp
* src/corelib/xml/qxmlstream_p.h
* src/tools/qdoc/qmlparser/qqmljsgrammar.cpp
* src/tools/uic/ui4.cpp
* tests/auto/other/qtokenautomaton/tokenizers/*
* tests/benchmarks/corelib/tools/qstring/data.cpp
* util/lexgen/tokenizer.cpp
Note B): in about 30 files some overlapping 'leading tab' and
'TAB character in non-leading whitespace' issues have been fixed
to make the sanity bot happy. Plus some general ws-fixes here
and there as asked for during review.
Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Parsing for bound SQL parameters now handles identifier quoting using
double quotes (") and square brackets ([]).
The following has only 1 bound value but previously 2 were detected:
SELECT 1 AS "A?b[?']]]de?ghi", ?
Task-number: QTBUG-27159
Change-Id: Icfd02187e1126ff3b5ed11df8d4e599f574e61bf
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
revert() should operate in OnFieldChange edit strategy just as
submit() does. The reason in Qt 4 for excluding OnFieldChange
was that there was no opportunity to revert. The model was
refreshed, causing all changes to be lost. In Qt 5 a failed
edit remains in the cache until user action, which could be
to revert.
Change-Id: Ide021c4f83a53834b7ed81f2abfa3aa49317704d
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Previously, selectRow() did not work after INSERTing a new row into a
table with an automatically populated column. It did not work because
the model did not know the primary values for the new row. Newly
inserted rows were therefore not refreshed in OnFieldChange and
OnRowChange edit strategies.
This change provides support for the typical simple case where a single
column is populated by the database and can be retrieved with
QSqlQuery::lastInsertId().
Task-Number: QTBUG-29102
Change-Id: Ibf0f0ac8661185bde57034ddf40c2178bece4778
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Lukas Geyer <lgeyer@gmx.at>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Commit 10ff9de91b introduced the
optimization of ignoring non-changes, but it overshot the mark.
It neglected to consider that QVariant's equality operator does not
compare the null flag. It also failed to consider that setData() has
a useful side effect of setting the generated flag in a column of a
pending INSERT. This is important when the application actually wants
a NULL to be inserted into the column.
Task-number: QTBUG-29217
Change-Id: I1368f7acc21eebfeb5a8d23746fc38f6f30fd395
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
QSqlQueryModel::headerData() relied on virtual indexInQuery() to
detect whether the requested column at row 0 mapped to an index in
the query. This failed when row 0 was a pending insert managed by
QSqlTableModel, and therefore not in the query.
The only thing that matters here is the column.
Task-number: QTBUG-29108
Change-Id: I3e0ae85ba223e444781ec8033386d394bb44f0e8
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
These types are either built-in or 'automatically declared' and so
don't need to be explicitly declared as metatypes.
Change-Id: Ifd116dee32a450ff89a9a1011e26b434765d6e95
Reviewed-by: David Faure <david.faure@kdab.com>