summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHonglei Zhang <honglei.zhang@nokia.com>2011-12-02 09:32:51 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-30 19:50:50 +0200
commitfa9cf676159e8d9876c8532dc4e90f4bf5d9a47b (patch)
tree1242d1b9cb14840bd03ca049988bdc061b229104 /src
parentcb0b3fc34d0cd5837960cdee699a9c8584922825 (diff)
Update QSqlRelationalTableModel about reference table alias
The current documentation does not mention how the reference table name is aliased in the relational table model. This makes it difficult to use function setFilter(). This commit adds relevant information to the documentation. Task-number: QTBUG-15989 Change-Id: I02cbefb3f2b66c9772557a1fea3d93c2d1696ee9 Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src')
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp
index 0387e5691f..a3d45576ae 100644
--- a/src/sql/models/qsqlrelationaltablemodel.cpp
+++ b/src/sql/models/qsqlrelationaltablemodel.cpp
@@ -379,16 +379,21 @@ void QSqlRelationalTableModelPrivate::clearCache()
keys will not be exposed through the model. The user or the
database is responsible for keeping referential integrity.
\li If a relation's display column name is also used as a column
- name in the main table, or if it is used as display column
+ name in the relational table, or if it is used as display column
name in more than one relation it will be aliased. The alias is
- is the relation's table name and display column name joined
- by an underscore (e.g. tablename_columnname). All occurrences
- of the duplicate display column name are aliased when
+ the relation's table name, display column name and a unique id
+ joined by an underscore (e.g. tablename_columnname_id).
+ QSqlRecord::fieldName() will return the aliased column name.
+ All occurrences of the duplicate display column name are aliased when
duplication is detected, but no aliasing is done to the column
names in the main table. The aliasing doesn't affect
QSqlRelation, so QSqlRelation::displayColumn() will return the
- original display column name, but QSqlRecord::fieldName() will
- return aliases.
+ original display column name.
+ \li The reference table name is aliased. The alias is the word "relTblAl"
+ and the relationed column index joined by an underscore
+ (e.g. relTblAl_2). The alias can be used to filter the table
+ (For example, setFilter("relTblAl_2='Oslo' OR
+ relTblAl_3='USA'")).
\li When using setData() the role should always be Qt::EditRole,
and when using data() the role should always be Qt::DisplayRole.
\endlist