Beispiel #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)
	}
}
Beispiel #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.(string); ok {
		column = nodes.Column(column)
	}

	self.Tree.Returning = column
	return self
}
Beispiel #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)
	}
}
Beispiel #4
0
// Table returns an Accessor from the managers package for
// generating SQL to interact with existing tables.
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)
	}
}