MCPcopy
hub / github.com/lxc/incus / SelectObjects

Function SelectObjects

internal/server/db/query/objects.go:15–31  ·  view source on GitHub ↗

SelectObjects executes a statement which must yield rows with a specific columns schema. It invokes the given Dest hook for each yielded row.

(ctx context.Context, stmt *sql.Stmt, rowFunc Dest, args ...any)

Source from the content-addressed store, hash-verified

13// SelectObjects executes a statement which must yield rows with a specific
14// columns schema. It invokes the given Dest hook for each yielded row.
15func SelectObjects(ctx context.Context, stmt *sql.Stmt, rowFunc Dest, args ...any) error {
16 rows, err := stmt.QueryContext(ctx, args...)
17 if err != nil {
18 return err
19 }
20
21 defer logger.WarnOnError(rows.Close, "Failed to close rows")
22
23 for rows.Next() {
24 err = rowFunc(rows.Scan)
25 if err != nil {
26 return err
27 }
28 }
29
30 return rows.Err()
31}
32
33// Scan runs a query with inArgs and provides the rowFunc with the scan function for each row.
34// It handles closing the rows and errors from the result set.

Callers 3

TestSelectObjects_ErrorFunction · 0.92
TestSelectObjectsFunction · 0.92
selectNodesVersionsFunction · 0.92

Calls 3

WarnOnErrorFunction · 0.92
ErrMethod · 0.80
QueryContextMethod · 0.65

Tested by 2

TestSelectObjects_ErrorFunction · 0.74
TestSelectObjectsFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…