Exemplo n.º 1
0
func TestColumn(t *testing.T) {
	column := nodes.Column("column")
	expected := `"column"`
	if got, _ := sql.Accept(column); expected != got {
		t.Errorf("TestColumn was expected to return %s, got %s", expected, got)
	}
}
Exemplo n.º 2
0
// Return sets the InsertStatementNodes Return to the `column` paramenter
// after ensureing it is a ColumnNode.
func (self *InsertManager) Returning(column interface{}) *InsertManager {
	if _, ok := column.(*nodes.ColumnNode); !ok {
		column = nodes.Column(column)
	}
	self.Tree.Returning = column
	return self
}
Exemplo n.º 3
0
func TestUnaliasedAttribute(t *testing.T) {
	relation := nodes.Relation("table")
	column := nodes.Column("column")
	attribute := nodes.Attribute(column, relation)
	expected := `"table"."column"`
	if got, _ := sql.Accept(attribute); expected != got {
		t.Errorf("TestUnaliasedAttribute was expected to return %s, got %s", expected, got)
	}
}
Exemplo n.º 4
0
// Table returns an Accessor
func Table(name string) managers.Accessor {
	relation := nodes.Relation(name)
	return func(name interface{}) *nodes.AttributeNode {
		if _, ok := name.(string); ok {
			return nodes.Attribute(nodes.Column(name), relation)
		}

		return nodes.Attribute(name, relation)
	}
}