Fix / Use table_name instead of relation name#1471
Closed
Jasonlgrd wants to merge 1 commit intoJSONAPI-Resources:masterfrom
Closed
Fix / Use table_name instead of relation name#1471Jasonlgrd wants to merge 1 commit intoJSONAPI-Resources:masterfrom
table_name instead of relation name#1471Jasonlgrd wants to merge 1 commit intoJSONAPI-Resources:masterfrom
Conversation
table_name instead of relation name
Author
|
ping @pjungwir |
Jasonlgrd
referenced
this pull request
in Semeia-io/jsonapi-resources
Aug 21, 2025
I was created a PR in the original repo: https://github.com/cerebris/jsonapi-resources/pull/1471
Author
|
This project seems not longer maintained. So I close this PR 👋 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fix a bug. We have discuss it in https://github.com/cerebris/jsonapi-resources/pull/1450 PR.
Context
I have a
userandpatient_enrolled_journal_eventresourcesIn
userresource, I have this relation:In
patient_enrolled_journal_eventresource, I have this relation:In
PatientEnrolledJournalEventmodel, I have this scope:And in
PatientEnrolledJournalEventResource, I rewriterecordsmethod to apply this scope like this:And when I get
http://localhost:3001/api/v1/users?include=patient-enrolled-journal-eventI have this SQL error :I have investigated, my breakpoint is in
get_join_arel_nodemethod:j.left.name= usertable_name= usersSo, the condition is false :(
Problem
In the condition, we compare a relation name with table name and when the relation name is singular so isn't match with
table_name.Solution
The
join_sources[0].leftis aArel::Nodes::TableAliasclass so we have atable_namegetter. It's better to compare the both table_name.Checklists
All Submissions:
New Feature Submissions:
Bug fixes and Changes to Core Features:
Test Plan:
Reviewer Checklist: