diff options
-rw-r--r-- | src/sql/drivers/odbc/qsql_odbc.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qsqlquery/tst_qsqlquery.cpp | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index d6423ae..2a83fe6 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -355,7 +355,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni } else { fieldVal += QString::fromAscii(buf, rSize); } - if (fieldVal.size() + lengthIndicator >= colSize) { + if (lengthIndicator - fieldVal.size() <= 0) { // workaround for Drivermanagers that don't return SQL_NO_DATA break; } diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 8d77589..074f16f 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -179,6 +179,10 @@ private slots: void task_217003(); #endif + void task_250026_data() { generic_data("QODBC"); } + void task_250026(); + + private: // returns all database connections void generic_data(const QString &engine=QString()); @@ -293,6 +297,7 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) #ifdef NOT_READY_YET tablenames << qTableName( "Planet" ); #endif + tablenames << qTableName( "task_250026" ); tst_Databases::safeDropTables( db, tablenames ); } @@ -2677,5 +2682,34 @@ void tst_QSqlQuery::task_217003() } #endif +void tst_QSqlQuery::task_250026() +{ + QString data258, data1026; + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + QSqlQuery q( db ); + + QString tableName = qTableName( "task_250026" ); + + if ( !q.exec( "create table " + tableName + " (longfield varchar(1100))" ) ) { + qDebug() << "Error" << q.lastError(); + QSKIP( "Db doesn't support \"1100\" as a size for fields", SkipSingle ); + } + + data258.fill( 'A', 258 ); + data1026.fill( 'A', 1026 ); + QVERIFY_SQL( q, prepare( "insert into " + tableName + "(longfield) VALUES (:longfield)" ) ); + q.bindValue( "longfield", data258 ); + QVERIFY_SQL( q, exec() ); + q.bindValue( "longfield", data1026 ); + QVERIFY_SQL( q, exec() ); + QVERIFY_SQL( q, exec( "select * from " + tableName ) ); + QVERIFY_SQL( q, next() ); + QCOMPARE( q.value( 0 ).toString().length(), data258.length() ); + QVERIFY_SQL( q, next() ); + QCOMPARE( q.value( 0 ).toString().length(), data1026.length() ); +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" |