Esempio n. 1
0
func TestExcept(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.Except(one, two)
	two.Combinator = nodes.Except(two, three)
	expected := `(SELECT FROM "table_one" EXCEPT (SELECT FROM "table_two" EXCEPT SELECT FROM "table_three"))`
	if got, _ := sql.Accept(one); expected != got {
		t.Errorf("TestUnion was expected to return %s, got %s", expected, got)
	}
}
Esempio n. 2
0
func TestSelectStatement(t *testing.T) {
	relation := nodes.Relation("table")
	stmt := nodes.SelectStatement(relation)
	expected := `SELECT FROM "table"`
	if got, _ := sql.Accept(stmt); expected != got {
		t.Errorf("TestSelectStatement was expected to return %s, got %s", expected, got)
	}
}
Esempio n. 3
0
// SelectManager factory method.
func Selection(relation *nodes.RelationNode) (selection *SelectManager) {
	selection = new(SelectManager)
	selection.Tree = nodes.SelectStatement(relation)
	selection.Context = selection.Tree.Cores[0]
	return
}