Add Iterator support in clickhouse-go#1821
Conversation
SummaryThis PR introduces Should fix1. The return func(yield func(T, error) bool) {
var closeErr error
defer func() { closeErr = rows.Close() }()
for rows.Next() {
var value T
if err := rows.ScanStruct(&value); err != nil {
var zero T
yield(zero, err)
return
}
if !yield(value, nil) {
return
}
}
if err := rows.Err(); err != nil {
var zero T
yield(zero, err)
return
}
if closeErr != nil {
var zero T
yield(zero, closeErr)
}
}2. Every exported symbol must have a full-sentence doc comment beginning with the symbol name. Currently the function has none. At minimum: // StructIter returns a range-over-function iterator that scans each row from rows
// into a value of type T using ScanStruct, closing rows when iteration ends.
// The second yield value is non-nil if scanning fails or rows.Err() is set.
// T must be a struct. StructIter is available only via the native clickhouse.Open() API;
// database/sql.Rows does not implement driver.Rows.
func StructIter[T any](rows Rows) iter.Seq2[T, error] {3. No integration test in The only non-unit test is 4.
Nits
VerdictRequest changes — the missing doc comment and silent swallowing of |
|
addressed the comments |
Summary
#1820
Checklist
Delete items not relevant to your PR: