diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-12-27 16:38:32 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-12-27 16:38:32 -0300 |
commit | 49a8c7bd5168ca84897166527f5c0d90126dc402 (patch) | |
tree | 73d803eddb1dffa6c0f31bdd3a203e607ee00686 /spec/arel/engines/sql/unit/relations/from_spec.rb | |
parent | a5e3ac2c2d20ea1335a1aa48e6813272a39bc3d3 (diff) | |
download | rails-49a8c7bd5168ca84897166527f5c0d90126dc402.tar.gz rails-49a8c7bd5168ca84897166527f5c0d90126dc402.tar.bz2 rails-49a8c7bd5168ca84897166527f5c0d90126dc402.zip |
Added "from" method, allowing to specify custom from clauses.
Diffstat (limited to 'spec/arel/engines/sql/unit/relations/from_spec.rb')
-rw-r--r-- | spec/arel/engines/sql/unit/relations/from_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/arel/engines/sql/unit/relations/from_spec.rb b/spec/arel/engines/sql/unit/relations/from_spec.rb new file mode 100644 index 0000000000..a611cd65f4 --- /dev/null +++ b/spec/arel/engines/sql/unit/relations/from_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' + +module Arel + describe Table do + before do + @relation = Table.new(:users) + end + + describe '#to_sql' do + it "manufactures a simple select query" do + sql = @relation.from("workers").to_sql + + adapter_is :mysql do + sql.should be_like(%Q{ + SELECT `users`.`id`, `users`.`name` + FROM workers + }) + end + + adapter_is_not :mysql do + sql.should be_like(%Q{ + SELECT "users"."id", "users"."name" + FROM workers + }) + end + end + end + + describe '#to_sql' do + it "overrides and use last from clause given " do + sql = @relation.from("workers").from("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 + + end +end |