sqlbind

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sqlbind parses and compiles typed SQL template sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(filename string, source []byte, options GenerateOptions) ([]byte, error)

Generate parses, validates, and compiles a SQL template module to Go.

Types

type BinaryExpr

type BinaryExpr = syntax.BinaryExpr

type Body

type Body = []Node

type CallExpr

type CallExpr = syntax.CallExpr

type CompileError

type CompileError struct {
	Filename string
	Pos      Position
	Message  string
}

func (*CompileError) Error

func (e *CompileError) Error() string

type ConditionalExpr

type ConditionalExpr = syntax.ConditionalExpr

type Declaration

type Declaration = syntax.Declaration

type EnumDecl

type EnumDecl = syntax.EnumDecl

type ExecutorResolver added in v0.1.6

type ExecutorResolver struct {
	PackagePath string
	Name        string
}

ExecutorResolver identifies a package function with the signature func(context.Context) (SQLExecutor, error).

type Expr

type Expr = syntax.Expr

type ExpressionNode

type ExpressionNode = syntax.ExpressionNode

type ExternalDecl

type ExternalDecl = syntax.ExternalDecl

type Field

type Field = syntax.Field

type ForNode

type ForNode = syntax.ForNode

type GenerateOptions

type GenerateOptions struct {
	Package string
	// PlaceholderStyle is "dollar" (the PostgreSQL default) or "question".
	PlaceholderStyle string
	// ContextAPI adds <Component>Context wrappers which resolve an executor
	// from context.Context while preserving the explicit executor APIs.
	ContextAPI bool
	// ExecutorResolver selects a framework-specific Context resolver. A nil
	// resolver uses sqlbind.SQLExecutorFromContext. Setting it implies ContextAPI.
	ExecutorResolver *ExecutorResolver
}

GenerateOptions controls SQL code generation.

type IdentifierExpr

type IdentifierExpr = syntax.IdentifierExpr

type IfNode

type IfNode = syntax.IfNode

type IndexExpr

type IndexExpr = syntax.IndexExpr

type LiteralExpr

type LiteralExpr = syntax.LiteralExpr

type MemberExpr

type MemberExpr = syntax.MemberExpr

type Module

type Module = syntax.Module

func Parse

func Parse(filename string, source []byte) (*Module, error)

Parse parses one SQL template module. SQL string literals, quoted identifiers, comments, and PostgreSQL dollar-quoted strings are kept losslessly and never interpreted as template syntax.

type Node

type Node = syntax.Node

type Parameter

type Parameter = syntax.Parameter

type ParseError

type ParseError = syntax.ParseError

type Position

type Position = syntax.Position

type RelationNode

type RelationNode struct {
	Kind      string   `json:"kind"`
	Pos       Position `json:"pos"`
	Name      string   `json:"name"`
	Arguments []Expr   `json:"arguments,omitempty"`
	Alias     string   `json:"alias"`
}

RelationNode is a structurally embedded private sql.relation<T> statement. It is emitted into the caller's builder, so placeholders remain globally ordered after runtime conditions are resolved.

func (*RelationNode) NodeType

func (n *RelationNode) NodeType() string

type TemplateDecl

type TemplateDecl = syntax.TemplateDecl

type TextNode

type TextNode struct {
	Kind string   `json:"kind"`
	Pos  Position `json:"pos"`
	Text string   `json:"text"`
}

func (*TextNode) NodeType

func (n *TextNode) NodeType() string

type TypeDecl

type TypeDecl = syntax.TypeDecl

type TypeRef

type TypeRef = syntax.TypeRef

type UnaryExpr

type UnaryExpr = syntax.UnaryExpr

Jump to

Keyboard shortcuts

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