Skip to content

Commit c19fb1c

Browse files
authoredSep 18, 2017
[expression] fix caching for aggregate() and @parent exp. (fixes #15797)
1 parent d2d9de8 commit c19fb1c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/core/expression/qgsexpressionfunction.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,16 +504,20 @@ static QVariant fcnAggregate( const QVariantList &values, const QgsExpressionCon
504504
QVariant result;
505505
if ( context )
506506
{
507-
QString cacheKey = QStringLiteral( "aggfcn:%1:%2:%3:%4" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.filter );
508-
507+
QString cacheKey;
509508
QgsExpression subExp( subExpression );
510509
QgsExpression filterExp( parameters.filter );
511510
if ( filterExp.referencedVariables().contains( "parent" )
512511
|| filterExp.referencedVariables().contains( QString() )
513512
|| subExp.referencedVariables().contains( "parent" )
514513
|| subExp.referencedVariables().contains( QString() ) )
515514
{
516-
cacheKey += ':' + qHash( context->feature() );
515+
cacheKey = QStringLiteral( "aggfcn:%1:%2:%3:%4:%5%6" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.filter,
516+
QString::number( context->feature().id() ), QString( qHash( context->feature() ) ) );
517+
}
518+
else
519+
{
520+
cacheKey = QStringLiteral( "aggfcn:%1:%2:%3:%4" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.filter );
517521
}
518522

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

0 commit comments

Comments
 (0)
Please sign in to comment.