compiler

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTableName

func ParseTableName(node ast.Node) (*ast.TableName, error)

func ParseTypeName

func ParseTypeName(node ast.Node) (*ast.TypeName, error)

Types

type Column

type Column struct {
	Name         string
	OriginalName string
	DataType     string
	NotNull      bool
	Unsigned     bool
	IsArray      bool
	ArrayDims    int
	Comment      string
	Length       *int
	IsNamedParam bool
	IsFuncCall   bool

	// XXX: Figure out what PostgreSQL calls `foo.id`
	Scope      string
	Table      *ast.TableName
	TableAlias string
	Type       *ast.TypeName
	EmbedTable *ast.TableName

	IsSqlcSlice bool // is this sqlc.slice()
	// contains filtered or unexported fields
}

func ConvertColumn

func ConvertColumn(rel *ast.TableName, c *catalog.Column) *Column

type Compiler

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

func NewCompiler

func NewCompiler(conf config.SQL, combo config.CombinedSettings) (*Compiler, error)

func (*Compiler) Catalog

func (c *Compiler) Catalog() *catalog.Catalog

func (*Compiler) Close added in v1.23.0

func (c *Compiler) Close(ctx context.Context)

func (*Compiler) OutputColumns

func (c *Compiler) OutputColumns(stmt ast.Node) ([]*catalog.Column, error)

OutputColumns determines which columns a statement will output

func (*Compiler) ParseCatalog

func (c *Compiler) ParseCatalog(schema []string) error

func (*Compiler) ParseQueries

func (c *Compiler) ParseQueries(queries []string, o opts.Parser) error

func (*Compiler) Result

func (c *Compiler) Result() *Result

type Function

type Function struct {
	Rel        *ast.FuncName
	ReturnType *ast.TypeName
	Outs       []*catalog.Argument
}

type Parameter

type Parameter struct {
	Number int
	Column *Column
}

type Parser

type Parser interface {
	Parse(io.Reader) ([]ast.Statement, error)
	CommentSyntax() source.CommentSyntax
	IsReservedKeyword(string) bool
}

TODO: Rename this interface Engine

type Query

type Query struct {
	SQL      string
	Metadata metadata.Metadata
	Columns  []*Column
	Params   []Parameter

	// Needed for CopyFrom
	InsertIntoTable *ast.TableName

	// Needed for vet
	RawStmt *ast.RawStmt
}

type QueryCatalog

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

func (QueryCatalog) GetFunc

func (qc QueryCatalog) GetFunc(rel *ast.FuncName) (*Function, error)

func (QueryCatalog) GetTable

func (qc QueryCatalog) GetTable(rel *ast.TableName) (*Table, error)

type Relation

type Relation struct {
	Catalog string
	Schema  string
	Name    string
}

func ParseRelationString

func ParseRelationString(name string) (*Relation, error)

type Result

type Result struct {
	Catalog *catalog.Catalog
	Queries []*Query
}

type Table

type Table struct {
	Rel     *ast.TableName
	Columns []*Column
}

Jump to

Keyboard shortcuts

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