From 5a334b3d2bc20c9d11cc95b17bdef1d096064a7b Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 28 Mar 2023 19:15:23 +0200 Subject: [PATCH] SQL/tests: Add testcase for QODBC toSQLTCHAR() Add a testcase for toSQLTCHAR() to make sure to pass the correct number of encoded characters to the odbc functions. Pick-to: 6.5 Task-number: QTBUG-112375 Change-Id: Ib67fab678fc3d0b098aedfc6fa9ec2139f2e75c7 Reviewed-by: Marc Mutz --- .../sql/kernel/qsqlquery/tst_qsqlquery.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 431c2f6f92..5c0f28e14b 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -240,6 +240,9 @@ private slots: void QTBUG_73286_data() { generic_data("QODBC"); } void QTBUG_73286(); + void insertVarChar1_data() { generic_data("QODBC"); } + void insertVarChar1(); + void dateTime_data(); void dateTime(); @@ -4717,6 +4720,22 @@ void tst_QSqlQuery::QTBUG_73286() QCOMPARE(q.value(2).toString(), "12345678901234567.890"); } +void tst_QSqlQuery::insertVarChar1() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + TableScope ts(db, "testtable", __FILE__); + QVERIFY_SQL(q, exec(QLatin1String("CREATE TABLE %1 (smallcol VARCHAR(1))").arg(ts.tableName()))); + QVERIFY_SQL(q, prepare(QLatin1String("INSERT INTO %1 (smallcol) VALUES (?)").arg(ts.tableName()))); + QSqlField smallCol("smallcol"); + smallCol.setValue(QVariant(QString(QChar('F')))); + q.bindValue(0, smallCol.value()); + QVERIFY_SQL(q, exec()); +} + void tst_QSqlQuery::dateTime_data() { if (dbs.dbNames.isEmpty())