summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarko Kangas <marko.kangas@digia.com>2013-02-08 10:10:26 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-23 18:13:00 (GMT)
commiteb71bb131faafa57b0c7978a53b957bd08e71516 (patch)
treeab7902fde3e274094f65d265ba7a303563ff7e44 /tests
parentc795a8e55f1fd0d612d1dbf50e879029ea346765 (diff)
downloadQt-eb71bb131faafa57b0c7978a53b957bd08e71516.zip
Qt-eb71bb131faafa57b0c7978a53b957bd08e71516.tar.gz
Qt-eb71bb131faafa57b0c7978a53b957bd08e71516.tar.bz2
Fix for Sql query aliases with dots
Task-number: QTBUG-14904 Cherry-picked Qt5 change: 18be0749eb58316036d6eaff9dc5fecc1379f31a Change-Id: I81edd9df68cfde15900315978dc3742ca6e22df5 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index bcbeb51..5ebbc3b 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -219,6 +219,9 @@ private slots:
void QTBUG_21884();
void QTBUG_16967_data() { generic_data("QSQLITE"); }
void QTBUG_16967(); //clean close
+ void QTBUG_14904_data() { generic_data("QSQLITE"); }
+ void QTBUG_14904();
+
void QTBUG_2192_data() { generic_data(); }
void QTBUG_2192();
@@ -3243,6 +3246,42 @@ void tst_QSqlQuery::QTBUG_16967()
}
}
+/**
+ * Test for aliases with dots
+ */
+void tst_QSqlQuery::QTBUG_14904()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QSqlQuery q(db);
+
+ QString tableName(qTableName("bug14904", __FILE__ ));
+ tst_Databases::safeDropTable( db, tableName );
+
+ q.prepare("create table " + tableName + "(val1 int)");
+ QVERIFY_SQL(q, exec());
+ q.prepare("insert into " + tableName + "(val1) values(?);");
+ q.addBindValue(1);
+ QVERIFY_SQL(q, exec());
+
+ QString sql="select val1 AS value1 from " + tableName;
+ QVERIFY_SQL(q, exec(sql));
+ QVERIFY_SQL(q, next());
+
+ QCOMPARE(q.record().indexOf("value1"), 0);
+ QCOMPARE(q.record().field(0).type(), QVariant::Int);
+ QCOMPARE(q.value(0).toInt(), 1);
+
+ sql="select val1 AS 'value.one' from " + tableName;
+ QVERIFY_SQL(q, exec(sql));
+ QVERIFY_SQL(q, next());
+ QCOMPARE(q.record().indexOf("value.one"), 0); // was -1 before bug fix
+ QCOMPARE(q.record().field(0).type(), QVariant::Int);
+ QCOMPARE(q.value(0).toInt(), 1);
+}
+
void tst_QSqlQuery::QTBUG_2192()
{
QFETCH( QString, dbName );