Sha256: b02468b09006e80d5c8eb5459dc8469889b28f03f2b59598258d7ef077217b87
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Optimizer::Algebra::Restriction::ProductOperand, '#optimizable?' do subject { object.optimizable? } let(:left) { Relation.new([[:user_id, Integer], [:user_name, String]], LazyEnumerable.new([[1, 'Dan Kubb']])) } let(:right) { Relation.new([[:employee_id, Integer], [:employee_name, String]], LazyEnumerable.new([[2, 'Dan Kubb']])) } let(:relation) { operand.restrict { predicate } } let(:object) { described_class.new(relation) } before do expect(object.operation).to be_kind_of(Algebra::Restriction) end context 'when the operand is a product operation and the predicate distributes to the left' do let(:operand) { left.product(right) } let(:predicate) { left[:user_name].eq('Dan Kubb') } it { should be(true) } end context 'when the operand is a product operation and the predicate distributes to the right' do let(:operand) { left.product(right) } let(:predicate) { right[:employee_name].eq('Dan Kubb') } it { should be(true) } end context 'when the operand is a product operation and the predicate does not distribute to the left or right' do let(:operand) { left.product(right) } let(:predicate) { left[:user_name].eq(right[:employee_name]) } it { should be(false) } end context 'when the operand is not a product operation' do let(:operand) { left } let(:predicate) { true } it { should be(false) } end end
Version data entries
2 entries across 2 versions & 1 rubygems