Skip to content

Commit

Permalink
Skip the test added in 9cc324a on buggy versions of SQlite
Browse files Browse the repository at this point in the history
See 7dcfc25e7c52682a4343c2ba7188a69e7c06c936 for more details
  • Loading branch information
sgrif committed Sep 21, 2015
1 parent ad07876 commit 10ff0cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
29 changes: 22 additions & 7 deletions activerecord/test/cases/relation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,23 @@ def test_respond_to_for_non_selected_element
end

def test_select_quotes_when_using_from_clause
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
skip_if_sqlite3_version_includes_quoting_bug
quoted_join = ActiveRecord::Base.connection.quote_table_name("join")
selected = Post.select(:join).from(Post.select("id as #{quoted_join}")).map(&:join)
assert_equal Post.pluck(:id), selected
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
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
Expand Down Expand Up @@ -285,6 +290,16 @@ def test_update_all_goes_through_normal_type_casting

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?
if current_adapter?(:SQLite3Adapter)
selected_quoted_column_names = ActiveRecord::Base.connection.exec_query(
Expand Down
10 changes: 0 additions & 10 deletions activerecord/test/cases/relations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1809,14 +1809,4 @@ def test_merging_reorders_bind_params
def test_relation_join_method
assert_equal 'Thank you for the welcome,Thank you again for the welcome', Post.first.comments.join(",")
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

0 comments on commit 10ff0cc

Please sign in to comment.