Select FROM stored procedure
Currently there is no way of executing queries like SELECT * FROM my_stored_proc(a,b,c) as FROM clause only accepts a single string as argument. https://github.com/Masterminds/squirrel/blob/75b018d6ca72f526bf83d5ae500841097c458bea/select.go#L274
Simply by making the function to accept variadic arguments, we can achieve a basic solution.
func (b SelectBuilder) FromProc(from string, args ...interface{}) SelectBuilder {
from = from+"("+Placeholders(len(args))+")"
return builder.Set(b, "From", newPart(from, args...)).(SelectBuilder)
}
This can be invoked as follows
Select("*").FromProc("my_stored_proc",args[:]...)
I'm not sure if this is an acceptable solution. But It does simplify some workflows.
Just saw this. https://github.com/Masterminds/squirrel/issues/294 These are similar.
Yes! This is the only case, in our codebase, where we need to construct a piece of sql (the store procedure call) using fmt.Sprintf