func (rb ruleBuilder) Between(min interface{}, max interface{}) ruleBuilder { if reflect.TypeOf(min).Kind() != reflect.TypeOf(max).Kind() { panic("Disparate values passed into Between(...) \n" + "\nMin: " + reflect.TypeOf(min).Kind().String() + "\nMax: " + reflect.TypeOf(max).Kind().String()) } rb = rb.updateTypeAccordingTo(min) builder.Set(rb, "Min", min) builder.Set(rb, "Max", max) return rb }
// SetMap set columns and values for insert builder from a map of column name and value // note that it will reset all previous columns and values was set if any func (b InsertBuilder) SetMap(clauses map[string]interface{}) InsertBuilder { cols := make([]string, 0, len(clauses)) vals := make([]interface{}, 0, len(clauses)) for col, val := range clauses { cols = append(cols, col) vals = append(vals, val) } b = builder.Set(b, "Columns", cols).(InsertBuilder) b = builder.Set(b, "Values", [][]interface{}{vals}).(InsertBuilder) return b }
//############################################################################ func (p beamerBuilder) Set(key string, value interface{}) beamerBuilder { m, ok := builder.Get(p, "KVStore") if ok { store := m.(map[string]interface{}) store[key] = value return builder.Set(p, "KVStore", store).(beamerBuilder) } store := make(map[string]interface{}) store[key] = value return builder.Set(p, "KVStore", store).(beamerBuilder) }
func (b jsonBuilder) AddHrefLink(class string, href string) jsonBuilder { val, _ := builder.Get(b, "Hal") if val == nil { val = Hal{} } hal, _ := val.(Hal) hal.AddHrefLink(class, href) return builder.Set(b, "Hal", hal).(jsonBuilder) }
func (b jsonBuilder) AddCustomField(name string, value interface{}) jsonBuilder { val, _ := builder.Get(b, "CustomFields") if val == nil { val = make(map[string]interface{}) } fields, _ := val.(map[string]interface{}) fields[name] = value return builder.Set(b, "CustomFields", fields).(jsonBuilder) }
func (b ContainerBuilder) S3Destination(identifier string, destination *S3Destination) ContainerBuilder { if destination.Key == "" { destination.Key = identifier + "-" + randString(10) } if destination.Bucket == "" { panic("You need to set S3Destination.Bucket") } return builder.Set(b, "S3Destination", destination).(ContainerBuilder) }
func setRunWith(b interface{}, baseRunner BaseRunner) interface{} { var runner Runner switch r := baseRunner.(type) { case Runner: runner = r case *sql.DB: runner = &dbRunner{r} } return builder.Set(b, "RunWith", runner) }
func TestSetInvalidNil(t *testing.T) { var panicVal interface{} func() { defer func() { panicVal = recover() }() b := builder.Set(FooBuilder, "X", nil) builder.GetStruct(b) }() if panicVal == nil { t.Errorf("expected panic, didn't") } }
func (b FunctionBuilder) Params(key string, value interface{}) FunctionBuilder { var hash map[string]interface{} params, ok := builder.Get(b, "Params") if ok { hash = params.(map[string]interface{}) } else { hash = make(map[string]interface{}) } hash[key] = value return builder.Set(b, "Params", hash).(FunctionBuilder) }
func (b searchReqBuilder) Query(v string) searchReqBuilder { return builder.Set(b, "Query", v).(searchReqBuilder) }
func (b answersReqBuilder) SiteID(v string) answersReqBuilder { return builder.Set(b, "SiteID", v).(answersReqBuilder) }
func (b searchReqBuilder) Tags(tags []string) searchReqBuilder { return builder.Set(b, "Tags", tags).(searchReqBuilder) }
func (b fooBuilder) X(i int) fooBuilder { return builder.Set(b, "X", i).(fooBuilder) }
// Into sets the INTO clause of the query. func (b InsertBuilder) Into(from string) InsertBuilder { return builder.Set(b, "Into", from).(InsertBuilder) }
func (b simpleExprBuilder) Multiplier(i int) simpleExprBuilder { return builder.Set(b, "Multiplier", i).(simpleExprBuilder) }
func (b FunctionBuilder) Save(c ContainerBuilder) FunctionBuilder { cont := c.build() return builder.Set(b, "Container", &cont).(FunctionBuilder) }
// Limit sets a LIMIT clause on the query. func (b UpdateBuilder) Limit(limit uint64) UpdateBuilder { return builder.Set(b, "Limit", fmt.Sprintf("%d", limit)).(UpdateBuilder) }
// Table sets the table to be updated. func (b UpdateBuilder) Table(table string) UpdateBuilder { return builder.Set(b, "Table", table).(UpdateBuilder) }
// PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the // query. func (b UpdateBuilder) PlaceholderFormat(f PlaceholderFormat) UpdateBuilder { return builder.Set(b, "PlaceholderFormat", f).(UpdateBuilder) }
func (b fooBuilder) I(i interface{}) fooBuilder { return builder.Set(b, "I", i).(fooBuilder) }
func (b fooBuilder) Y(i int) fooBuilder { return builder.Set(b, "Y", i).(fooBuilder) }
func (b FunctionBuilder) Name(name string) FunctionBuilder { return builder.Set(b, "Name", name).(FunctionBuilder) }
func (b ContainerBuilder) Extension(ext string) ContainerBuilder { return builder.Set(b, "Extension", ext).(ContainerBuilder) }
func (b searchReqBuilder) SiteID(v string) searchReqBuilder { return builder.Set(b, "SiteID", v).(searchReqBuilder) }
// PlaceholderFormat sets the PlaceholderFormat field for any child builders. func (b StatementBuilderType) PlaceholderFormat(f PlaceholderFormat) StatementBuilderType { return builder.Set(b, "PlaceholderFormat", f).(StatementBuilderType) }
func (b searchReqBuilder) Sort(v string) searchReqBuilder { return builder.Set(b, "Sort", v).(searchReqBuilder) }
// PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the // query. func (b InsertBuilder) PlaceholderFormat(f PlaceholderFormat) InsertBuilder { return builder.Set(b, "PlaceholderFormat", f).(InsertBuilder) }
func (b searchReqBuilder) Accepted(flag bool) searchReqBuilder { return builder.Set(b, "Accepted", flag).(searchReqBuilder) }
// Offset sets a OFFSET clause on the query. func (b UpdateBuilder) Offset(offset uint64) UpdateBuilder { return builder.Set(b, "Offset", fmt.Sprintf("%d", offset)).(UpdateBuilder) }
func (b ContainerBuilder) S3Destination(key string, bucket string) ContainerBuilder { destination := &S3Destination{Key: key, Bucket: bucket} return builder.Set(b, "S3Destination", destination).(ContainerBuilder) }