示例#1
0
func TestUnion(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.Union(one, two)
	two.Combinator = nodes.Union(two, three)
	expected := `(SELECT FROM "table_one" UNION (SELECT FROM "table_two" UNION SELECT FROM "table_three"))`
	if got, _ := sql.Accept(one); expected != got {
		t.Errorf("TestUnion was expected to return %s, got %s", expected, got)
	}
}
示例#2
0
// Union sets the SelectManager's Tree's Combination member to a
// UnionNode of itself and the parameter `manager`'s Tree.
func (self *SelectManager) Union(manager *SelectManager) *SelectManager {
	self.Tree.Combinator = nodes.Union(self.Tree, manager.Tree)
	return self
}