summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql/kernel
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-02-09 12:01:46 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-02-15 17:32:47 +0100
commite5ba8380457f823f5bd4a475ffb808b3c5b9dd42 (patch)
tree1c340c8ba6ffa56af69a1442fb37809c10b34cd6 /tests/auto/sql/kernel
parent1013cf49c70507f4c75789347f13ed06aa4eae28 (diff)
tst_qsqlquery coding style: use braces correctly
Single-line bodies of single-line controls don't need braces. If one block of an if/else chain needs braces, the rest get them too. One long condition needed a split that forced its body to need braces. Change-Id: Ic4116b1273e16a586fdec18e6d8228e48a9cb07c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'tests/auto/sql/kernel')
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 05e2bde4af..35cc57562c 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -1192,10 +1192,9 @@ void tst_QSqlQuery::numRowsAffected()
if ( q.numRowsAffected() == -1 || q.numRowsAffected() == 0 )
QSKIP("Database doesn't support numRowsAffected");
- if ( q.numRowsAffected() != -1 && q.numRowsAffected() != 0 && q.numRowsAffected() != i ) {
- // the value is undefined for SELECT, this check is just here for curiosity
+ // Value is undefined for SELECT, this check is just here for curiosity:
+ if (q.numRowsAffected() != -1 && q.numRowsAffected() != 0 && q.numRowsAffected() != i)
qDebug( "Expected numRowsAffected to be -1, 0 or %d, got %d", i, q.numRowsAffected() );
- }
QVERIFY_SQL( q, exec( "update " + qtest + " set id = 100 where id = 1" ) );
@@ -2082,8 +2081,9 @@ void tst_QSqlQuery::transaction()
if (dbType == QSqlDriver::MySqlServer) {
qDebug( "MySQL: %s", qPrintable(tst_Databases::printError( q.lastError() ) ));
QSKIP( "MySQL transaction failed "); //non-fatal
- } else
+ } else {
QFAIL( "Could not rollback transaction: " + tst_Databases::printError( q.lastError() ) );
+ }
}
QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 41" ) );
@@ -2121,10 +2121,10 @@ void tst_QSqlQuery::joins()
const QString qtestj1(qTableName("qtestj1", __FILE__, db)), qtestj2(qTableName("qtestj2", __FILE__, db));
if (dbType == QSqlDriver::Oracle || dbType == QSqlDriver::Sybase
- || dbType == QSqlDriver::Interbase || db.driverName().startsWith("QODBC"))
- // Oracle broken beyond recognition - cannot outer join on more than
- // one table.
+ || dbType == QSqlDriver::Interbase || db.driverName().startsWith("QODBC")) {
+ // Oracle broken beyond recognition - cannot outer join on more than one table:
QSKIP( "DBMS cannot understand standard SQL");
+ }
QSqlQuery q( db );
@@ -3104,8 +3104,9 @@ void tst_QSqlQuery::createQueryOnClosedDatabase()
// Only supported by these drivers
if (dbType != QSqlDriver::PostgreSQL && dbType != QSqlDriver::Oracle
- && dbType != QSqlDriver::MySqlServer && dbType != QSqlDriver::DB2)
+ && dbType != QSqlDriver::MySqlServer && dbType != QSqlDriver::DB2) {
QSKIP( "Test is specific for PostgreSQL, Oracle, MySql and DB2");
+ }
db.close();
@@ -3469,8 +3470,10 @@ void tst_QSqlQuery::blobsPreparedQuery()
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- if ( !db.driver()->hasFeature( QSqlDriver::BLOB ) || !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) )
+ if (!db.driver()->hasFeature(QSqlDriver::BLOB)
+ || !db.driver()->hasFeature(QSqlDriver::PreparedQueries)) {
QSKIP( "DBMS does not support BLOBs or prepared queries");
+ }
const QString tableName(qTableName("blobstest", __FILE__, db));
@@ -4576,9 +4579,8 @@ void tst_QSqlQuery::aggregateFunctionTypes()
QString field = "id";
// PSQL does not have the round() function with real type
- if (dbType == QSqlDriver::PostgreSQL) {
+ if (dbType == QSqlDriver::PostgreSQL)
field += "::NUMERIC";
- }
QVERIFY_SQL(q, exec("SELECT ROUND(" + field + ", 1) FROM " + tableName + " WHERE id=1.5"));
QVERIFY(q.next());