SQL/PSQL: slight improvement in code

added a details about code paths that cannot happen and added constexpr

Fixes: QTBUG-132303
Change-Id: I98340c5a1f275c00aafb3294cf8e5e8368126b76
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit e574cda7fc3f6be5a81489d8d9cdb859625d4e88)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thierry Bastian 2025-01-27 08:25:55 +01:00 committed by Qt Cherry-pick Bot
parent d7736416e8
commit 779e5faf1d

View File

@ -1455,7 +1455,10 @@ QSqlRecord QPSQLDriver::record(const QString &tablename) const
template <bool forPreparedStatement>
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 <bool forPreparedStatement, class FloatType>
@ -1505,8 +1508,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)