mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
V8 API: 2nd OR on same field gives only results for 2nd filter #4842
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#4842
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ebogaard on GitHub (Aug 30, 2022).
Issue
Expected Behavior
When using an OR more than once on the same field, you expect to get results that satisfy both filters.
For example: /V8/module/Accounts?filter[name][eq]=A&filter[operator]=or&filter[name][eq]=B
Should give all Accounts with name A or B.
Actual Behavior
When using this filter, we only get Accounts that satisfy the second filter. The first filter seems to be ignored.
When using an OR on two separate fields, the OR operator works as expected and gives results that satisfy both fitlers.
Possible Fix
n/a
Steps to Reproduce
Context
Your Environment
@serfreeman1337 commented on GitHub (Aug 31, 2022):
Quick fix to allow array values for requests:
Api/V8/module/Accounts?filter[operator]=or&filter[name][eq][]=A&filter[name][eq][]=B(note the [])
@ebogaard commented on GitHub (Sep 1, 2022):
Ah, thanks. So this is just an omission in the documentation, not a functional issue.
@serfreeman1337 commented on GitHub (Sep 1, 2022):
Current API filter design doesn't allow to specify same key name twice.
Proposed quick fix should at least allow that, but it's not official and any such changes to files migh be overriten during suitecrm update.
@ebogaard commented on GitHub (Sep 1, 2022):
Sorry, didn't read that correctly. Didn't see a patch is necessary. Seems like a proper way to fix this, though.
@SuiteBot commented on GitHub (Sep 2, 2022):
This issue has been mentioned on SuiteCRM. There might be relevant details there:
https://community.suitecrm.com/t/retrieve-api-v8-data-with-or-and-and-operator/86149/2
@TwizzX17 commented on GitHub (Nov 9, 2023):
Since the link to the previous proposed solution doesn't work anymore, have i tried to recreate the solution from the description:
Api/V8/JsonApi/Repository/Filter.php:75
I've added code to the parseWhere function, into the original foreach loop of $expres, to handle it a different way, if the $value is of type array. Whether this is the correct solution for the project, am i not sure of, but if anyone else needs a quick fix for this issue, then here is an example.
As described earlier in this thread - design your params with empty brackets like this:
(note the [])