stmt

package
v1.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context, query string) (*sql.Stmt, bool)

FromContext retrieves a SQL statement from the context chain that matches the given query. It performs a recursive search through the context chain until it finds a matching statement or reaches the end of the chain.

Note: It prevents infinite recursion by checking for self-referential contexts.

func Query

func Query(s *sql.Stmt) string

Query returns the underlying SQL query string from a *sql.Stmt. The offset of the query field is determined at init time using reflection, ensuring both safety and runtime performance.

Note: This is an internal function that relies on the sql.Stmt structure. It will panic during package initialization if the structure changes.

func WithContext

func WithContext(ctx context.Context, stmt *sql.Stmt) context.Context

WithContext creates a new context containing the provided SQL statement. It maintains a chain of contexts, allowing for statement reuse and lookup.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL