Skip to content
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

Ar 6 1 fix frozen error #124

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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