Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.2.0
-
None
-
-
3983babd7 (dev)
Description
You have some prepared SQL statement and calling "QSqlQuery::last(executed)Query()" does not return the actual "live" SQL statement (with bound values applied).
In Qt 5 there was a way to re-create the actual SQL statement sent to server:
QString DatabaseFactory::lastExecutedQuery(const QSqlQuery& query) { QString str = query.lastQuery(); QMapIterator<QString, QVariant> it(query.boundValues()); while (it.hasNext()) { it.next(); if (it.value().type() == QVariant::Type::Char || it.value().type() == QVariant::Type::String) { str.replace(it.key(), QSL("'%1'").arg(it.value().toString())); } else { str.replace(it.key(), it.value().toString()); } } return str; }
In Qt 6 this is impossible as "boundValues" is not a map anymore.
How to do the same method with Qt 6?? There is no way to my knowledge.