Skip to content

Commit

Permalink
QSqlDriver:sqlStatement: respect generated flags for WHERE too
Browse files Browse the repository at this point in the history
Change-Id: I90034cd1a8dc0473c36d788c6737493a51641b02
Reviewed-by: Andy Shaw <[email protected]>
  • Loading branch information
mabrand committed Feb 24, 2016
1 parent c568770 commit 3ca2eea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sql/kernel/qsqldriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ QString QSqlDriver::stripDelimiters(const QString &identifier, IdentifierType ty
with the values from \a rec. If \a preparedStatement is true, the
string will contain placeholders instead of values.
The generated flag in each field of \a rec determines whether the
field is included in the generated statement.
This method can be used to manipulate tables without having to worry
about database-dependent SQL dialects. For non-prepared statements,
the values will be properly escaped.
Expand Down Expand Up @@ -493,7 +496,9 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
? QString()
: prepareIdentifier(tableName, QSqlDriver::TableName, this) + QLatin1Char('.');
for (int i = 0; i < rec.count(); ++i) {
s.append(QLatin1String(i? " AND " : "WHERE "));
if (!rec.isGenerated(i))
continue;
s.append(s.isEmpty() ? QLatin1String("WHERE ") : QLatin1String(" AND "));
s.append(tableNamePrefix);
s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this));
if (rec.isNull(i))
Expand Down

0 comments on commit 3ca2eea

Please sign in to comment.