// Columns adds result columns to the query. func (b SelectBuilder) Columns(columns ...string) SelectBuilder { var parts []interface{} for _, str := range columns { parts = append(parts, newPart(str)) } return builder.Extend(b, "Columns", parts).(SelectBuilder) }
func TestExtendNil(t *testing.T) { b := builder.Extend(FooBuilder, "Add", nil) _, ok := builder.Get(b, "X") if ok { t.Fatalf("key %v set unexpectedly", "Add") } }
func TestExtendPanic(t *testing.T) { var panicVal *reflect.ValueError func() { defer func() { panicVal = recover().(*reflect.ValueError) }() builder.Extend(FooBuilder, "Add", Foo{}) }() if panicVal == nil { t.Errorf("expected panic, didn't") } }
// Columns adds insert columns to the query. func (b InsertBuilder) Columns(columns ...string) InsertBuilder { return builder.Extend(b, "Columns", columns).(InsertBuilder) }
// Options adds keyword options before the INTO clause of the query. func (b InsertBuilder) Options(options ...string) InsertBuilder { return builder.Extend(b, "Options", options).(InsertBuilder) }
// OrderBy adds ORDER BY expressions to the query. func (b UpdateBuilder) OrderBy(orderBys ...string) UpdateBuilder { return builder.Extend(b, "OrderBys", orderBys).(UpdateBuilder) }
// OrderBy adds ORDER BY expressions to the query. func (b DeleteBuilder) OrderBy(orderBys ...string) DeleteBuilder { return builder.Extend(b, "OrderBys", orderBys).(DeleteBuilder) }
// OrderBy adds ORDER BY expressions to the query. func (b SelectBuilder) OrderBy(orderBys ...string) SelectBuilder { return builder.Extend(b, "OrderBys", orderBys).(SelectBuilder) }
// GroupBy adds GROUP BY expressions to the query. func (b SelectBuilder) GroupBy(groupBys ...string) SelectBuilder { return builder.Extend(b, "GroupBys", groupBys).(SelectBuilder) }
// Options adds select option to the query func (b SelectBuilder) Options(options ...string) SelectBuilder { return builder.Extend(b, "Options", options).(SelectBuilder) }
// Having adds an expression to the HAVING clause of the query. // // See Where. func (b SelectBuilder) Having(pred interface{}, rest ...interface{}) SelectBuilder { return builder.Extend(b, "HavingParts", newWhereParts(pred, rest...)).(SelectBuilder) }
// Where adds an expression to the WHERE clause of the query. // // Expressions are ANDed together in the generated SQL. // // Where accepts several types for its pred argument: // // nil OR "" - ignored. // // string - SQL expression. // If the expression has SQL placeholders then a set of arguments must be passed // as well, one for each placeholder. // // map[string]interface{} OR Eq - map of SQL expressions to values. Each key is // transformed into an expression like "<key> = ?", with the corresponding value // bound to the placeholder. If the value is nil, the expression will be "<key> // IS NULL". If the value is an array or slice, the expression will be "<key> IN // (?,?,...)", with one placeholder for each item in the value. These expressions // are ANDed together. // // Where will panic if pred isn't any of the above types. func (b SelectBuilder) Where(pred interface{}, args ...interface{}) SelectBuilder { return builder.Extend(b, "WhereParts", newWhereParts(pred, args...)).(SelectBuilder) }
// Columns adds result columns to the query. func (b SelectBuilder) Columns(columns ...string) SelectBuilder { return builder.Extend(b, "Columns", columns).(SelectBuilder) }