Hello,
I have a QSqlQuery where query.isValid = false and query.size() = 0, but I can't figure out why. It was working fine a couple weeks ago (famous last words). I have checked and confirmed the following:

-DB is open.
-query.exec() = true
-query.lastError() = QSqlError("", "", "")
-SQL syntax is valid (query works fine and returns results when output with qDebug() and run in Sequel Pro; also changing or simplifying the query doesn't affect anything)
-There is data to be returned, so it is not that the query has no results (see above)

Qt Code:
  1. QString orderID = appInfo->orderID;
  2.  
  3. QString queryString = "SELECT order_item.qty_ordered, order_item.sku, order_item.name, order_item.price FROM order_item JOIN order ON order_item.order_id = order.entity_id WHERE order_item.qty_ordered > 0 AND order.increment_id = '" + orderID + "';";
  4.  
  5. QSqlQuery query(queryString, QSqlDatabase::database("gx_db")); // I have multiple DBs connected, just specifying which one here
  6.  
  7. while(query.next()) {
  8. qDebug() << "Why isn't this showing up??";
  9. QJsonObject obj;
  10. obj.insert("qty", query.value("qty_ordered").toString());
  11. obj.insert("sku", query.value("sku").toString());
  12. obj.insert("description", query.value("name").toString());
  13. obj.insert("salePrice", query.value("price").toString());
  14.  
  15. array.append(obj);
  16. }
To copy to clipboard, switch view to plain text mode 

Any ideas? I'm stumped.