Skip to content

Commit 0b082fb

Browse files
committed
postgres provider fix: layers with incomplete geometry type/srid/pk data could not be selected for addition
1 parent 7b13a89 commit 0b082fb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/providers/postgres/qgspgtablemodel.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ void QgsPgTableModel::addTableEntry( QgsPostgresLayerProperty layerProperty )
9797
}
9898
else
9999
{
100-
pkCol = pkText = layerProperty.pkCols[0];
100+
if ( layerProperty.pkCols.size() > 1 )
101+
{
102+
pkText = tr( "Select..." );
103+
}
104+
105+
pkCol = layerProperty.pkCols[0];
101106
}
102107

103108
QStandardItem *pkItem = new QStandardItem( pkText );
@@ -323,9 +328,9 @@ bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, in
323328

324329
if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol )
325330
{
326-
QGis::GeometryType geomType = ( QGis::GeometryType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();
331+
QGis::WkbType geomType = ( QGis::WkbType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();
327332

328-
bool ok = geomType != QGis::UnknownGeometry;
333+
bool ok = geomType != QGis::WKBUnknown;
329334

330335
if ( ok && geomType != QGis::NoGeometry )
331336
idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok );

0 commit comments

Comments
 (0)