Sha256: 57610810a7b540120b19d9b14cc9f8801a694c03bd43cd3b89e8bb7e682d56f7

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
module Alf
  module Sql
    class Processor
      describe Merge, "on_with_exp" do

        subject{ Merge.new(:intersect, right, builder(1)).on_with_exp(expr) }

        context 'when right is a simple exp' do
          let(:expr){
            # with t1 AS ...
            #      SELECT * FROM t1
            with_exp({t1: select_all}, select_all)
          }

          let(:right){
            # SELECT * FROM t2
            select_all_t2
          }

          let(:expected){
            # WITH t1 AS ...
            # SELECT * FROM t1 INTERSECT SELECT * FROM t2
            with_exp({t1: select_all}, intersect)
          }

          it{ should eq(expected) }
        end

        context 'when right is a with_exp' do
          let(:expr){
            # WITH t1 AS ...
            # SELECT * FROM t1
            with_exp({t1: select_all}, select_all)
          }

          let(:right){
            # WITH t2 AS ...
            # SELECT * FROM t2
            with_exp({t2: select_all_t2}, select_all_t2)
          }

          let(:expected){
            # WITH t1 AS ...
            #      t2 AS ...
            # SELECT * FROM t1 INTERSECT SELECT * FROM t2
            with_exp({t1: select_all, t2: select_all_t2}, intersect)
          }

          it{ should eq(expected) }
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-sql-0.16.3 spec/processor/merge/test_on_with_exp.rb
alf-sql-0.16.2 spec/processor/merge/test_on_with_exp.rb
alf-sql-0.16.1 spec/processor/merge/test_on_with_exp.rb
alf-sql-0.16.0 spec/processor/merge/test_on_with_exp.rb
alf-sql-0.15.0 spec/processor/merge/test_on_with_exp.rb