@@ -35,6 +35,7 @@ QgsPgTableModel::QgsPgTableModel()
35
35
headerLabels << tr ( " SRID" );
36
36
headerLabels << tr ( " Feature id" );
37
37
headerLabels << tr ( " Select at id" );
38
+ headerLabels << tr ( " Check pk unicity" );
38
39
headerLabels << tr ( " Sql" );
39
40
setHorizontalHeaderLabels ( headerLabels );
40
41
}
@@ -122,6 +123,11 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper
122
123
selItem->setCheckState ( Qt::Checked );
123
124
selItem->setToolTip ( tr ( " Disable 'Fast Access to Features at ID' capability to force keeping the attribute table in memory (e.g. in case of expensive views)." ) );
124
125
126
+ QStandardItem *checkPkUnicityItem = new QStandardItem ( QString () );
127
+ checkPkUnicityItem->setFlags ( checkPkUnicityItem->flags () | Qt::ItemIsUserCheckable );
128
+ checkPkUnicityItem->setCheckState ( Qt::Unchecked );
129
+ checkPkUnicityItem->setToolTip ( tr ( " Enable check for primary key unicity when loading the features. This may slow down loading for large tables." ) );
130
+
125
131
QStandardItem *sqlItem = new QStandardItem ( layerProperty.sql );
126
132
127
133
QList<QStandardItem *> childItemList;
@@ -135,6 +141,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper
135
141
childItemList << sridItem;
136
142
childItemList << pkItem;
137
143
childItemList << selItem;
144
+ childItemList << checkPkUnicityItem;
138
145
childItemList << sqlItem;
139
146
140
147
const auto constChildItemList = childItemList;
@@ -375,6 +382,7 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &conn
375
382
376
383
bool selectAtId = itemFromIndex ( index.sibling ( index.row (), DbtmSelectAtId ) )->checkState () == Qt::Checked;
377
384
QString sql = index.sibling ( index.row (), DbtmSql ).data ( Qt::DisplayRole ).toString ();
385
+ bool checkPkUnicity = itemFromIndex ( index.sibling ( index.row (), DbtmCheckPkUnicity ) )->checkState () == Qt::Checked;
378
386
379
387
QgsDataSourceUri uri ( connInfo );
380
388
@@ -392,6 +400,7 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &conn
392
400
uri.setWkbType ( wkbType );
393
401
uri.setSrid ( srid );
394
402
uri.disableSelectAtId ( !selectAtId );
403
+ uri.setParam ( QStringLiteral ( " checkPrimaryKeyUnicity" ), QString ( checkPkUnicity ) );
395
404
396
405
QgsDebugMsg ( QStringLiteral ( " returning uri %1" ).arg ( uri.uri ( false ) ) );
397
406
return uri.uri ( false );
0 commit comments