summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorBill King <bking@trolltech.com>2009-10-13 01:57:05 (GMT)
committerBill King <bking@trolltech.com>2009-10-13 03:21:47 (GMT)
commitbee70a74465ef837b446ef2d2309a002da5bfe30 (patch)
tree00d7e1a34b92422c8f6e47161427b93f83e0f1c2 /src/sql
parentf613b0170d0fe806378779472315d0bbdc1aada9 (diff)
downloadQt-bee70a74465ef837b446ef2d2309a002da5bfe30.zip
Qt-bee70a74465ef837b446ef2d2309a002da5bfe30.tar.gz
Qt-bee70a74465ef837b446ef2d2309a002da5bfe30.tar.bz2
Fixes issue with multiple lookups to same table/field
Previously the renaming scheme created a new table_field alias name. If multiple references referred to the same table/field lookup, then multiples of the same alias would be generated in the query, leading the query to fail. Reviewed-by: Justin McPherson
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp
index aebecf1..5f0a35d 100644
--- a/src/sql/models/qsqlrelationaltablemodel.cpp
+++ b/src/sql/models/qsqlrelationaltablemodel.cpp
@@ -569,7 +569,8 @@ QString QSqlRelationalTableModel::selectStatement() const
QString displayColumn = relation.displayColumn();
if (d->db.driver()->isIdentifierEscaped(displayColumn, QSqlDriver::FieldName))
displayColumn = d->db.driver()->stripDelimiters(displayColumn, QSqlDriver::FieldName);
- fList.append(QString::fromLatin1(" AS %1_%2").arg(relTableName).arg(displayColumn));
+ fList.append(QString::fromLatin1(" AS %1_%2_%3").arg(relTableName).arg(displayColumn).arg(fieldNames.value(fieldList[i])));
+ fieldNames.insert(fieldList[i], fieldNames.value(fieldList[i])-1);
}
// this needs fixing!! the below if is borken.