Skip to content

Commit f56b3c0

Browse files
authored
Fix HABTM query (#104)
While these seem like they should be equivalent, we are seeing the preloaded data is not filtered by the FK.
1 parent 0cd4866 commit f56b3c0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/jsonapi_compliable/adapters/active_record_sideloading.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ def has_and_belongs_to_many(association_name, scope: nil, resource:, foreign_key
9999
.class.reflections[through.to_s].klass.table_name
100100

101101
_scope.call
102-
.joins(through)
103-
.preload(through) # otherwise n+1 as we reference in #assign
102+
.includes(through)
104103
.where(table_name => { fk => parent_ids })
105104
.distinct
106105
end

0 commit comments

Comments
 (0)