sql

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodOne   = 1
	MethodMany  = 2
	MethodExec  = 3
	MethodCount = 4

	ExecRetAffect = 1
	ExecRetLastid = 2
	ExecRetResult = 3
)
View Source
const (
	CondIf     = 1
	CondFor    = 2
	CondAlways = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckTask

type CheckTask struct {
	Name   string
	Sess   db.Session
	Sql    string
	Params []interface{}
}

type Cond

type Cond struct {
	Type int

	Cond  string
	Sep   string
	Slice string

	Pre  SQL
	Subs []*Cond
	Next SQL
}

type File

type File struct {
	ImplPath string

	Structs []*coder.GoStruct
	Methods []Method

	CheckTasks []*CheckTask

	Orms []Orm
	// contains filtered or unexported fields
}

func Compile

func Compile(data []string) (*File, error)

func (*File) Pkg

func (f *File) Pkg() string

func (*File) Tar

func (f *File) Tar() string

type Method

type Method struct {
	Type int

	GoName    string
	Comments  []string
	ParamDef  string
	RetGoName string
	RetFields []QueryField
	ExecRet   int

	Static    SQL
	IsDynamic bool

	Conds []*Cond
	// contains filtered or unexported fields
}

func (*Method) IsExec

func (m *Method) IsExec() bool

func (*Method) IsQuery

func (m *Method) IsQuery() bool

type Orm

type Orm struct {
	Name  string
	Table string
	Type  string

	Struct *coder.GoStruct
}

type QueryField

type QueryField struct {
	// 在database中的原始名称
	Name string
	// 该字段的表名称
	Table string
	// 该字段的表别名
	TableAlias string
	// 在sql中定义的字段别名
	Alias string
	// 由用户定义的,该字段的引用名称
	Ref string

	// 如果有alias,为alias的GoName形式
	// 如果没有alias,为name的GoName形式
	GoName string
}

QueryField 解析的sql语句查询字段,一般用于生成反序列化代码或生成查询返回的结构体

type SQL

type SQL struct {
	Text   string
	Params []string
}

Jump to

Keyboard shortcuts

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