Sha256: 82b118545179d8a5ffadbb96f64385b576b5918c52b5cf2d40fd890343a8e277

Contents?: true

Size: 990 Bytes

Versions: 5

Compression:

Stored size: 990 Bytes

Contents

require 'spec_helper'
module Alf
  module Operator::Relational
    describe Join do

      let(:suppliers){Relation.coerce [
        {:sid => 'S1', :city => 'London'},
        {:sid => 'S2', :city => 'Paris'},
        {:sid => 'S3', :city => 'Paris'},
        {:sid => 'S4', :city => 'London'},
        {:sid => 'S5', :city => 'Athens'},
      ]}

      context "when applied to sub-relations" do
        let(:suppliers_by_city){Relation.coerce( 
          Lispy.group(suppliers, [:sid], :suppliers)
        )}
        let(:s2_s3){Relation.coerce([
          {:sid => 'S3'},
          {:sid => 'S2'}
        ])} 
        let(:right){Relation.coerce([
          {:suppliers => s2_s3, :hello => "world"}
        ])}
        let(:expected){Relation.coerce([
          {:suppliers => s2_s3, :hello => "world", :city => 'Paris'}
        ])}
        subject{Relation.coerce(
          Lispy.join(suppliers_by_city, right)
        )}
        it{ should eq(expected) }
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-core/operator/relational/test_join.rb
alf-0.12.1 spec/unit/alf-core/operator/relational/test_join.rb
alf-0.12.0 spec/unit/alf-core/operator/relational/test_join.rb
alf-0.11.1 spec/unit/alf-core/operator/relational/test_join.rb
alf-0.11.0 spec/unit/alf-core/operator/relational/test_join.rb