diff options
author | DaNiMoTh <jjdanimoth@gmail.com> | 2011-07-19 14:57:07 +1000 |
---|---|---|
committer | Charles Yin <charles.yin@nokia.com> | 2011-07-19 14:57:07 +1000 |
commit | c4280dbd9bb37cca21d007f5f8b9217f80b44043 (patch) | |
tree | ca35cfc7b1dde96027df56afa5d157ad540f7d0a /src/sql/models/qsqlrelationaltablemodel.h | |
parent | 2b13b3d367cb6cda48ab9183d9ad5b2eee09e129 (diff) | |
download | qt4-tools-c4280dbd9bb37cca21d007f5f8b9217f80b44043.tar.gz |
Fixed behavior on NULL foreign keys
Instead of using a simple INNER JOIN, like:
SELECT a,b,rel.c FROM table1, table2 WHERE (table1.smthing =
table2.smthing)
which doesn't show row where foreign keys are NULL, allow use of LEFT
JOIN like:
SELECT a,b,rel.c FROM table1 LEFT JOIN table2 ON table1.smthing =
table2.smthing
The trick works also for multi-relational tables.
Just remember to use the new API setJoinMode.
Signed-off-by: DaNiMoTh <jjdanimoth@gmail.com>
Change-Id: I349f9418e4859923977942add59872b000cac2c5
Task-number:QTBUG-8217
Reviewed-by:Michael Goddard
Reviewed-by:Charles Yin
Merge-request: 2576
Reviewed-by: Charles Yin <charles.yin@nokia.com>
Diffstat (limited to 'src/sql/models/qsqlrelationaltablemodel.h')
-rw-r--r-- | src/sql/models/qsqlrelationaltablemodel.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sql/models/qsqlrelationaltablemodel.h b/src/sql/models/qsqlrelationaltablemodel.h index 15faae9b57..32d88b3189 100644 --- a/src/sql/models/qsqlrelationaltablemodel.h +++ b/src/sql/models/qsqlrelationaltablemodel.h @@ -76,6 +76,11 @@ class Q_SQL_EXPORT QSqlRelationalTableModel: public QSqlTableModel Q_OBJECT public: + enum JoinMode { + InnerJoin, + LeftJoin + }; + explicit QSqlRelationalTableModel(QObject *parent = 0, QSqlDatabase db = QSqlDatabase()); virtual ~QSqlRelationalTableModel(); @@ -91,6 +96,7 @@ public: virtual void setRelation(int column, const QSqlRelation &relation); QSqlRelation relation(int column) const; virtual QSqlTableModel *relationModel(int column) const; + void setJoinMode( QSqlRelationalTableModel::JoinMode joinMode ); public Q_SLOTS: void revertRow(int row); |