From 47de2ef27f9d68d5c1f2f935380e1517f99c9721 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 21 Dec 2016 14:02:14 +0100 Subject: QOCIDriver: Ensure the where clause is correctly setup Commit 88e043a8 introduced two bugs: 1. When constructing the WHERE clause, the closing ' around the owner name was dropped. 2. When constructing QLatin1Strings for comparison with system owners, a size of -1 was passed, with the comment "force strlen call". But, unlike QString, QLatin1String does not invoke strlen(), but stores the negative length unchanged, making the comparisons always fail. Change-Id: Ie2835b76877c31ee32c900f67eb0853df7110dbb Reviewed-by: Marc Mutz --- src/plugins/sqldrivers/oci/qsql_oci.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins/sqldrivers/oci/qsql_oci.cpp') diff --git a/src/plugins/sqldrivers/oci/qsql_oci.cpp b/src/plugins/sqldrivers/oci/qsql_oci.cpp index 47d6db7ea4..32d3681a17 100644 --- a/src/plugins/sqldrivers/oci/qsql_oci.cpp +++ b/src/plugins/sqldrivers/oci/qsql_oci.cpp @@ -2405,16 +2405,16 @@ static QString make_where_clause(const QString &user, Expression e) static const char joinC[][4] = { "or" , "and" }; static Q_CONSTEXPR QLatin1Char bang[] = { QLatin1Char(' '), QLatin1Char('!') }; - const QLatin1String join(joinC[e], -1); // -1: force strlen call + const QLatin1String join(joinC[e]); QString result; result.reserve(sizeof sysUsers / sizeof *sysUsers * // max-sizeof(owner != and ) (9 + sizeof *sysUsers + 5)); for (const auto &sysUser : sysUsers) { - const QLatin1String l1(sysUser, -1); // -1: force strlen call + const QLatin1String l1(sysUser); if (l1 != user) - result += QLatin1String("owner ") + bang[e] + QLatin1String("= '") + l1 + QLatin1Char(' ') + join + QLatin1Char(' '); + result += QLatin1String("owner ") + bang[e] + QLatin1String("= '") + l1 + QLatin1String("' ") + join + QLatin1Char(' '); } result.chop(join.size() + 2); // remove final " " -- cgit v1.2.3