summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2016-02-18 23:04:57 +0100
committerMark Brand <mabrand@mabrand.nl>2016-02-24 16:38:17 +0000
commit3ca2eea00d53ae1f75cead8dde763cb8e348d630 (patch)
tree0932e51b44adc2b0fdc5c67135bcf38f54f0f576 /src/sql
parentc5687704e9b1e3f67c6a095c86368b8dc9809629 (diff)
QSqlDriver:sqlStatement: respect generated flags for WHERE too
Change-Id: I90034cd1a8dc0473c36d788c6737493a51641b02 Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/kernel/qsqldriver.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index d53331fb10..ac51941f43 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -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.
@@ -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))