Finish UpdateAll query builder

* Add modifiers to delete builder
* Update golden file tests
* Add startAt to whereClause
This commit is contained in:
Patrick O'brien 2016-08-11 18:23:47 +10:00
parent c3f8cff117
commit e3f319346f
10 changed files with 240 additions and 40 deletions
strmangle

View file

@ -208,20 +208,24 @@ func PrefixStringSlice(str string, strs []string) []string {
}
// Placeholders generates the SQL statement placeholders for in queries.
// For example, ($1,$2,$3),($4,$5,$6) etc.
// For example, ($1, $2, $3), ($4, $5, $6) etc.
// It will start counting placeholders at "start".
func Placeholders(count int, start int, group int) string {
var buf bytes.Buffer
if start == 0 || group == 0 {
panic("Invalid start or group numbers supplied.")
}
if group > 1 {
buf.WriteByte('(')
}
for i := 0; i < count; i++ {
if i != 0 {
if group > 1 && i%group == 0 {
buf.WriteString(`),(`)
buf.WriteString("), (")
} else {
buf.WriteByte(',')
buf.WriteString(", ")
}
}
buf.WriteString(fmt.Sprintf("$%d", start+i))