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 <marc.mutz@qt.io>
This commit is contained in:
Christian Ehrlicher 2023-03-28 19:15:23 +02:00
parent 2f709952cf
commit 5a334b3d2b

View File

@ -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())