MCPcopy Create free account
hub / github.com/foxcpp/maddy / LookupMulti

Method LookupMulti

internal/table/sql_query.go:175–200  ·  view source on GitHub ↗
(ctx context.Context, val string)

Source from the content-addressed store, hash-verified

173}
174
175func (s *SQL) LookupMulti(ctx context.Context, val string) ([]string, error) {
176 var (
177 repl []string
178 rows *sql.Rows
179 err error
180 )
181 if s.namedArgs {
182 rows, err = s.lookup.QueryContext(ctx, sql.Named("key", val))
183 } else {
184 rows, err = s.lookup.QueryContext(ctx, val)
185 }
186 if err != nil {
187 return nil, fmt.Errorf("%s; lookup %s: %w", s.modName, val, err)
188 }
189 for rows.Next() {
190 var res string
191 if err := rows.Scan(&res); err != nil {
192 return nil, fmt.Errorf("%s; lookup %s: %w", s.modName, val, err)
193 }
194 repl = append(repl, res)
195 }
196 if err := rows.Err(); err != nil {
197 return nil, fmt.Errorf("%s; lookup %s: %w", s.modName, val, err)
198 }
199 return repl, nil
200}
201
202func (s *SQL) Keys() ([]string, error) {
203 if s.list == nil {

Callers

nothing calls this directly

Calls 2

ErrMethod · 0.80
NextMethod · 0.45

Tested by

no test coverage detected