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:
parent
d7736416e8
commit
779e5faf1d
@ -1455,7 +1455,10 @@ QSqlRecord QPSQLDriver::record(const QString &tablename) const
|
|||||||
template <bool forPreparedStatement>
|
template <bool forPreparedStatement>
|
||||||
inline QString autoQuoteResult(QAnyStringView str)
|
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>
|
template <bool forPreparedStatement, class FloatType>
|
||||||
@ -1505,8 +1508,8 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QMetaType::QString:
|
case QMetaType::QString:
|
||||||
if (forPreparedStatement) {
|
if constexpr (forPreparedStatement) {
|
||||||
r = field.value().toString();
|
r = field.value().toString(); // there is no code path where trimStrings can be true here
|
||||||
} else {
|
} else {
|
||||||
r = QSqlDriver::formatValue(field, trimStrings);
|
r = QSqlDriver::formatValue(field, trimStrings);
|
||||||
if (d->hasBackslashEscape)
|
if (d->hasBackslashEscape)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user