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 IN filter with empty array #7202

Merged
merged 2 commits into from
Sep 23, 2024
Merged

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Sep 23, 2024

Context

The api currently allows empty array in the IN filter but the expected behaviour is not very clear. Typeorm seems to return all records when it is empty which could lead to undesired result. Instead we decided to throw an error.
I've updated the FE accordingly to skip calls when array is empty.

Screenshot 2024-09-23 at 14 20 28

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request addresses an issue with the IN filter handling empty arrays in the API and updates the frontend to optimize API calls accordingly.

  • Modified packages/twenty-server/src/engine/api/graphql/graphql-query-runner/graphql-query-parsers/graphql-query-filter/graphql-query-filter-field.parser.ts to throw an error for empty arrays in IN filters
  • Updated packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsMessageChannelsContainer.tsx to skip API calls when the accounts array is empty
  • Improved error handling in the backend to prevent unexpected behavior with empty IN filters
  • Optimized frontend performance by avoiding unnecessary API requests for empty data sets
  • Removed unused import and switched to native Array.isArray() method in the backend parser

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

return;
if (operator === 'in') {
if (!Array.isArray(value)) {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THROW!

@charlesBochet charlesBochet merged commit d8e16cb into main Sep 23, 2024
11 of 16 checks passed
@charlesBochet charlesBochet deleted the c--fix-in-filter-with-empty-array branch September 23, 2024 13:12
ijreilly pushed a commit that referenced this pull request Sep 25, 2024
More details in this PR #7202

We(I) forgot to fix on the calendar page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants