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

get_join_arel_node fails with include_optional_linkage_data if there is already a join #1449

Closed
3 of 7 tasks
pjungwir opened this issue Feb 16, 2024 · 0 comments · Fixed by #1450
Closed
3 of 7 tasks

Comments

@pjungwir
Copy link
Contributor

This issue is a (choose one):

  • Problem/bug report.
  • Feature request.
  • Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.

Checklist before submitting:

  • I've searched for an existing issue.
  • I've asked my question on Gitter and have not received a satisfactory answer.
  • I've included a complete bug report template. This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.
  • The feature I'm asking for is compliant with the JSON:API spec.

Description

If the user adds a join (e.g. in records) and that association has include_optional_linkage_data: true, then get_join_arel_node prints "get_join_arel_node: No join added" to stdout, returns nil, and a little later we crash because of the nil.

This happens because get_join_arel_node compares the node count before & after adding a join, but the count doesn't change because the join was already there.

We should fix this by looking for a compatible join and only failing if we can't find one. If we are trying to add a left outer join, then any join type will do (since adding an outer join wouldn't change the cardinality). If we are trying to add an inner join, then only another inner join is compatible (since otherwise the filtering we expect wouldn't happen).

I have a test case in my related PR, so I haven't included one here.

I hit this bug on master (a3a2a7a) and ruby 3.1.2p20.

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 a pull request may close this issue.

1 participant