1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Skip the test added in 9cc324a on buggy versions of SQlite

See 7dcfc25e7c for more details
This commit is contained in:
Sean Griffin 2015-09-21 11:36:55 -06:00
parent 9cc324a3f1
commit 926002a7f3
2 changed files with 22 additions and 17 deletions

View file

@ -243,18 +243,23 @@ module ActiveRecord
end end
def test_select_quotes_when_using_from_clause def test_select_quotes_when_using_from_clause
if sqlite3_version_includes_quoting_bug? skip_if_sqlite3_version_includes_quoting_bug
skip <<-ERROR.squish
You are using an outdated version of SQLite3 which has a bug in
quoted column names. Please update SQLite3 and rebuild the sqlite3
ruby gem
ERROR
end
quoted_join = ActiveRecord::Base.connection.quote_table_name("join") quoted_join = ActiveRecord::Base.connection.quote_table_name("join")
selected = Post.select(:join).from(Post.select("id as #{quoted_join}")).map(&:join) selected = Post.select(:join).from(Post.select("id as #{quoted_join}")).map(&:join)
assert_equal Post.pluck(:id), selected assert_equal Post.pluck(:id), selected
end end
def test_selecting_aliased_attribute_quotes_column_name_when_from_is_used
skip_if_sqlite3_version_includes_quoting_bug
klass = Class.new(ActiveRecord::Base) do
self.table_name = :test_with_keyword_column_name
alias_attribute :description, :desc
end
klass.create!(description: "foo")
assert_equal ["foo"], klass.select(:description).from(klass.all).map(&:desc)
end
def test_relation_merging_with_merged_joins_as_strings def test_relation_merging_with_merged_joins_as_strings
join_string = "LEFT OUTER JOIN #{Rating.quoted_table_name} ON #{SpecialComment.quoted_table_name}.id = #{Rating.quoted_table_name}.comment_id" join_string = "LEFT OUTER JOIN #{Rating.quoted_table_name} ON #{SpecialComment.quoted_table_name}.id = #{Rating.quoted_table_name}.comment_id"
special_comments_with_ratings = SpecialComment.joins join_string special_comments_with_ratings = SpecialComment.joins join_string
@ -292,6 +297,16 @@ module ActiveRecord
private private
def skip_if_sqlite3_version_includes_quoting_bug
if sqlite3_version_includes_quoting_bug?
skip <<-ERROR.squish
You are using an outdated version of SQLite3 which has a bug in
quoted column names. Please update SQLite3 and rebuild the sqlite3
ruby gem
ERROR
end
end
def sqlite3_version_includes_quoting_bug? def sqlite3_version_includes_quoting_bug?
if current_adapter?(:SQLite3Adapter) if current_adapter?(:SQLite3Adapter)
selected_quoted_column_names = ActiveRecord::Base.connection.exec_query( selected_quoted_column_names = ActiveRecord::Base.connection.exec_query(

View file

@ -1897,14 +1897,4 @@ class RelationTest < ActiveRecord::TestCase
def test_relation_join_method def test_relation_join_method
assert_equal 'Thank you for the welcome,Thank you again for the welcome', Post.first.comments.join(",") assert_equal 'Thank you for the welcome,Thank you again for the welcome', Post.first.comments.join(",")
end end
def test_selecting_aliased_attribute_quotes_column_name_when_from_is_used
klass = Class.new(ActiveRecord::Base) do
self.table_name = :test_with_keyword_column_name
alias_attribute :description, :desc
end
klass.create!(description: "foo")
assert_equal ["foo"], klass.select(:description).from(klass.all).map(&:desc)
end
end end