2020-11-29 20:10:59 +00:00
|
|
|
{{- define "signature" -}}
|
|
|
|
Limited_{{ .Suffix }}({{ ctxparam .Args }},
|
|
|
|
limit int, offset int64) (
|
|
|
|
rows {{ sliceof .Row }}, err error)
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
|
|
|
|
{{- define "invoke" -}}
|
|
|
|
Limited_{{ .Suffix }}({{ ctxarg .Args }}, limit, offset)
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "body" }}
|
|
|
|
{{ embedplaceholders .Info }}
|
|
|
|
{{ embedsql .Info "__embed_stmt" }}
|
|
|
|
|
|
|
|
var __values []interface{}
|
|
|
|
{{ embedvalues .Args "__values" }}
|
|
|
|
__values = append(__values, limit, offset)
|
|
|
|
|
|
|
|
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
|
|
|
|
obj.logStmt(__stmt, __values...)
|
|
|
|
|
2020-11-29 20:53:09 +00:00
|
|
|
for {
|
2020-11-29 23:06:27 +00:00
|
|
|
rows, err = func() (rows {{ sliceof .Row }}, err error) {
|
2020-11-29 20:53:09 +00:00
|
|
|
__rows, err := obj.driver.QueryContext(ctx, __stmt, __values...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer __rows.Close()
|
2020-11-29 20:10:59 +00:00
|
|
|
|
2020-11-29 20:53:09 +00:00
|
|
|
for __rows.Next() {
|
|
|
|
{{ initnew .Row }}
|
|
|
|
err = __rows.Scan({{ addrof (flatten .Row) }})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
rows = append(rows, {{ arg .Row }})
|
|
|
|
}
|
|
|
|
err = __rows.Err()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rows, nil
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
if obj.shouldRetry(err) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
return nil, obj.makeErr(err)
|
|
|
|
}
|
|
|
|
return rows, nil
|
|
|
|
}
|
2020-11-29 20:10:59 +00:00
|
|
|
{{ end -}}
|