Skip to content
Permalink
Browse files

Fix expression and wrap field filters in parentheses

  • Loading branch information
suricactus committed Sep 9, 2020
1 parent c4b2a74 commit 54a4dd5fd48ae87960ae92db5d2ecb2370bb4856
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/gui/editorwidgets/qgsrelationreferencewidget.cpp
@@ -922,8 +922,11 @@ void QgsRelationReferenceWidget::filterChanged()

QString expression = filterExpression;
if ( ! filterExpression.isEmpty() && ! filtersAttrs.values().isEmpty() )
filterExpression = QStringLiteral( " AND " );
expression += QStringLiteral( " AND " );

expression += filtersAttrs.isEmpty() ? QString() : QStringLiteral( " ( " );
expression += filtersAttrs.values().join( QStringLiteral( " AND " ) );
expression += filtersAttrs.isEmpty() ? QString() : QStringLiteral( " ) " );

subset << mReferencedLayer->fields().lookupField( fieldName );

@@ -957,7 +960,9 @@ void QgsRelationReferenceWidget::filterChanged()
if ( ! filterExpression.isEmpty() && ! filters.values().isEmpty() )
filterExpression += QStringLiteral( " AND " );

filterExpression += filters.isEmpty() ? QString() : QStringLiteral( " ( " );
filterExpression += filters.values().join( QStringLiteral( " AND " ) );
filterExpression += filters.isEmpty() ? QString() : QStringLiteral( " ) " );

mComboBox->setFilterExpression( filterExpression );
}

0 comments on commit 54a4dd5

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