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

Fix join table column quoting with SQLite. #34626

Merged
merged 1 commit into from
Dec 5, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Fix join table column quoting with SQLite.

*Gannon McGibbon*

* Allow disabling scopes generated by `ActiveRecord.enum`.

*Alfred Dominic*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def quote_table_name_for_assignment(table, attr)
quote_column_name(attr)
end

def quote_table_name(name)
@quoted_table_names[name] ||= super.gsub(".", "\".\"").freeze
end

def quote_column_name(name)
@quoted_column_names[name] ||= %Q("#{super.gsub('"', '""')}")
end
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/calculations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,10 @@ def test_pluck_with_includes_offset
assert_equal [], Topic.includes(:replies).order(:id).offset(5).pluck(:id)
end

def test_pluck_with_join
assert_equal [[2, 2], [4, 4]], Reply.includes(:topic).pluck(:id, :"topics.id")
end

def test_group_by_with_limit
expected = { "Post" => 8, "SpecialPost" => 1 }
actual = Post.includes(:comments).group(:type).order(:type).limit(2).count("comments.id")
Expand Down