Skip to content

Commit 8318ce9

Browse files
committed
Don't quote as part of SQL range-based functions
This was leading to double quoting for some types. Now, we leave it to the caller to ensure that the values passed have the correct quoting alread applied.
1 parent 1d15649 commit 8318ce9

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/sql/include/qx/sql/__private/qx-sqlstring_helpers.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ void appendKeywordParen(QString& str, const QString& word, const R& range)
5656
/* The boxing here is inefficient, but I'm not sure how to improve the situation since
5757
* we rely on the SqlString ctor to reliably get a string from value_type.
5858
*/
59-
QString rStr = u"'"_s;
59+
60+
/* NOTE: With current implementation it is up to the caller to ensure that the elements
61+
* in 'range' end up quoted as required (or of a type that automatically quotes them
62+
* during construction).
63+
*/
64+
QString rStr;
6065
for(auto n = std::size(range); const auto& value : range)
6166
{
6267
rStr += __private::qstring_compat(value);
6368
if(n-- != 1)
64-
rStr += u"','"_s;
69+
rStr += u","_s;
6570
}
66-
rStr += u"'"_s;
6771

6872
appendKeywordParen(str, word, rStr);
6973
}

lib/sql/src/qx-sqlquery.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
/*!
132132
* @def QX_SQL_MEMBER_OVERRIDE()
133133
*
134-
* Used to define a member/field specific value parsing/serialzing override for a
134+
* Used to define a member/field specific value parsing/serializing override for a
135135
* SQL-tried struct. The specified member will be processed using the provided
136136
* functions instead of potentially available generic ones for that type.
137137
*
@@ -289,7 +289,7 @@ void SqlQuery::bindValue(const QString& placeholder, const QVariant& val) { mBin
289289
/*!
290290
* @fn Derived& AbstractSqlQuery::IN(const R& range)
291291
*
292-
* Adds an `IN` clause to the query using all of the elments from @a range.
292+
* Adds an `IN` clause to the query using all of the elements from @a range.
293293
*
294294
* If @a range is empty, the SQL statement will be ill-formed.
295295
*/

0 commit comments

Comments
 (0)