mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #34626 from gmcgibbon/sqlite_pluck_quoting
Fix join table column quoting with SQLite.
This commit is contained in:
commit
b802e08273
3 changed files with 12 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
* Fix join table column quoting with SQLite.
|
||||||
|
|
||||||
|
*Gannon McGibbon*
|
||||||
|
|
||||||
* Allow disabling scopes generated by `ActiveRecord.enum`.
|
* Allow disabling scopes generated by `ActiveRecord.enum`.
|
||||||
|
|
||||||
*Alfred Dominic*
|
*Alfred Dominic*
|
||||||
|
|
|
@ -12,6 +12,10 @@ module ActiveRecord
|
||||||
quote_column_name(attr)
|
quote_column_name(attr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def quote_table_name(name)
|
||||||
|
@quoted_table_names[name] ||= super.gsub(".", "\".\"").freeze
|
||||||
|
end
|
||||||
|
|
||||||
def quote_column_name(name)
|
def quote_column_name(name)
|
||||||
@quoted_column_names[name] ||= %Q("#{super.gsub('"', '""')}")
|
@quoted_column_names[name] ||= %Q("#{super.gsub('"', '""')}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -721,6 +721,10 @@ class CalculationsTest < ActiveRecord::TestCase
|
||||||
assert_equal [], Topic.includes(:replies).order(:id).offset(5).pluck(:id)
|
assert_equal [], Topic.includes(:replies).order(:id).offset(5).pluck(:id)
|
||||||
end
|
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
|
def test_group_by_with_limit
|
||||||
expected = { "Post" => 8, "SpecialPost" => 1 }
|
expected = { "Post" => 8, "SpecialPost" => 1 }
|
||||||
actual = Post.includes(:comments).group(:type).order(:type).limit(2).count("comments.id")
|
actual = Post.includes(:comments).group(:type).order(:type).limit(2).count("comments.id")
|
||||||
|
|
Loading…
Reference in a new issue