field

package
v0.0.0-...-1f77496 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFieldFlag is `FieldNameFlag`.
	DefaultFieldFlag = FieldNameFlag
	// CheckFieldFlag includes `FieldNameFlag` and `OrgFieldNameFlag`.
	CheckFieldFlag = FieldNameFlag | OrgFieldNameFlag
)
View Source
const (
	// OrgFieldNameFlag is origin filed name flag.
	OrgFieldNameFlag uint32 = 1 << iota
	// FieldNameFlag is filed name flag.
	FieldNameFlag
)

Variables

This section is empty.

Functions

func CheckAllFieldNames

func CheckAllFieldNames(names []string, fields []*ResultField, flag uint32) error

CheckAllFieldNames checks whether names has unknown or ambiguous field in ResultFields.

func CheckAmbiguousField

func CheckAmbiguousField(name string, fields []*ResultField, flag uint32) error

CheckAmbiguousField checks whether name is an ambiguous field in ResultFields.

func CheckFieldName

func CheckFieldName(name string, fields []*ResultField, flag uint32) error

CheckFieldName checks whether name is an unknown or ambiguous field in ResultFields.

func CheckFieldsEqual

func CheckFieldsEqual(xname, yname string) bool

CheckFieldsEqual checks if xname and yname is equal. xname/yname in the pattern dbname.tablename.fieldname If any part of any argument is missing, it will ignore it and continue check other parts. So a.b.c equals b.c

func CheckWildcardField

func CheckWildcardField(name string) (string, bool, error)

CheckWildcardField checks wildcard field, like `*` or `table.*` or `db.table.*`.

func ContainAllFieldNames

func ContainAllFieldNames(names []string, fields []*ResultField, flag uint32) bool

ContainAllFieldNames checks whether names are all in ResultFields. TODO: add alias table name support

func ContainFieldName

func ContainFieldName(name string, fields []*ResultField, flag uint32) bool

ContainFieldName checks whether name is in ResultFields.

func GetFieldIndex

func GetFieldIndex(name string, fields []*Field, flag uint32) []int

GetFieldIndex gets name index in Fields.

func GetResultFieldIndex

func GetResultFieldIndex(name string, fields []*ResultField, flag uint32) []int

GetResultFieldIndex gets name index in ResultFields.

func JoinQualifiedName

func JoinQualifiedName(db string, table string, field string) string

JoinQualifiedName converts db, table, field to a qualified name.

func RFQNames

func RFQNames(l []*ResultField) []string

RFQNames gets all ResultField names.

Types

type Field

type Field struct {
	Expr expression.Expression
	Name string
}

Field is used for parsing column name from SQL.

func (*Field) String

func (f *Field) String() string

String implements fmt.Stringer interface.

type Opt

type Opt struct {
	IsUnsigned bool
	IsZerofill bool
}

Opt is used for parsing data type option from SQL.

type ResultField

type ResultField struct {
	column.Col   // Col.Name is OrgName.
	Name         string
	TableName    string
	OrgTableName string
	DBName       string
}

ResultField provides meta data of table column.

func CloneFieldByName

func CloneFieldByName(name string, fields []*ResultField, flag uint32) (*ResultField, error)

CloneFieldByName clones a ResultField in ResultFields according to name.

func ColToResultField

func ColToResultField(col *column.Col, tableName string) *ResultField

ColToResultField converts Col to ResultField.

func ColsToResultFields

func ColsToResultFields(cols []*column.Col, tableName string) []*ResultField

ColsToResultFields converts Cols to ResultFields.

func (*ResultField) Clone

func (rf *ResultField) Clone() *ResultField

Clone clones a new ResultField from old ResultField.

func (*ResultField) String

func (rf *ResultField) String() string

String implements fmt.Stringer interface.

Jump to

Keyboard shortcuts

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