BufPool WhereClause

This commit is contained in:
Patrick O'brien 2016-08-14 00:01:06 +10:00
parent 5922dc89bd
commit bd92e49ff0

View file

@ -300,12 +300,17 @@ func WhereClause(start int, cols []string) string {
panic("0 is not a valid start number for whereClause") panic("0 is not a valid start number for whereClause")
} }
ret := make([]string, len(cols)) buf := GetBuffer()
defer PutBuffer(buf)
for i, c := range cols { for i, c := range cols {
ret[i] = fmt.Sprintf(`"%s"=$%d`, c, start+i) buf.WriteString(fmt.Sprintf(`"%s"=$%d`, c, start+i))
if i < len(cols)-1 {
buf.WriteString(" AND ")
}
} }
return strings.Join(ret, " AND ") return buf.String()
} }
// DriverUsesLastInsertID returns whether the database driver supports the // DriverUsesLastInsertID returns whether the database driver supports the