aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-12 21:40:38 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-12 21:40:38 +0530
commit7286f0f4c8117e2210834070d30378ffb12dba23 (patch)
tree3a146b5efe6bee24e6d1bd5a8348e792582207b4 /spec
parent26a0fefc6d87107161a0d3a171d852f6cd2b4888 (diff)
downloadrails-7286f0f4c8117e2210834070d30378ffb12dba23.tar.gz
rails-7286f0f4c8117e2210834070d30378ffb12dba23.tar.bz2
rails-7286f0f4c8117e2210834070d30378ffb12dba23.zip
Make sure not to use alias if it's same as the table name
Diffstat (limited to 'spec')
-rw-r--r--spec/arel/engines/sql/unit/relations/table_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/arel/engines/sql/unit/relations/table_spec.rb b/spec/arel/engines/sql/unit/relations/table_spec.rb
index 977eb343e3..d8584ccaec 100644
--- a/spec/arel/engines/sql/unit/relations/table_spec.rb
+++ b/spec/arel/engines/sql/unit/relations/table_spec.rb
@@ -44,6 +44,25 @@ module Arel
})
end
end
+
+ it "does not apply alias if it's same as the table name" do
+ sql = @relation.as(:users).to_sql
+
+ adapter_is :mysql do
+ sql.should be_like(%Q{
+ SELECT `users`.`id`, `users`.`name`
+ FROM `users`
+ })
+ end
+
+ adapter_is_not :mysql do
+ sql.should be_like(%Q{
+ SELECT "users"."id", "users"."name"
+ FROM "users"
+ })
+ end
+ end
+
end
describe '#column_for' do