-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: any rule not accounting for empty filter #4051
fix: any rule not accounting for empty filter #4051
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller
Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged No assets were unchanged |
@douugdev just curious - I started looking at this one but couldn't track it down on time. Mind me asking how you narrowed the issue down to being inside |
Sure, it was a real rabbit hole! I realized when the default It worked. But it was probably lots of places to change and it wouldn't fix the root problem if someone else created another query elsewhere. So I just logged the generated SQL (after understanding how it was generated by actual, pretty clever btw!) when changing the Without the fix, this was the generated where clause for a filter with the clauses "cleared == true && amount < 0" WHERE ((v_transactions_internal_alive.cleared = 1
AND v_transactions_internal_alive.amount < 0)
AND (CAST(SUBSTR(v_transactions_internal_alive.date, 1, 6) AS integer) >= 202406
AND CAST(SUBSTR(v_transactions_internal_alive.date, 1, 6) AS integer) <= 202412)
AND v_transactions_internal_alive.amount < 0) and this was for the clauses "cleared == true || amount < 0" WHERE ((v_transactions_internal_alive.cleared = 1
OR v_transactions_internal_alive.amount < 0)
AND (CAST(SUBSTR(v_transactions_internal_alive.date, 1, 6) AS integer) >= 202406
AND CAST(SUBSTR(v_transactions_internal_alive.date, 1, 6) AS integer) <= 202412)
AND v_transactions_internal_alive.amount < 0) All fine here. But when deleting the clauses: WHERE (0
AND (CAST(SUBSTR(v_transactions_internal_alive.date, 1, 6) AS integer) >= 202406
AND CAST(SUBSTR(v_transactions_internal_alive.date, 1, 6) AS integer) <= 202412)
AND v_transactions_internal_alive.amount < 0) Suddenly there is a 0 in there, and These are the functions that handle the generating OR and AND operators: With this being the part of the "compileConditions" function that chooses which function to use: At last I saw that instead of the object being passed being And the condition So backtracking a bit: first the So the final compiled WHERE was: (0 AND ... AND ...) which never finds anything. Thanks for coming to my ted talk! |
@douugdev holy crap I did not expect it to be that complicated! Thanks for walking me through that. |
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
packages/loot-core/src/server/aql/compiler.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-eslint-plugin". (The package "eslint-plugin-eslint-plugin" was not found when loaded as a Node module from the directory "/packages/eslint-plugin-actual".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-eslint-plugin" was referenced from the config file in "packages/eslint-plugin-actual/.eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. WalkthroughThe pull request introduces a modification in the Assessment against linked issues
The assessment reveals that while the code change modifies the condition compilation logic, there is insufficient evidence to conclusively link it to the specific bug reported in issue #3982. The changes appear to be more related to internal compiler logic rather than directly addressing the filter and summary value issues described in the bug report. Further investigation or additional context would be needed to establish a direct connection. 📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🔇 Additional comments (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, looks like quite the debugging rabbit hole
Fixes #3982, that bug didn't only occur in the summary report, it also ocurred everywhere where there are filters that allow you to switch from "all" to "any" clauses.
For example in custom reports:
When you started filtering, switched to the "any" clause and then removed the conditions, the report would "crash" and never display any value because the compiler was inserting a
AND 0
statement in theWHERE
condition of the SQL. See:https://github.com/user-attachments/assets/6e02f703-bb52-4b0c-88a3-ffe2c7e66a43
The bug was in the condition not accounting for empty arrays, it checked
if(!cond)
but if an empty array was passed, it was seem as a truthy value, because, for some reason,!![]
is a truthy value in JavaScript 🤷.After the fix:
https://github.com/user-attachments/assets/3d656330-3c6f-4243-a961-ad4f92aa5343