예제 #1
0
func TestGrouping(t *testing.T) {
	grouping := nodes.Grouping(1)
	expected := "(1)"
	if got, _ := sql.Accept(grouping); expected != got {
		t.Errorf("TestGrouping was expected to return %s, got %s", expected, got)
	}
}
예제 #2
0
// Appends an expression to the current Context's Wheres slice,
// typically a comparison, i.e. 1 = 1
func (self *SelectManager) Where(expr interface{}) *SelectManager {
	if _, ok := expr.(string); ok {
		expr = nodes.Literal(expr)
	}

	if _, ok := expr.(*nodes.GroupingNode); !ok {
		expr = nodes.Grouping(expr)
	}

	self.Context.Wheres = append(self.Context.Wheres, expr)
	return self
}