Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.7.0
-
None
-
Window 7, VS2015
-
b211148e4b4167483e1a78a45ae8fef97e5a4f2d (qt/qtbase/dev)
Description
QODBCResult::exec fails to bind many data types properly. Any QVariant::type that is not explicitly handled by the switch (which appears to be limited to the old QVariant types) falls through the default case. The default case then ignores the actual data and uses the empty QVariant in tmpStorage. This results in an empty string being sent.
// fall through default:{ QByteArray& ba = tmpStorage[i]; if(*ind != SQL_NULL_DATA) *ind = ba.size(); r = SQLBindParameter(d->hStmt, i + 1, qParamType[bindValueType(i) & QSql::InOut], SQL_C_BINARY, SQL_VARBINARY, ba.length() + 1, 0, const_cast<char*>(ba.constData()), ba.length() + 1, ind); break; }
Quick fix is to simply add
// fall through default:{ QByteArray& ba = tmpStorage[i]; ba = val.toByteArray(); ...
Full fix would be to explicitly handle the types which have sensible conversions i.e. QMetaType::Float -> SQL_C_FLOAT -> SQL_FLOAT etc.
Bug was probably introduced when tmpStorage was changed to be preallocated.