Skip to content

Commit b802e08

Browse files
authored
Merge pull request rails#34626 from gmcgibbon/sqlite_pluck_quoting
Fix join table column quoting with SQLite.
2 parents 299a213 + 93f1907 commit b802e08

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

activerecord/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Fix join table column quoting with SQLite.
2+
3+
*Gannon McGibbon*
4+
15
* Allow disabling scopes generated by `ActiveRecord.enum`.
26

37
*Alfred Dominic*

activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ def quote_table_name_for_assignment(table, attr)
1212
quote_column_name(attr)
1313
end
1414

15+
def quote_table_name(name)
16+
@quoted_table_names[name] ||= super.gsub(".", "\".\"").freeze
17+
end
18+
1519
def quote_column_name(name)
1620
@quoted_column_names[name] ||= %Q("#{super.gsub('"', '""')}")
1721
end

activerecord/test/cases/calculations_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,10 @@ def test_pluck_with_includes_offset
721721
assert_equal [], Topic.includes(:replies).order(:id).offset(5).pluck(:id)
722722
end
723723

724+
def test_pluck_with_join
725+
assert_equal [[2, 2], [4, 4]], Reply.includes(:topic).pluck(:id, :"topics.id")
726+
end
727+
724728
def test_group_by_with_limit
725729
expected = { "Post" => 8, "SpecialPost" => 1 }
726730
actual = Post.includes(:comments).group(:type).order(:type).limit(2).count("comments.id")

0 commit comments

Comments
 (0)