Use QList instead of QVector in sql tests
Task-number: QTBUG-84469 Change-Id: Id429ce85da027541b53d516045a78b739c2e9745 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
fe5b04346c
commit
88cfcd7f3f
@ -2168,7 +2168,7 @@ void tst_QSqlQuery::prepare_bind_exec()
|
|||||||
|
|
||||||
/*** Below we test QSqlQuery::boundValues() with position arguments.
|
/*** Below we test QSqlQuery::boundValues() with position arguments.
|
||||||
* Due to the fact that the name of a positional argument is not
|
* Due to the fact that the name of a positional argument is not
|
||||||
* specified by the Qt docs, we test that the QVector contains
|
* specified by the Qt docs, we test that the QList contains
|
||||||
* the correct values in the same order as QSqlResult::boundValueName
|
* the correct values in the same order as QSqlResult::boundValueName
|
||||||
* returns since it should be in insertion order (i.e. field order). ***/
|
* returns since it should be in insertion order (i.e. field order). ***/
|
||||||
QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, ?)" ) );
|
QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, ?)" ) );
|
||||||
@ -4054,7 +4054,7 @@ void tst_QSqlQuery::QTBUG_36211()
|
|||||||
void tst_QSqlQuery::QTBUG_53969()
|
void tst_QSqlQuery::QTBUG_53969()
|
||||||
{
|
{
|
||||||
QFETCH( QString, dbName );
|
QFETCH( QString, dbName );
|
||||||
QVector<int> values = QVector<int>() << 10 << 20 << 127 << 128 << 1, tableValues;
|
QList<int> values = QList<int>() << 10 << 20 << 127 << 128 << 1, tableValues;
|
||||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||||
CHECK_DATABASE( db );
|
CHECK_DATABASE( db );
|
||||||
tableValues.reserve(values.size());
|
tableValues.reserve(values.size());
|
||||||
@ -4069,7 +4069,7 @@ void tst_QSqlQuery::QTBUG_53969()
|
|||||||
|
|
||||||
QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (test_number) VALUES (:value)"));
|
QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (test_number) VALUES (:value)"));
|
||||||
|
|
||||||
QVector<int>::iterator begin = values.begin(), end = values.end(), it;
|
QList<int>::iterator begin = values.begin(), end = values.end(), it;
|
||||||
for (it = begin; it != end; ++it) {
|
for (it = begin; it != end; ++it) {
|
||||||
q.bindValue(":value", *it);
|
q.bindValue(":value", *it);
|
||||||
QVERIFY_SQL(q, exec());
|
QVERIFY_SQL(q, exec());
|
||||||
@ -4416,11 +4416,10 @@ void tst_QSqlQuery::aggregateFunctionTypes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName,
|
void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QString &type,
|
||||||
const QString &type, bool withPreparedStatement,
|
bool withPreparedStatement, const QList<T> &values)
|
||||||
const QVector<T> &values)
|
|
||||||
{
|
{
|
||||||
QVector<QVariant> variantValues;
|
QList<QVariant> variantValues;
|
||||||
variantValues.reserve(values.size());
|
variantValues.reserve(values.size());
|
||||||
|
|
||||||
QSqlQuery q(db);
|
QSqlQuery q(db);
|
||||||
@ -4448,8 +4447,8 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName,
|
|||||||
} else {
|
} else {
|
||||||
QVERIFY_SQL(q, exec("SELECT id FROM " + tableName));
|
QVERIFY_SQL(q, exec("SELECT id FROM " + tableName));
|
||||||
}
|
}
|
||||||
QVector<T> actualValues;
|
QList<T> actualValues;
|
||||||
QVector<QVariant> actualVariantValues;
|
QList<QVariant> actualVariantValues;
|
||||||
actualValues.reserve(values.size());
|
actualValues.reserve(values.size());
|
||||||
while (q.next()) {
|
while (q.next()) {
|
||||||
QVariant value = q.value(0);
|
QVariant value = q.value(0);
|
||||||
@ -4472,7 +4471,7 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName,
|
|||||||
// insert some values
|
// insert some values
|
||||||
const int steps = 20;
|
const int steps = 20;
|
||||||
const T increment = (max / steps - min / steps);
|
const T increment = (max / steps - min / steps);
|
||||||
QVector<T> values;
|
QList<T> values;
|
||||||
values.reserve(steps);
|
values.reserve(steps);
|
||||||
T v = min;
|
T v = min;
|
||||||
for (int i = 0; i < steps; ++i, v += increment)
|
for (int i = 0; i < steps; ++i, v += increment)
|
||||||
@ -4486,7 +4485,7 @@ void tst_QSqlQuery::integralTypesMysql()
|
|||||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||||
CHECK_DATABASE(db);
|
CHECK_DATABASE(db);
|
||||||
|
|
||||||
const QVector<bool> boolValues = QVector<bool>() << false << true;
|
const QList<bool> boolValues = QList<bool>() << false << true;
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
const bool withPreparedStatement = (i == 1);
|
const bool withPreparedStatement = (i == 1);
|
||||||
runIntegralTypesMysqlTest<bool>(db, "tinyInt1Test", "TINYINT(1)", withPreparedStatement, boolValues);
|
runIntegralTypesMysqlTest<bool>(db, "tinyInt1Test", "TINYINT(1)", withPreparedStatement, boolValues);
|
||||||
|
@ -46,10 +46,7 @@ public:
|
|||||||
return QSqlResult::savePrepare(sqlquery);
|
return QSqlResult::savePrepare(sqlquery);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QVariant> boundValues() const
|
QList<QVariant> boundValues() const { return QSqlResult::boundValues(); }
|
||||||
{
|
|
||||||
return QSqlResult::boundValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant data(int /* index */) { return QVariant(); }
|
QVariant data(int /* index */) { return QVariant(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user