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 <marc.mutz@kdab.com>
This commit is contained in:
parent
af5c8d04fb
commit
47de2ef27f
@ -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 != <sysuser> 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 " <join> "
|
||||
|
Loading…
x
Reference in New Issue
Block a user