Skip to content

Commit a261a06

Browse files
troopa81nyalldawson
authored andcommittedMay 28, 2020
Fixes #34982 : set sql filter on the right row for postgres datasource
1 parent 97e0651 commit a261a06

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎src/providers/postgres/qgspgtablemodel.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
249249
QModelIndex schemaSibling = index.sibling( index.row(), DbtmSchema );
250250
QModelIndex tableSibling = index.sibling( index.row(), DbtmTable );
251251
QModelIndex geomSibling = index.sibling( index.row(), DbtmGeomCol );
252+
QModelIndex geomTypeSibling = index.sibling( index.row(), DbtmType );
252253

253254
if ( !schemaSibling.isValid() || !tableSibling.isValid() || !geomSibling.isValid() )
254255
{
@@ -258,6 +259,7 @@ void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
258259
QString schemaName = itemFromIndex( schemaSibling )->text();
259260
QString tableName = itemFromIndex( tableSibling )->text();
260261
QString geomName = itemFromIndex( geomSibling )->text();
262+
QString geomType = itemFromIndex( geomTypeSibling )->text();
261263

262264
QList<QStandardItem *> schemaItems = findItems( schemaName, Qt::MatchExactly, DbtmSchema );
263265
if ( schemaItems.empty() )
@@ -288,7 +290,15 @@ void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
288290
continue;
289291
}
290292

291-
if ( itemFromIndex( currentTableIndex )->text() == tableName && itemFromIndex( currentGeomIndex )->text() == geomName )
293+
QModelIndex currentGeomType = currentChildIndex.sibling( i, DbtmType );
294+
if ( !currentGeomType.isValid() )
295+
{
296+
continue;
297+
}
298+
299+
if ( itemFromIndex( currentTableIndex )->text() == tableName
300+
&& itemFromIndex( currentGeomIndex )->text() == geomName
301+
&& itemFromIndex( currentGeomType )->text() == geomType )
292302
{
293303
QModelIndex sqlIndex = currentChildIndex.sibling( i, DbtmSql );
294304
if ( sqlIndex.isValid() )

0 commit comments

Comments
 (0)
Please sign in to comment.