From: Honglei Zhang Date: Fri, 2 Dec 2011 07:32:51 +0000 (+0200) Subject: Update QSqlRelationalTableModel about reference table alias X-Git-Tag: 071012110112~1928 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa9cf676159e8d9876c8532dc4e90f4bf5d9a47b;p=profile%2Fivi%2Fqtbase.git 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 --- diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp index 0387e56..a3d4557 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