query

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LIMIT_COUNT  = "limit:count"
	LIMIT_OFFSET = "limit:offset"
	ORDERBY_ASC  = "orderby-asc"
	ORDERBY_DESC = "orderby-desc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LimitOption

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

type LocationOffset

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

type QueryBuilder

type QueryBuilder struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

func (*QueryBuilder) IsQueryIn

func (qb *QueryBuilder) IsQueryIn() bool

type QueryField

type QueryField struct {
	Name   string
	Type   T
	Alias  string
	IsLike bool
}

type QueryMetadata

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

func (*QueryMetadata) String

func (qm *QueryMetadata) String() string

type Raw

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

type RawQueryGenerator

type RawQueryGenerator struct{}

RawQueryGenerator is a generator for raw query. It should be available for all drivers.

func (*RawQueryGenerator) DriverName

func (rg *RawQueryGenerator) DriverName() string

func (*RawQueryGenerator) Generate

func (rg *RawQueryGenerator) Generate(meta generator.TMetadata) error

type RawQueryParser

type RawQueryParser interface {
	Parse(context.Context, string) (TableMetadata, *QueryBuilder, error)
	Flush()
}

RawQueryParser is a parser to extract metedata from sql query

type SQL

type SQL struct {
	RawQueryParser RawQueryParser
	// contains filtered or unexported fields
}

func NewSQL

func NewSQL(objs map[string]generator.IObject) *SQL

func (*SQL) Read

func (p *SQL) Read(path string) (*SQLMethod, error)

type SQLFile

type SQLFile struct {
	GoPackage string
	Methods   []*SQLMethod
	Dir       string
}

type SQLMethod

type SQLMethod struct {
	Name    string
	Fields  []*SQLMethodField
	Result  []*SQLMethodField
	Limit   *SQLMethodField
	Offset  *SQLMethodField
	OrderBy []*SQLMethodField

	SQL string

	Assign   string
	FromFile string
	QueryIn  bool
}

type SQLMethodField

type SQLMethodField struct {
	Name          string
	Raw           string
	Type          string
	FullName      string
	IsLike        bool
	IsOrderByDESC bool
}

type T

type T uint8
const (
	T_PLACEHOLDER T = iota
	T_INT
	T_STRING
	T_ARRAY_STRING
	T_ARRAY_INT
	T_ANY
)

func (T) BaseType

func (t T) BaseType() string

func (T) String

func (t T) String() string

type Table

type Table struct {
	Name  string
	Alias string
}

type TableMetadata

type TableMetadata map[Table]*QueryMetadata

func (TableMetadata) AppendParams

func (t TableMetadata) AppendParams(table string, params ...*QueryField)

func (TableMetadata) AppendResult

func (t TableMetadata) AppendResult(table string, result ...*QueryField)

func (TableMetadata) String

func (t TableMetadata) String() string

func (TableMetadata) Validate

func (tm TableMetadata) Validate(tableRef map[string]map[string]generator.IField) error

type TiDBParser

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

func NewTiDBParser

func NewTiDBParser() *TiDBParser

func (*TiDBParser) Flush

func (tp *TiDBParser) Flush()

func (*TiDBParser) Metadata

func (tp *TiDBParser) Metadata() string

func (*TiDBParser) Parse

func (tp *TiDBParser) Parse(ctx context.Context,
	query string,
) (TableMetadata, *QueryBuilder, error)

func (*TiDBParser) Query

func (tp *TiDBParser) Query() string

Jump to

Keyboard shortcuts

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