summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2018-02-22 13:45:34 +0100
committerAndy Shaw <andy.shaw@qt.io>2018-03-17 23:14:34 +0000
commit9b68dc19bf3973d3a46439c4b8667ad3beba167d (patch)
treee908f4ae759d26a4b117ca578da6f76ef8fb762e /tests/auto/sql
parent44137dc65ab1121fc360f6f006b7515648f0bae3 (diff)
MySQL: Fix tests
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>
Diffstat (limited to 'tests/auto/sql')
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp8
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp10
2 files changed, 9 insertions, 9 deletions
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index 89978319a0..4130b364f4 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -890,10 +890,10 @@ void tst_QSqlDatabase::recordMySQL()
static QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0));
static const FieldDef fieldDefs[] = {
- FieldDef("tinyint", QVariant::Int, 127),
- FieldDef("tinyint unsigned", QVariant::UInt, 255),
- FieldDef("smallint", QVariant::Int, 32767),
- FieldDef("smallint unsigned", QVariant::UInt, 65535),
+ FieldDef("tinyint", static_cast<QVariant::Type>(QMetaType::Char), 127),
+ FieldDef("tinyint unsigned", static_cast<QVariant::Type>(QMetaType::UChar), 255),
+ FieldDef("smallint", static_cast<QVariant::Type>(QMetaType::Short), 32767),
+ FieldDef("smallint unsigned", static_cast<QVariant::Type>(QMetaType::UShort), 65535),
FieldDef("mediumint", QVariant::Int, 8388607),
FieldDef("mediumint unsigned", QVariant::UInt, 16777215),
FieldDef("integer", QVariant::Int, 2147483647),
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index c4a27a3175..6843ff7d4a 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -3035,11 +3035,7 @@ void tst_QSqlQuery::nextResult()
QCOMPARE( q.record().field( 0 ).type(), QVariant::String );
QCOMPARE( q.record().field( 1 ).name().toUpper(), QString( "NUM" ) );
-
- if (dbType == QSqlDriver::MySqlServer)
- QCOMPARE( q.record().field( 1 ).type(), QVariant::String );
- else
- QCOMPARE( q.record().field( 1 ).type(), QVariant::Double );
+ QCOMPARE(q.record().field(1).type(), QVariant::Double);
QVERIFY( q.next() ); // Move to first row of the second result set
@@ -3289,6 +3285,10 @@ void tst_QSqlQuery::timeStampParsing()
QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
"id serial NOT NULL, "
"datefield timestamp, primary key(id));")));
+ } else if (dbType == QSqlDriver::MySqlServer) {
+ QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
+ "id integer NOT NULL AUTO_INCREMENT,"
+ "datefield timestamp, primary key(id));")));
} else {
QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
"\"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT,"