Fix / Use table_name
instead of relation name
#1471
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 #1450 PR.
Context
I have a
user
andpatient_enrolled_journal_event
resourcesIn
user
resource, I have this relation:In
patient_enrolled_journal_event
resource, I have this relation:In
PatientEnrolledJournalEvent
model, I have this scope:And in
PatientEnrolledJournalEventResource
, I rewriterecords
method to apply this scope like this:And when I get
http://localhost:3001/api/v1/users?include=patient-enrolled-journal-event
I have this SQL error :I have investigated, my breakpoint is in
get_join_arel_node
method: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].left
is aArel::Nodes::TableAlias
class so we have atable_name
getter. 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: