Exemplo n.º 1
0
func TestIntersect(t *testing.T) {
	relationOne := nodes.Relation("table_one")
	relationTwo := nodes.Relation("table_two")
	relationThree := nodes.Relation("table_three")
	one := nodes.SelectStatement(relationOne)
	two := nodes.SelectStatement(relationTwo)
	three := nodes.SelectStatement(relationThree)
	one.Combinator = nodes.Intersect(one, two)
	two.Combinator = nodes.Intersect(two, three)
	expected := `(SELECT FROM "table_one" INTERSECT (SELECT FROM "table_two" INTERSECT SELECT FROM "table_three"))`
	if got, _ := sql.Accept(one); expected != got {
		t.Errorf("TestUnion was expected to return %s, got %s", expected, got)
	}
}
Exemplo n.º 2
0
// Intersect sets the SelectManager's Tree's Combination member to a
// IntersectNode of itself and the parameter `manager`'s Tree.
func (self *SelectManager) Intersect(manager *SelectManager) *SelectManager {
	self.Tree.Combinator = nodes.Intersect(self.Tree, manager.Tree)
	return self
}