mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-11-04 14:27:20 +00:00
* Read each observer's receptions on their own in the observer comparison * Tighten the observer comparison plan checks
34 lines
805 B
Go
34 lines
805 B
Go
// Copyright 2026 Beacon Contributors
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
)
|
|
|
|
// statementCapture records the SQL and args of sqlc statements whose name starts with name, for EXPLAIN.
|
|
type statementCapture struct {
|
|
pgx.Tx
|
|
name string
|
|
statement string
|
|
args []any
|
|
}
|
|
|
|
func (c *statementCapture) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) {
|
|
if strings.Contains(sql, "-- name: "+c.name) {
|
|
c.statement, c.args = sql, args
|
|
}
|
|
return c.Tx.Query(ctx, sql, args...)
|
|
}
|
|
|
|
func (c *statementCapture) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row {
|
|
if strings.Contains(sql, "-- name: "+c.name) {
|
|
c.statement, c.args = sql, args
|
|
}
|
|
return c.Tx.QueryRow(ctx, sql, args...)
|
|
}
|