Skip to content
Permalink
Browse files

Fixes #34982 : set sql filter on the right row for postgres datasource

  • Loading branch information
troopa81 authored and nyalldawson committed May 28, 2020
1 parent 97e0651 commit a261a069bd00320d10a3d8f8146fc88a07a43f9e
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/providers/postgres/qgspgtablemodel.cpp
@@ -249,6 +249,7 @@ void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
QModelIndex schemaSibling = index.sibling( index.row(), DbtmSchema );
QModelIndex tableSibling = index.sibling( index.row(), DbtmTable );
QModelIndex geomSibling = index.sibling( index.row(), DbtmGeomCol );
QModelIndex geomTypeSibling = index.sibling( index.row(), DbtmType );

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

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

if ( itemFromIndex( currentTableIndex )->text() == tableName && itemFromIndex( currentGeomIndex )->text() == geomName )
QModelIndex currentGeomType = currentChildIndex.sibling( i, DbtmType );
if ( !currentGeomType.isValid() )
{
continue;
}

if ( itemFromIndex( currentTableIndex )->text() == tableName
&& itemFromIndex( currentGeomIndex )->text() == geomName
&& itemFromIndex( currentGeomType )->text() == geomType )
{
QModelIndex sqlIndex = currentChildIndex.sibling( i, DbtmSql );
if ( sqlIndex.isValid() )

0 comments on commit a261a06

Please sign in to comment.
You can’t perform that action at this time.