diff options
author | Carl Lerche <carllerche@mac.com> | 2010-03-12 14:46:37 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-03-12 14:46:37 -0800 |
commit | e13420c86afb5c31e90cff800f121bd49255b939 (patch) | |
tree | 7089d188061b2a676143add52227e107a5cf9b45 /spec/engines/memory/integration | |
parent | 0b8b87fb947a746d4e58d11ea73ef20cfb23f576 (diff) | |
download | rails-e13420c86afb5c31e90cff800f121bd49255b939.tar.gz rails-e13420c86afb5c31e90cff800f121bd49255b939.tar.bz2 rails-e13420c86afb5c31e90cff800f121bd49255b939.zip |
We're obviously writing specs for arel. No need for a sub directory.
Diffstat (limited to 'spec/engines/memory/integration')
-rw-r--r-- | spec/engines/memory/integration/joins/cross_engine_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/engines/memory/integration/joins/cross_engine_spec.rb b/spec/engines/memory/integration/joins/cross_engine_spec.rb new file mode 100644 index 0000000000..606f3154c7 --- /dev/null +++ b/spec/engines/memory/integration/joins/cross_engine_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper' + +module Arel + describe Join do + before do + @users = Array.new([ + [1, 'bryan' ], + [2, 'emilio' ], + [3, 'nick'] + ], [[:id, Attributes::Integer], [:name, Attributes::String]]) + @photos = Table.new(:photos) + @photos.delete + @photos.insert(@photos[:id] => 1, @photos[:user_id] => 1, @photos[:camera_id] => 6) + @photos.insert(@photos[:id] => 2, @photos[:user_id] => 2, @photos[:camera_id] => 42) + # Oracle adapter returns database integers as Ruby integers and not strings + @adapter_returns_integer = false + adapter_is :oracle do + @adapter_returns_integer = true + end + end + + describe 'when the in memory relation is on the left' do + it 'joins across engines' do + @users \ + .join(@photos) \ + .on(@users[:id].eq(@photos[:user_id])) \ + .project(@users[:name], @photos[:camera_id]) \ + .let do |relation| + relation.call.should == [ + Row.new(relation, ['bryan', @adapter_returns_integer ? 6 : '6']), + Row.new(relation, ['emilio', @adapter_returns_integer ? 42 : '42']) + ] + end + end + end + + describe 'when the in memory relation is on the right' do + it 'joins across engines' do + @photos \ + .join(@users) \ + .on(@users[:id].eq(@photos[:user_id])) \ + .project(@users[:name], @photos[:camera_id]) \ + .let do |relation| + relation.call.should == [ + Row.new(relation, ['bryan', @adapter_returns_integer ? 6 : '6']), + Row.new(relation, ['emilio', @adapter_returns_integer ? 42 : '42']) + ] + end + end + end + end +end |