Skip to content
Permalink
Browse files

[expression] fix caching for aggregate() and @parent exp. (fixes #15797)

  • Loading branch information
nirvn committed Sep 18, 2017
1 parent d2d9de8 commit c19fb1ca0ca03e7f04734af038aefc8b18834065
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/core/expression/qgsexpressionfunction.cpp
@@ -504,16 +504,20 @@ static QVariant fcnAggregate( const QVariantList &values, const QgsExpressionCon
QVariant result;
if ( context )
{
QString cacheKey = QStringLiteral( "aggfcn:%1:%2:%3:%4" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.filter );

QString cacheKey;
QgsExpression subExp( subExpression );
QgsExpression filterExp( parameters.filter );
if ( filterExp.referencedVariables().contains( "parent" )
|| filterExp.referencedVariables().contains( QString() )
|| subExp.referencedVariables().contains( "parent" )
|| subExp.referencedVariables().contains( QString() ) )
{
cacheKey += ':' + qHash( context->feature() );
cacheKey = QStringLiteral( "aggfcn:%1:%2:%3:%4:%5%6" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.filter,
QString::number( context->feature().id() ), QString( qHash( context->feature() ) ) );
}
else
{
cacheKey = QStringLiteral( "aggfcn:%1:%2:%3:%4" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.filter );
}

if ( context && context->hasCachedValue( cacheKey ) )

0 comments on commit c19fb1c

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