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

Function Scan

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

Scan runs a query with inArgs and provides the rowFunc with the scan function for each row. It handles closing the rows and errors from the result set.

(ctx context.Context, tx *sql.Tx, query string, rowFunc Dest, inArgs ...any)

Source from the content-addressed store, hash-verified

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.
35func Scan(ctx context.Context, tx *sql.Tx, query string, rowFunc Dest, inArgs ...any) error {
36 rows, err := tx.QueryContext(ctx, query, inArgs...)
37 if err != nil {
38 return err
39 }
40
41 defer logger.WarnOnError(rows.Close, "Failed to close rows")
42
43 for rows.Next() {
44 err = rowFunc(rows.Scan)
45 if err != nil {
46 return err
47 }
48 }
49
50 return rows.Err()
51}
52
53// Dest is a function that is expected to return the objects to pass to the
54// 'dest' argument of sql.Rows.Scan(). It is invoked by SelectObjects once per

Calls 3

WarnOnErrorFunction · 0.92
ErrMethod · 0.80
QueryContextMethod · 0.65

Tested by 2

TestUpsertObject_InsertFunction · 0.74
TestUpsertObject_UpdateFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…