diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 27e79cf3093..14643b6c088 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1462,7 +1462,10 @@ QSqlRecord QPSQLDriver::record(const QString &tablename) const template inline QString autoQuoteResult(QAnyStringView str) { - return forPreparedStatement ? str.toString() : (u'\'' + str.toString() + u'\''); + if constexpr (forPreparedStatement) + return str.toString(); + else + return u'\'' + str.toString() + u'\''; } template @@ -1512,8 +1515,8 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const break; } case QMetaType::QString: - if (forPreparedStatement) { - r = field.value().toString(); + if constexpr (forPreparedStatement) { + r = field.value().toString(); // there is no code path where trimStrings can be true here } else { r = QSqlDriver::formatValue(field, trimStrings); if (d->hasBackslashEscape)