Doc: Fix coverity warnings in SQL snippets
Fixes: QTBUG-83008 Change-Id: I126bc04719cd221a3d80ae825fca44e63aeec934 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
This commit is contained in:
parent
f22c929c8a
commit
3f3e200aef
@ -60,8 +60,8 @@ void testProc()
|
||||
QSqlQuery q;
|
||||
q.exec("call qtestproc (@outval1, @outval2)");
|
||||
q.exec("select @outval1, @outval2");
|
||||
q.next();
|
||||
qDebug() << q.value(0) << q.value(1); // outputs "42" and "43"
|
||||
if (q.next())
|
||||
qDebug() << q.value(0) << q.value(1); // outputs "42" and "43"
|
||||
//! [2]
|
||||
}
|
||||
|
||||
@ -87,7 +87,8 @@ db.setDatabaseName("C:\\test.gdb");
|
||||
//! [25]
|
||||
// connect to database using the Latin-1 character set
|
||||
db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1");
|
||||
db.open();
|
||||
if (db.open())
|
||||
qDebug("The database connection is open.");
|
||||
//! [25]
|
||||
}
|
||||
|
||||
@ -96,8 +97,8 @@ void exProc()
|
||||
//! [26]
|
||||
QSqlQuery q;
|
||||
q.exec("execute procedure my_procedure");
|
||||
q.next();
|
||||
qDebug() << q.value(0); // outputs the first RETURN/OUT value
|
||||
if (q.next())
|
||||
qDebug() << q.value(0); // outputs the first RETURN/OUT value
|
||||
//! [26]
|
||||
|
||||
qDebug( \
|
||||
|
@ -207,7 +207,7 @@ void QSqlQuery_snippets()
|
||||
QMap<QString, QVariant> sqlIterator(query.boundValues());
|
||||
for (auto i = sqlIterator.begin(); i != sqlIterator.end(); ++i) {
|
||||
cout << i.key().toUtf8().data() << ": "
|
||||
<< i.value().toString().toUtf8().data() << Qt::endl;
|
||||
<< i.value().toString().toUtf8().data() << "\n";
|
||||
}
|
||||
//! [14]
|
||||
}
|
||||
@ -217,7 +217,7 @@ void QSqlQuery_snippets()
|
||||
//! [15]
|
||||
QList<QVariant> list = query.boundValues().values();
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
cout << i << ": " << list.at(i).toString().toUtf8().data() << Qt::endl;
|
||||
cout << i << ": " << list.at(i).toString().toUtf8().data() << "\n";
|
||||
//! [15]
|
||||
}
|
||||
}
|
||||
@ -274,6 +274,7 @@ void QSqlTableModel_snippets()
|
||||
model.select();
|
||||
int salary = model.record(4).value("salary").toInt();
|
||||
//! [25]
|
||||
Q_UNUSED(salary);
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,7 +515,7 @@ public:
|
||||
const QString & /* password */, const QString & /* host */,
|
||||
int /* port */, const QString & /* options */) override
|
||||
{ return false; }
|
||||
void close() {}
|
||||
void close() override {}
|
||||
QSqlResult *createResult() const override { return new XyzResult(this); }
|
||||
};
|
||||
//! [48]
|
||||
|
Loading…
Reference in New Issue
Block a user