예제 #1
0
// Appends a new InnerJoin to the current Context's SourceNode.
func (self *SelectManager) InnerJoin(table interface{}) *SelectManager {
	switch table.(type) {
	case Accessor:
		self.Context.Source.Right = append(self.Context.Source.Right, nodes.InnerJoin(table.(Accessor).Relation(), nil))
	case *nodes.RelationNode:
		self.Context.Source.Right = append(self.Context.Source.Right, nodes.InnerJoin(table.(*nodes.RelationNode), nil))
	}
	return self
}
예제 #2
0
func TestInnerJoin(t *testing.T) {
	join := nodes.InnerJoin(1, nil)
	expected := "INNER JOIN 1"
	if got, _ := sql.Accept(join); expected != got {
		t.Errorf("TestInnerJoin was expected to return %s, got %s", expected, got)
	}
}
예제 #3
0
func TestSelectCoreExtensive(t *testing.T) {
	relation := nodes.Relation("table")
	core := nodes.SelectCore(relation)
	core.Projections = append(core.Projections, 1, 2)
	core.Wheres = append(core.Wheres, 3, 4)
	core.Source.Right = append(core.Source.Right, nodes.InnerJoin(5, nil))
	expected := `SELECT 1, 2 FROM "table" INNER JOIN 5 WHERE 3 AND 4`
	if got, _ := sql.Accept(core); expected != got {
		t.Errorf("TestSelectCoreExtensive was expected to return %s, got %s", expected, got)
	}
}