expander

package
v1.31.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnGetter

type ColumnGetter interface {
	GetColumnNames(ctx context.Context, query string) ([]string, error)
}

ColumnGetter retrieves column names for a query by preparing it against a database.

type Expander

type Expander struct {
	// contains filtered or unexported fields
}

Expander expands SELECT * and RETURNING * queries by replacing * with explicit column names obtained from preparing the query against a database.

func New

func New(colGetter ColumnGetter, parser Parser, dialect format.Dialect) *Expander

New creates a new Expander with the given column getter, parser, and dialect.

func (*Expander) Expand

func (e *Expander) Expand(ctx context.Context, query string) (string, error)

Expand takes a SQL query, and if it contains * in SELECT or RETURNING clause, expands it to use explicit column names. Returns the expanded query string.

type Parser

type Parser interface {
	Parse(r io.Reader) ([]ast.Statement, error)
}

Parser is an interface for SQL parsers that can parse SQL into AST statements.

Jump to

Keyboard shortcuts

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