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 include_optional_linkage_data with joins #1450

Merged

Conversation

pjungwir
Copy link
Contributor

@pjungwir pjungwir commented Feb 16, 2024

When the user adds a join in records, it confuses get_join_arel_node because it finds the same number of joins before & after adding a join for include_optional_linkage_data (or equivalently for always_include_*_linkage_data).

This commit falls back to searching the existing arel nodes for a compatible join and uses that if found.

Fixes #1449

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

Test Plan:

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

When the user adds a join in `records`, it confuses `get_join_arel_node`
because it finds the same number of joins before & after adding a join
for `include_optional_linkage_data` (or equivalently for
`always_include_*_linkage_data`).

This commit falls back to searching the existing arel nodes for a
compatible join and uses that if found.
@averydev
Copy link

averydev commented Mar 5, 2024

This has had a hugely positive impact on performance for us. Thank you!

Copy link
Member

@lgebhardt lgebhardt left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thanks @pjungwir

@lgebhardt lgebhardt merged commit e92afc6 into cerebris:master Apr 18, 2024
28 checks passed
aytigra added a commit to aytigra/jsonapi-resources that referenced this pull request Sep 19, 2024
Fix include_optional_linkage_data with joins (cerebris#1450)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get_join_arel_node fails with include_optional_linkage_data if there is already a join
3 participants