Beispiel #1
0
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
}
Beispiel #2
0
// 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
}
Beispiel #3
0
//############################################################################
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)

}
Beispiel #4
0
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)
}
Beispiel #5
0
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)
}
Beispiel #8
0
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")
	}
}
Beispiel #9
0
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)
}
Beispiel #10
0
func (b searchReqBuilder) Query(v string) searchReqBuilder {
	return builder.Set(b, "Query", v).(searchReqBuilder)
}
Beispiel #11
0
func (b answersReqBuilder) SiteID(v string) answersReqBuilder {
	return builder.Set(b, "SiteID", v).(answersReqBuilder)
}
Beispiel #12
0
func (b searchReqBuilder) Tags(tags []string) searchReqBuilder {
	return builder.Set(b, "Tags", tags).(searchReqBuilder)
}
Beispiel #13
0
func (b fooBuilder) X(i int) fooBuilder {
	return builder.Set(b, "X", i).(fooBuilder)
}
Beispiel #14
0
// Into sets the INTO clause of the query.
func (b InsertBuilder) Into(from string) InsertBuilder {
	return builder.Set(b, "Into", from).(InsertBuilder)
}
Beispiel #15
0
func (b simpleExprBuilder) Multiplier(i int) simpleExprBuilder {
	return builder.Set(b, "Multiplier", i).(simpleExprBuilder)
}
Beispiel #16
0
func (b FunctionBuilder) Save(c ContainerBuilder) FunctionBuilder {
	cont := c.build()
	return builder.Set(b, "Container", &cont).(FunctionBuilder)
}
Beispiel #17
0
// 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)
}
Beispiel #18
0
// Table sets the table to be updated.
func (b UpdateBuilder) Table(table string) UpdateBuilder {
	return builder.Set(b, "Table", table).(UpdateBuilder)
}
Beispiel #19
0
// 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)
}
Beispiel #20
0
func (b fooBuilder) I(i interface{}) fooBuilder {
	return builder.Set(b, "I", i).(fooBuilder)
}
Beispiel #21
0
func (b fooBuilder) Y(i int) fooBuilder {
	return builder.Set(b, "Y", i).(fooBuilder)
}
Beispiel #22
0
func (b FunctionBuilder) Name(name string) FunctionBuilder {
	return builder.Set(b, "Name", name).(FunctionBuilder)
}
Beispiel #23
0
func (b ContainerBuilder) Extension(ext string) ContainerBuilder {
	return builder.Set(b, "Extension", ext).(ContainerBuilder)
}
Beispiel #24
0
func (b searchReqBuilder) SiteID(v string) searchReqBuilder {
	return builder.Set(b, "SiteID", v).(searchReqBuilder)
}
Beispiel #25
0
// PlaceholderFormat sets the PlaceholderFormat field for any child builders.
func (b StatementBuilderType) PlaceholderFormat(f PlaceholderFormat) StatementBuilderType {
	return builder.Set(b, "PlaceholderFormat", f).(StatementBuilderType)
}
Beispiel #26
0
func (b searchReqBuilder) Sort(v string) searchReqBuilder {
	return builder.Set(b, "Sort", v).(searchReqBuilder)
}
Beispiel #27
0
// 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)
}
Beispiel #28
0
func (b searchReqBuilder) Accepted(flag bool) searchReqBuilder {
	return builder.Set(b, "Accepted", flag).(searchReqBuilder)
}
Beispiel #29
0
// 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)
}
Beispiel #30
0
func (b ContainerBuilder) S3Destination(key string, bucket string) ContainerBuilder {
	destination := &S3Destination{Key: key, Bucket: bucket}
	return builder.Set(b, "S3Destination", destination).(ContainerBuilder)
}