Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QSqlquery size returns -1 when forwardOnly is enabled
Kiruahxh last edited by Kiruahxh
With a postgres database on linux with QPSQL driver, I cannot retrieve the number of results of a query with "size()" method, it always returns -1.
bool hasSupport = QSqlDatabase::database().driver()->hasFeature(QSqlDriver::QuerySize); QSqlQuery query; query.setForwardOnly(true); // this prevents from getting nbRows query.exec("select 123"); int nbRows = query.size(); query.first(); int val = query.value(0).toInt(); "hasSupport => true" "nbRows => -1" "val => 123"
I guess that when using QPSQL driver, setForwardOnly() is incompatible with size()?
I didn't see it documented anywhere
ForwardOnly queries can't return the complete query size.