Skip to content
Permalink
Browse files

Fix @parent variable detection in aggregate subExpression

  • Loading branch information
m-kuhn committed Oct 31, 2016
1 parent 6d38765 commit cc6b1e33912be66d8dedafacab59332546c72527
Showing with 31 additions and 12 deletions.
  1. +31 −12 src/core/qgsexpression.cpp
@@ -3670,14 +3670,22 @@ const QList<QgsExpression::Function*>& QgsExpression::Functions()
if ( !node )
return true;

if ( !node->args() || node->args()->count() < 4 )
if ( !node->args() )
return false;
else

QSet<QString> referencedVars;
if ( node->args()->count() > 2 )
{
QgsExpression::Node* subExpressionNode = node->args()->at( 2 );
referencedVars = subExpressionNode->referencedVariables();
}

if ( node->args()->count() > 3 )
{
QgsExpression::Node* filterNode = node->args()->at( 3 );
QSet<QString> referencedVars = filterNode->referencedVariables();
return referencedVars.contains( "parent" ) || referencedVars.contains( QString() );
referencedVars = filterNode->referencedVariables();
}
return referencedVars.contains( "parent" ) || referencedVars.contains( QString() );
},
[]( const QgsExpression::NodeFunction* node )
{
@@ -3686,18 +3694,29 @@ const QList<QgsExpression::Function*>& QgsExpression::Functions()
if ( !node )
return QSet<QString>() << QgsFeatureRequest::AllAttributes;

if ( !node->args() || node->args()->count() < 4 )
if ( !node->args() )
return QSet<QString>();
else

QSet<QString> referencedCols;
QSet<QString> referencedVars;

if ( node->args()->count() > 2 )
{
QgsExpression::Node* subExpressionNode = node->args()->at( 2 );
referencedVars = subExpressionNode->referencedVariables();
referencedCols = subExpressionNode->referencedColumns();
}
if ( node->args()->count() > 3 )
{
QgsExpression::Node* filterNode = node->args()->at( 3 );
QSet<QString> referencedVars = filterNode->referencedVariables();

if ( referencedVars.contains( "parent" ) || referencedVars.contains( QString() ) )
return QSet<QString>() << QgsFeatureRequest::AllAttributes;
else
return QSet<QString>();
referencedVars = filterNode->referencedVariables();
referencedCols.unite( filterNode->referencedColumns() );
}

if ( referencedVars.contains( "parent" ) || referencedVars.contains( QString() ) )
return QSet<QString>() << QgsFeatureRequest::AllAttributes;
else
return referencedCols;
},
true
)

0 comments on commit cc6b1e3

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