Documentation
¶
Index ¶
- func RegisterDialect(name string, dialect Dialect)
- type Builder
- func (b Builder) Capabilities() builders.Capabilities
- func (b Builder) Create(field builders.Field) (string, []any, error)
- func (b Builder) Delete(field builders.Field) (string, []any, error)
- func (b Builder) Query(field builders.Field) (string, []any, error)
- func (b Builder) Update(field builders.Field) (string, []any, error)
- type Dialect
- type Executor
- type PostgresDialect
- type SQLQuery
- type TypeNameScanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDialect ¶ added in v0.3.1
RegisterDialect allows registering custom SQL dialects.
Types ¶
type Builder ¶
type Builder struct {
Schema *ast.Schema
Logger log.Logger
TableNameGenerator builders.TableNameGenerator
Operators map[string]builders.Operator
AggregatorOperators map[string]builders.AggregatorOperator
CaseConverter builders.ColumnCaseConverter
Dialect string
}
func NewBuilder ¶
func (Builder) Capabilities ¶ added in v0.3.1
func (b Builder) Capabilities() builders.Capabilities
Capabilities returns what this SQL database supports.
type Dialect ¶ added in v0.3.1
type Dialect interface {
// JSONBuildObject creates a JSON object from key-value pairs
JSONBuildObject(args ...any) exp.SQLFunctionExpression
// JSONAgg aggregates rows into a JSON array
JSONAgg(expr exp.Expression) exp.SQLFunctionExpression
// CoalesceJSON returns a fallback value if the expression is null
CoalesceJSON(expr exp.Expression, fallback string) exp.SQLFunctionExpression
}
Dialect provides dialect-specific SQL functions. Different databases have different syntax for JSON operations.
func GetSQLDialect ¶ added in v0.3.1
GetSQLDialect returns the Dialect for a given dialect name. Returns PostgresDialect as the default if the dialect is not found.
type Executor ¶ added in v0.3.1
type Executor struct {
// contains filtered or unexported fields
}
Executor implements execution.Executor for PostgreSQL databases.
func NewExecutor ¶ added in v0.3.1
NewExecutor creates a new SQL Executor with the given pool and config.
func (*Executor) Dialect ¶ added in v0.3.1
Dialect returns the SQL dialect name. This is a helper method for introspection, not part of the Executor interface.
func (*Executor) Mutate ¶ added in v0.3.1
Mutate executes a create/update/delete mutation and scans results into dest.
type PostgresDialect ¶ added in v0.3.1
type PostgresDialect struct{}
PostgresDialect implements Dialect for PostgreSQL.
func (PostgresDialect) CoalesceJSON ¶ added in v0.3.1
func (PostgresDialect) CoalesceJSON(expr exp.Expression, fallback string) exp.SQLFunctionExpression
func (PostgresDialect) JSONAgg ¶ added in v0.3.1
func (PostgresDialect) JSONAgg(expr exp.Expression) exp.SQLFunctionExpression
func (PostgresDialect) JSONBuildObject ¶ added in v0.3.1
func (PostgresDialect) JSONBuildObject(args ...any) exp.SQLFunctionExpression
type SQLQuery ¶ added in v0.3.1
type SQLQuery struct {
// contains filtered or unexported fields
}
SQLQuery implements builders.Query for SQL databases. It wraps the SQL string and prepared statement arguments.
func NewSQLQuery ¶ added in v0.3.1
NewSQLQuery creates a new SQLQuery with the given SQL and arguments.
func (SQLQuery) Native ¶ added in v0.3.1
Native returns the SQLQuery itself as the native query object. This allows type assertion: query.Native().(SQLQuery)
type TypeNameScanner ¶ added in v0.3.1
type TypeNameScanner[T any] struct { // contains filtered or unexported fields }
TypeNameScanner is a scanner for interface types that determines the concrete type based on a type discriminator field in the result. This is PostgreSQL-specific as it uses pgx types.
func NewTypeNameScanner ¶ added in v0.3.1
func NewTypeNameScanner[T any](types map[string]reflect.Type, typeNameKey string) *TypeNameScanner[T]
NewTypeNameScanner creates a new TypeNameScanner for the given types and type name key. The types map should map type names (lowercase) to their reflect.Type. The typeNameKey is the column name containing the type discriminator.
func (*TypeNameScanner[T]) ScanJson ¶ added in v0.3.1
func (t *TypeNameScanner[T]) ScanJson(data []byte) (T, error)
ScanJson scans JSON data into the appropriate concrete type based on the type discriminator.
func (*TypeNameScanner[T]) ScanRow ¶ added in v0.3.1
func (t *TypeNameScanner[T]) ScanRow(row pgx.CollectableRow) (T, error)
ScanRow scans a single row into the appropriate concrete type based on the type discriminator.