aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relations_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-02-17 10:49:38 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-02-17 10:49:38 -0300
commita2075f4142355900bf9e3d19c70248f614363a39 (patch)
tree889e2dc249c9e8e9625b4a635e61bc471306cf82 /activerecord/test/cases/relations_test.rb
parentc507f9f4c96ffb19345759bde3e871509c9a905e (diff)
downloadrails-a2075f4142355900bf9e3d19c70248f614363a39.tar.gz
rails-a2075f4142355900bf9e3d19c70248f614363a39.tar.bz2
rails-a2075f4142355900bf9e3d19c70248f614363a39.zip
Revert "Merge pull request #13344 from ccutrer/fix-from-default-select"
This reverts commit 3ea840355409dc205a9e0d027fc09f1452636969, reversing changes made to e4cde5d58cbb09d1843796f96ba86225ff94fe05. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/query_methods.rb Reason: using `from` without `select` should not change the select list to SELECT * because it can lead different query results. If it is needed to change the table to a subquery or a view you can pass a table alias in the `from` call or use `select('subquery.*')`. Fixes #14049.
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r--activerecord/test/cases/relations_test.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index e390d37871..8718110c36 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -151,11 +151,14 @@ class RelationTest < ActiveRecord::TestCase
assert_equal relation.to_a, Comment.select('a.*').from(relation, :a).to_a
end
- def test_finding_with_subquery_without_select
- relation = Topic.where(:approved => true)
- assert_equal relation.to_a, Topic.from(relation).to_a
+ def test_finding_with_subquery_without_select_does_not_change_the_select
+ relation = Topic.where(approved: true)
+ assert_raises(ActiveRecord::StatementInvalid) do
+ Topic.from(relation).to_a
+ end
end
+
def test_finding_with_conditions
assert_equal ["David"], Author.where(:name => 'David').map(&:name)
assert_equal ['Mary'], Author.where(["name = ?", 'Mary']).map(&:name)