Query builder (#10104)
* add query builder to facilitate dynamic SQL construction * leverage query builder to refactor user store This is partially setup work for MM-13120, but merged to master to avoid further conflicts. * fix unrelated unit test breakage * documentation tweaks * Apply suggestions from code review Co-Authored-By: lieut-data <jesse.hallam@gmail.com> * prefer comma separated case options to fallthrough * vendor github.com/Masterminds/squirrel and deps * switch to using github.com/Masterminds/squirrel * rm querybuilder
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
099e6f74f3
Коммит
2c3a2e9235
24
vendor/github.com/lann/builder/reflect.go
сгенерированный
поставляемый
Обычный файл
24
vendor/github.com/lann/builder/reflect.go
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,24 @@
|
||||
package builder
|
||||
|
||||
import "reflect"
|
||||
|
||||
func convert(from interface{}, to interface{}) interface{} {
|
||||
return reflect.
|
||||
ValueOf(from).
|
||||
Convert(reflect.TypeOf(to)).
|
||||
Interface()
|
||||
}
|
||||
|
||||
func forEach(s interface{}, f func(interface{})) {
|
||||
val := reflect.ValueOf(s)
|
||||
|
||||
kind := val.Kind()
|
||||
if kind != reflect.Slice && kind != reflect.Array {
|
||||
panic(&reflect.ValueError{Method: "builder.forEach", Kind: kind})
|
||||
}
|
||||
|
||||
l := val.Len()
|
||||
for i := 0; i < l; i++ {
|
||||
f(val.Index(i).Interface())
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user