Skip to content

Commit

Permalink
Merge pull request #124 from rocket-turtle/AR_6_1_fix_FrozenError
Browse files Browse the repository at this point in the history
Ar 6 1 fix frozen error
  • Loading branch information
rzane authored Aug 8, 2022
2 parents 7b307db + e9318aa commit 3ab6fb1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased]

- AR 6.1: fix - FrozenError: can't modify frozen object: []
- Drop support for ActiveRecord older than 6.0.

## [1.4.4] - 2022-02-07
Expand Down
4 changes: 3 additions & 1 deletion lib/baby_squeel/active_record/query_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def construct_join_dependency(associations, join_type)

# https://github.com/rails/rails/commit/c0c53ee9d28134757cf1418521cb97c4a135f140
def select_association_list(*args)
args[0].extend(BabySqueel::ActiveRecord::QueryMethods::Injector6_1)
if args[0].any? { |join| join.is_a?(BabySqueel::Join) }
args[0].extend(BabySqueel::ActiveRecord::QueryMethods::Injector6_1)
end
super *args
end
else
Expand Down
7 changes: 7 additions & 0 deletions spec/integration/__snapshots__/rails_integration_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ test that plain rails still works joins and merge 1: SELECT "authors".* FROM "au
test that plain rails still works left_joins 1: SELECT "posts".* FROM "posts" LEFT
OUTER JOIN "posts" "parents_posts" ON "parents_posts"."id" = "posts"."parent_id"
LEFT OUTER JOIN "authors" ON "authors"."id" = "posts"."author_id"
test that plain rails still works joins includes 1: SELECT "posts"."id" AS t0_r0,
"posts"."title" AS t0_r1, "posts"."author_id" AS t0_r2, "posts"."published_at" AS
t0_r3, "posts"."view_count" AS t0_r4, "posts"."parent_id" AS t0_r5, "posts"."created_at"
AS t0_r6, "posts"."updated_at" AS t0_r7, "authors"."id" AS t1_r0, "authors"."name"
AS t1_r1, "authors"."age" AS t1_r2, "authors"."ugly" AS t1_r3, "authors"."created_at"
AS t1_r4, "authors"."updated_at" AS t1_r5 FROM "posts" INNER JOIN "authors" ON "authors"."id"
= "posts"."author_id"
6 changes: 6 additions & 0 deletions spec/integration/rails_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@

expect(relation).to match_sql_snapshot
end

it 'joins includes' do
relation = Post.joins(:author).includes(:author).to_sql

expect(relation).to match_sql_snapshot
end
end

0 comments on commit 3ab6fb1

Please sign in to comment.