Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aggregate function returns incorrect results #59000

Merged
merged 2 commits into from
Oct 14, 2024

Conversation

nyalldawson
Copy link
Collaborator

When the aggregate uses variables, we need to ensure that the
cache key correctly considers the current value of ALL those
variables. Otherwise we'll return incorrect results when
an expression is re-evaluated after changing the variable
value for the context.

Fixes use of aggregate function with @symbol_label in legends.

Fixes #58221

(Possibly also fixes #58315, but untested)

@github-actions github-actions bot added this to the 3.40.0 milestone Oct 8, 2024
Copy link

github-actions bot commented Oct 8, 2024

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 8c70a83)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 8c70a83)

When the aggregate uses variables, we need to ensure that the
cache key correctly considers the current value of ALL those
variables. Otherwise we'll return incorrect results when
an expression is re-evaluated after changing the variable
value for the context.

Fixes use of aggregate function with @symbol_label in legends.

Fixes qgis#58221
src/core/qgsexpressioncontext.cpp Show resolved Hide resolved
src/core/qgsexpressioncontext.cpp Show resolved Hide resolved
src/core/qgsexpressioncontext.cpp Show resolved Hide resolved
@troopa81 troopa81 merged commit f618993 into qgis:master Oct 14, 2024
29 checks passed
@qgis-bot
Copy link
Collaborator

The backport to queued_ltr_backports failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply 7b88103128d... Fix aggregate function returns incorrect results
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

stdout
Auto-merging python/PyQt6/core/auto_generated/qgsexpressioncontext.sip.in
Auto-merging python/core/auto_generated/qgsexpressioncontext.sip.in
Auto-merging src/core/expression/qgsexpressionfunction.cpp
CONFLICT (content): Merge conflict in src/core/expression/qgsexpressionfunction.cpp
Auto-merging src/core/qgsexpressioncontext.cpp
Auto-merging src/core/qgsexpressioncontext.h
Auto-merging tests/src/core/testqgsexpression.cpp
Auto-merging tests/src/core/testqgsexpressioncontext.cpp

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-queued_ltr_backports queued_ltr_backports
# Navigate to the new working tree
cd .worktrees/backport-queued_ltr_backports
# Create a new branch
git switch --create backport-59000-to-queued_ltr_backports
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 7b88103128db0cc33c5718ad273ddf51cb192bf9,8c70a83935423fa9aac8ef37651b92de5192c128
# Push it to GitHub
git push --set-upstream origin backport-59000-to-queued_ltr_backports
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-queued_ltr_backports

Then, create a pull request where the base branch is queued_ltr_backports and the compare/head branch is backport-59000-to-queued_ltr_backports.

@qgis-bot qgis-bot added the failed backport The automated backport attempt failed, needs a manual backport label Oct 14, 2024
@nyalldawson nyalldawson deleted the aggregate_cache branch October 27, 2024 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport queued_ltr_backports Queued Backports failed backport The automated backport attempt failed, needs a manual backport
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in @Symbol_label using with aggregate function Legend expression issue
3 participants