Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
6.4.3
Description
moving from Qt6.4.2 to Qt6.4.3 it appears odbc sqldriver has a bug. In Qt6.4.3 if the size of the database column equals the size of the QString. for example if column Uuid in table is a varchar(36), and the inserted Data is of size 36 characters then Qt6.4.3 odbc driver passes size 37 which results in the error.
This is happening probably because of the code like following:
in Qt/6.4.3/Src/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc.cpp, line 1374: { auto encoded = toSQLTCHAR(query); r = SQLPrepare(d->hStmt, encoded.data(), SQLINTEGER(encoded.size())); } In Qt6.4.2 it was: r = SQLPrepare(d->hStmt, toSQLTCHAR(query).data(), (SQLINTEGER) query.length());
The problem is that toSQLTCHAR returns a QVarLengthArray which has a
size one element bigger than the original QString. That is probably because it appends(0) at the end.
When client application runs it ends with following error:
"[Microsoft][SQL Server Native Client 11.0][SQL
Server]Character or binary data in table
"MyDatabase.dbo.mytable", column "Uuid" is truncated.
Truncated Data: B98E2686-E67F-4F8F-8D8D-DD0B0DBBFECE."
Attachments
Issue Links
- duplicates
-
QTBUG-112375 Error inserting value in field varchar(1) with prepared query with ODBC sql driver
- Closed