Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/sql/include/qx/sql/__private/qx-sqlstring_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,28 @@ void appendKeywordParen(QString& str, const QString& word, const R& range)
* we rely on the SqlString ctor to reliably get a string from value_type.
*/

/* NOTE: With current implementation it is up to the caller to ensure that the elements
* in 'range' end up quoted as required (or of a type that automatically quotes them
* during construction).
/* TODO: This is a bit of a hack. We manually quote when the contained type of R is QString
* based. This works, but there is an arugment to be made that the caller should be responsible
* for ensuring that everything is quoted as required (or is a type that auto quotes) ahead of
* time, and this may on occasion cause accidental double quoting.
*/
constexpr bool quote = std::constructible_from<QString, Qx::unwrap<R>>;
QString rStr;
if constexpr(quote)
rStr += u"'"_s;
for(auto n = std::size(range); const auto& value : range)
{
rStr += __private::qstring_compat(value);
if(n-- != 1)
rStr += u","_s;
{
if constexpr(quote)
rStr += u"','"_s;
else
rStr += u","_s;
}
}
if constexpr(quote)
rStr += u"'"_s;

appendKeywordParen(str, word, rStr);
}
Expand Down