summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2013-02-08 23:57:41 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-12 10:54:51 +0100
commitf01caaf64a6798e805ce5df9f735a5b86bfe8eb8 (patch)
tree31c05e2f88152d50d3b20213b4fc7f2cf609fa64 /tests/auto/sql
parent784b9655597d2c23a00d57181b1853e6df07fdf3 (diff)
QSqlQuery tests: fix mysql problems
Change-Id: I82f4e6c8801c7a936b80ad72c229f915e6d2a4de Reviewed-by: Israel Lins Albuquerque <israelins85@yahoo.com.br> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'tests/auto/sql')
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 4e821dacc5..764b29dc85 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -540,7 +540,7 @@ void tst_QSqlQuery::mysqlOutValues()
q.exec( "drop function " + hello );
- QVERIFY_SQL( q, exec( "create function " + hello + " (s char(20)) returns varchar(50) return concat('Hello ', s)" ) );
+ QVERIFY_SQL(q, exec("create function " + hello + " (s char(20)) returns varchar(50) READS SQL DATA return concat('Hello ', s)"));
QVERIFY_SQL( q, exec( "select " + hello + "('world')" ) );
QVERIFY_SQL( q, next() );
@@ -3580,7 +3580,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
CHECK_DATABASE(db);
QVariant::Type intType = QVariant::Int;
// QPSQL uses LongLong for manipulation of integers
- if (db.driverName().startsWith("QPSQL"))
+ if (db.driverName().startsWith("QPSQL") || db.driverName().startsWith("QMYSQL"))
intType = QVariant::LongLong;
{
const QString tableName(qTableName("numericFunctionsWithIntValues", __FILE__));
@@ -3594,6 +3594,8 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QVERIFY(q.next());
if (db.driverName().startsWith("QSQLITE"))
QCOMPARE(q.record().field(0).type(), QVariant::Invalid);
+ else if (db.driverName().startsWith("QMYSQL"))
+ QCOMPARE(q.record().field(0).type(), QVariant::Double);
else
QCOMPARE(q.record().field(0).type(), intType);
@@ -3603,11 +3605,15 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName));
QVERIFY(q.next());
QCOMPARE(q.value(0).toInt(), 3);
- QCOMPARE(q.record().field(0).type(), intType);
+ if (db.driverName().startsWith("QMYSQL"))
+ QCOMPARE(q.record().field(0).type(), QVariant::Double);
+ else
+ QCOMPARE(q.record().field(0).type(), intType);
QVERIFY_SQL(q, exec("SELECT AVG(id) FROM " + tableName));
QVERIFY(q.next());
- if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QPSQL")) {
+ if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QPSQL")
+ || (db.driverName().startsWith("QMYSQL"))) {
QCOMPARE(q.value(0).toDouble(), 1.5);
QCOMPARE(q.record().field(0).type(), QVariant::Double);
} else {
@@ -3682,7 +3688,10 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QVERIFY_SQL(q, exec("SELECT ROUND(id, 0) FROM " + tableName + " WHERE id=2.5"));
QVERIFY(q.next());
- QCOMPARE(q.value(0).toDouble(), 3.0);
+ if (db.driverName().startsWith("QMYSQL"))
+ QCOMPARE(q.value(0).toDouble(), 2.0);
+ else
+ QCOMPARE(q.value(0).toDouble(), 3.0);
QCOMPARE(q.record().field(0).type(), QVariant::Double);
}
}