aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-08-26 23:58:06 +0930
committerMatthew Draper <matthew@trebex.net>2014-08-26 23:58:06 +0930
commit36836fa5e7c084c0dce2818577e6fd0cf815f786 (patch)
treebee0543d1c859c53a0268a5b31a8af17015f28ff /test
parent53bc8426648cc93695525e8f12102cd416b2d772 (diff)
parent712c002af51700d128eb45996687600bb20c75a7 (diff)
downloadrails-36836fa5e7c084c0dce2818577e6fd0cf815f786.tar.gz
rails-36836fa5e7c084c0dce2818577e6fd0cf815f786.tar.bz2
rails-36836fa5e7c084c0dce2818577e6fd0cf815f786.zip
Merge pull request #300 from jpcody/master
Allow for alias omission in aggregate expressions
Diffstat (limited to 'test')
-rw-r--r--test/attributes/test_attribute.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/test/attributes/test_attribute.rb b/test/attributes/test_attribute.rb
index f55e39cfe9..dd2d9d343e 100644
--- a/test/attributes/test_attribute.rb
+++ b/test/attributes/test_attribute.rb
@@ -82,7 +82,7 @@ module Arel
mgr = users.project(Arel.star).where(users[:karma].gt(avg))
mgr.to_sql.must_be_like %{
- SELECT * FROM "users" WHERE "users"."karma" > (SELECT AVG("users"."karma") AS avg_id FROM "users")
+ SELECT * FROM "users" WHERE "users"."karma" > (SELECT AVG("users"."karma") FROM "users")
}
end
end
@@ -269,12 +269,11 @@ module Arel
relation[:id].average.must_be_kind_of Nodes::Avg
end
- # FIXME: backwards compat. Is this really necessary?
- it 'should set the alias to "avg_id"' do
+ it 'should generate the proper SQL' do
relation = Table.new(:users)
mgr = relation.project relation[:id].average
mgr.to_sql.must_be_like %{
- SELECT AVG("users"."id") AS avg_id
+ SELECT AVG("users"."id")
FROM "users"
}
end
@@ -286,12 +285,11 @@ module Arel
relation[:id].maximum.must_be_kind_of Nodes::Max
end
- # FIXME: backwards compat. Is this really necessary?
- it 'should set the alias to "max_id"' do
+ it 'should generate the proper SQL' do
relation = Table.new(:users)
mgr = relation.project relation[:id].maximum
mgr.to_sql.must_be_like %{
- SELECT MAX("users"."id") AS max_id
+ SELECT MAX("users"."id")
FROM "users"
}
end
@@ -310,12 +308,11 @@ module Arel
relation[:id].sum.must_be_kind_of Nodes::Sum
end
- # FIXME: backwards compat. Is this really necessary?
- it 'should set the alias to "sum_id"' do
+ it 'should generate the proper SQL' do
relation = Table.new(:users)
mgr = relation.project relation[:id].sum
mgr.to_sql.must_be_like %{
- SELECT SUM("users"."id") AS sum_id
+ SELECT SUM("users"."id")
FROM "users"
}
end