compiler

package
v1.15.10 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedStatementType = errors.New("parseQuery: unsupported statement type")

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
	DataType string
	NotNull  bool
	IsArray  bool
	IsSlice  bool
	Comment  string
	Length   *int

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

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

func (*Compiler) Catalog

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

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 Parameter

type Parameter struct {
	Number int
	Column *Column
}

这里存的是参数,in 之所以有问题是因为没有解析出Parameter,name 是Colum的name

type Parser

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

TODO: Rename this interface Engine

type Query

type Query struct {
	SQL                   string
	Name                  string
	Cmd                   string // TODO: Pick a better name. One of: one, many, exec, execrows
	Columns               []*Column
	Params                []Parameter
	Comments              []string
	InsertValuesLen       int64
	InsertValuesParameter []Parameter
	Omits                 []string
	IsRepeatValues        bool //插入多个值
	// XXX: Hack
	Filename string
}

type QueryCatalog

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

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