Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.6, 5.12.0
-
c2657f9762e01abd65ac991ba31e3ca085d9540c (qt/qtbase/dev) 1c38e5a7b53813ae624770066cc7f7c7f5acfb9c (qt/tqtc-qtbase/tqtc/lts-5.15) 1932953334e3b37441e0a12804813cc529dcbc04 (qt/qtbase/6.0)
Description
Problem is in qsql_odbc.cpp file line 1282
1281: case QSql::HighPrecision: 1282: d->fieldCache[i] = qGetStringData(d->hStmt, i, info.length(), false); 1283: break;
info.length() should be replaced with something like this: info.length() + ((info.precision() != -1) ? 1 : 0) or else last digit will be cut.
Here is minimal project to reproduce the issue:
#include <QCoreApplication> #include <QSqlDatabase> #include <QSqlQuery> #include <QSqlDriver> #include <QDebug> int *main*(int argc, char *argv[]) { QCoreApplication a(_argc_, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); db.setHostName("host"); db.setPort(7433); db.setDatabaseName("test"); db.setUserName("user"); db.setPassword("********"); db.open(); QSqlQuery query("SELECT 99.99, 9999999999999999, 999999999999999999999999.99", db); query.setNumericalPrecisionPolicy(QSql::HighPrecision); query.next(); qDebug() << query.value(0).toString() << query.value(1).toString() << query.value(2).toString(); return a.exec(); } Output: "99.9\u0000" "9999999999999999" "999999999999999999999999.9\u0000"