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>
This commit is contained in:
parent
44137dc65a
commit
9b68dc19bf
@ -890,10 +890,10 @@ void tst_QSqlDatabase::recordMySQL()
|
|||||||
|
|
||||||
static QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0));
|
static QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0));
|
||||||
static const FieldDef fieldDefs[] = {
|
static const FieldDef fieldDefs[] = {
|
||||||
FieldDef("tinyint", QVariant::Int, 127),
|
FieldDef("tinyint", static_cast<QVariant::Type>(QMetaType::Char), 127),
|
||||||
FieldDef("tinyint unsigned", QVariant::UInt, 255),
|
FieldDef("tinyint unsigned", static_cast<QVariant::Type>(QMetaType::UChar), 255),
|
||||||
FieldDef("smallint", QVariant::Int, 32767),
|
FieldDef("smallint", static_cast<QVariant::Type>(QMetaType::Short), 32767),
|
||||||
FieldDef("smallint unsigned", QVariant::UInt, 65535),
|
FieldDef("smallint unsigned", static_cast<QVariant::Type>(QMetaType::UShort), 65535),
|
||||||
FieldDef("mediumint", QVariant::Int, 8388607),
|
FieldDef("mediumint", QVariant::Int, 8388607),
|
||||||
FieldDef("mediumint unsigned", QVariant::UInt, 16777215),
|
FieldDef("mediumint unsigned", QVariant::UInt, 16777215),
|
||||||
FieldDef("integer", QVariant::Int, 2147483647),
|
FieldDef("integer", QVariant::Int, 2147483647),
|
||||||
|
@ -3035,11 +3035,7 @@ void tst_QSqlQuery::nextResult()
|
|||||||
QCOMPARE( q.record().field( 0 ).type(), QVariant::String );
|
QCOMPARE( q.record().field( 0 ).type(), QVariant::String );
|
||||||
|
|
||||||
QCOMPARE( q.record().field( 1 ).name().toUpper(), QString( "NUM" ) );
|
QCOMPARE( q.record().field( 1 ).name().toUpper(), QString( "NUM" ) );
|
||||||
|
QCOMPARE(q.record().field(1).type(), QVariant::Double);
|
||||||
if (dbType == QSqlDriver::MySqlServer)
|
|
||||||
QCOMPARE( q.record().field( 1 ).type(), QVariant::String );
|
|
||||||
else
|
|
||||||
QCOMPARE( q.record().field( 1 ).type(), QVariant::Double );
|
|
||||||
|
|
||||||
QVERIFY( q.next() ); // Move to first row of the second result set
|
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("("
|
QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
|
||||||
"id serial NOT NULL, "
|
"id serial NOT NULL, "
|
||||||
"datefield timestamp, primary key(id));")));
|
"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 {
|
} else {
|
||||||
QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
|
QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
|
||||||
"\"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT,"
|
"\"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT,"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user