summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql/kernel
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2019-01-31 11:50:15 +0100
committerAndy Shaw <andy.shaw@qt.io>2021-01-14 07:02:43 +0000
commitc2657f9762e01abd65ac991ba31e3ca085d9540c (patch)
treef1d7842acd0aaaf2a70cbdc7e53182a10a7cd43b /tests/auto/sql/kernel
parent1bcfada9f04bd20a7a64d448fbf60c0f0820ed09 (diff)
QODBC: Preserve the whole value when using HighPrecision
Some ODBC drivers do not properly handle SQL_NO_DATA and therefore decimal values returned with HighPrecision are cut off because the decimal point is not taken into account. Fixes: QTBUG-73286 Pick-to: 6.0 5.15 5.12 Change-Id: I905c947b4d0266a3245d5735300300ca00f77480 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'tests/auto/sql/kernel')
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index edb6a2747a..ad7baeb9a9 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -258,6 +258,9 @@ private slots:
void QTBUG_57138_data() { generic_data("QSQLITE"); }
void QTBUG_57138();
+ void QTBUG_73286_data() { generic_data("QODBC"); }
+ void QTBUG_73286();
+
void dateTime_data();
void dateTime();
@@ -4548,6 +4551,7 @@ void tst_QSqlQuery::QTBUG_57138()
QSqlQuery create(db);
QString tableName = qTableName("qtbug57138", __FILE__, db);
+ tst_Databases::safeDropTable(db, tableName);
QVERIFY_SQL(create, exec("create table " + tableName + " (id int, dt_utc datetime, dt_lt datetime, dt_tzoffset datetime)"));
QVERIFY_SQL(create, prepare("insert into " + tableName + " (id, dt_utc, dt_lt, dt_tzoffset) values (?, ?, ?, ?)"));
@@ -4571,6 +4575,37 @@ void tst_QSqlQuery::QTBUG_57138()
QCOMPARE(q.value(2).toDateTime(), tzoffset);
}
+void tst_QSqlQuery::QTBUG_73286()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QSqlQuery create(db);
+ QString tableName = qTableName("qtbug73286", __FILE__, db);
+ tst_Databases::safeDropTable(db, tableName);
+
+ QVERIFY_SQL(create, exec("create table " + tableName + " (dec2 decimal(4,2), dec0 decimal(20,0), dec3 decimal(20,3))"));
+ QVERIFY_SQL(create, prepare("insert into " + tableName + " (dec2, dec0, dec3) values (?, ?, ?)"));
+
+ create.addBindValue("99.99");
+ create.addBindValue("12345678901234567890");
+ create.addBindValue("12345678901234567.890");
+
+ QVERIFY_SQL(create, exec());
+
+ QSqlQuery q(db);
+ q.prepare("SELECT dec2, dec0, dec3 FROM " + tableName);
+ q.setNumericalPrecisionPolicy(QSql::HighPrecision);
+
+ QVERIFY_SQL(q, exec());
+ QVERIFY(q.next());
+
+ QCOMPARE(q.value(0).toString(), "99.99");
+ QCOMPARE(q.value(1).toString(), "12345678901234567890");
+ QCOMPARE(q.value(2).toString(), "12345678901234567.890");
+}
+
void tst_QSqlQuery::dateTime_data()
{
if (dbs.dbNames.isEmpty())