-
Notifications
You must be signed in to change notification settings - Fork 535
Always include to_one linkage #1218
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
895c5da
Add test for empty included relationships containing data elements
lgebhardt 86f0c0d
Remove find_records overrides from tests
lgebhardt 087568e
Remove unused `retrieve_records` method
lgebhardt fe5c5f1
Move `records` method to ActiveRelationResourceFinder
lgebhardt 3213d57
Introduce Path class for parsing include, filter and sort paths
lgebhardt 825c964
Update test fixtures and data
lgebhardt 789b3b7
Rework joins and support belongs_to linkages without includes
lgebhardt 9c00a9a
Fix count on `records` that select a column on rails 4
lgebhardt 48f1c0a
Add join_left ActiveRecordAdapter to ponyfill
lgebhardt dd9ab5e
Do not use pagination or sorting in `count`
lgebhardt 6243176
Rename PathPart to PathSegment
lgebhardt 9c0391d
Clarify logic for processing polymorphic path segments with resource …
lgebhardt 14b1a1e
Clarify model check
lgebhardt 9918556
Test caching for `show_related_resource` requests
lgebhardt d82073c
Simplify and test `relationship_segments`
lgebhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
lib/jsonapi/active_relation_resource_finder/adapters/join_left_active_record_adapter.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module JSONAPI | ||
module ActiveRelationResourceFinder | ||
module Adapters | ||
module JoinLeftActiveRecordAdapter | ||
|
||
# Extends left_joins functionality to rails 4, and uses the same logic for rails 5.0.x and 5.1.x | ||
# The default left_joins logic of rails 5.2.x is used. This results in and extra join in some cases. For | ||
# example Post.joins(:comments).joins_left(comments: :author) will join the comments table twice, | ||
# once inner and once left in 5.2, but only as inner in earlier versions. | ||
def joins_left(*columns) | ||
if Rails::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MINOR >= 2 | ||
left_joins(columns) | ||
else | ||
join_dependency = ActiveRecord::Associations::JoinDependency.new(self, columns, []) | ||
joins(join_dependency) | ||
end | ||
end | ||
|
||
alias_method :join_left, :joins_left | ||
end | ||
|
||
if defined?(ActiveRecord) | ||
ActiveRecord::Base.extend JoinLeftActiveRecordAdapter | ||
end | ||
end | ||
end | ||
end |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.