sqlfly

package module
v0.0.0-...-0efd16a Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

README

sqlfly

Golang Inmemory Database

Documentation

Index

Constants

View Source
const (
	OpEqual Operator = iota
	OpNotEqual
	OpLessThan
	OpLessThanEqual
	OpGreaterThan
	OpGreaterThanEqual

	OrderASC Ordering = iota
	OrderDESC

	BaseKindInt BaseKind = iota
	BaseKindUint
	BaseKindFloat
	BaseKindBool
	BaseKindString
	BaseKindTime
	BaseKindOther
)

Variables

View Source
var (
	// ErrMetaNotAStruct error returned if the specified meta is not a struct
	ErrMetaNotAStruct = fmt.Errorf("the table meta data is not a struct")

	// ErrInvalidColumnName error returned if the specified column name is not valid
	ErrInvalidColumnName = fmt.Errorf("invalid column name")

	// ErrColumnNameEmpty error returned if any of the specified column name is an empty string
	ErrColumnNameEmpty = fmt.Errorf("%w : specified column name is empty", ErrInvalidColumnName)

	// ErrColumnNameNotExist error returned if any of the specified column name is not matching any field in the meta type
	ErrColumnNameNotExist = fmt.Errorf("%w : specified column name not exist in struct", ErrInvalidColumnName)

	// ErrUniquesColumnNameNotExist error returned if any othe specified unique column name is not matching any field in the meta type
	ErrUniquesColumnNameNotExist = fmt.Errorf("%w : unique column", ErrColumnNameNotExist)

	// ErrNullsColumnNameNotExist error returned if any of the specified nullable column name is not matching any field of the meta type
	ErrNullsColumnNameNotExist = fmt.Errorf("%w : null column", ErrColumnNameNotExist)

	// ErrInsertError errors returned when theres a problem during inserting a data into StructTable
	ErrInsertError = fmt.Errorf("problem when inserting data")

	// ErrCanNotInsertNoStructType errors returned when the data to insert is not a struct
	ErrCanNotInsertNoStructType = fmt.Errorf("%w : can not insert non struct", ErrInsertError)

	// ErrCanNotInsertNonNativeType errors returned when the data to insert is not a struct
	ErrCanNotInsertNonNativeType = fmt.Errorf("%w : can not insert non native field", ErrInsertError)

	// ErrIncompatibleStruct errors returned when data to insert is not compatible with the meta struct
	ErrIncompatibleStruct = fmt.Errorf("%w : incompatible struct to insert", ErrInsertError)

	// ErrUniqueConstraintViolation error returned when a inserted field value is duplicated violating unique constraint
	ErrUniqueConstraintViolation = fmt.Errorf("%w : unique field constraint violation", ErrInsertError)

	// ErrEvaluationError errors returned when cel-go evaluation yield error
	ErrEvaluationError = fmt.Errorf("problem when evaluating data")
)

Functions

func Contains

func Contains(arr []string, s string) bool

Contains check the existence of a string in string array

func StructShallowEquals

func StructShallowEquals(one, two interface{}) bool

func ToMap

func ToMap(strck interface{}) map[string]interface{}

Types

type BaseKind

type BaseKind int

func GetBaseKind

func GetBaseKind(value reflect.Value) BaseKind

func GetBaseKindOfType

func GetBaseKindOfType(typ reflect.Type) BaseKind

type KeyValue

type KeyValue struct {
	Key   string
	Value reflect.Value
}

type KeyValueCompare

type KeyValueCompare struct {
	KeyValue
	Op Operator
}

type Operator

type Operator int

type Order

type Order struct {
	Key      string
	Ordering Ordering
}

type Ordering

type Ordering int

type StructTable

type StructTable struct {
	MetaType reflect.Type
	Uniques  []string
	// contains filtered or unexported fields
}

func NewStructTable

func NewStructTable(metaType reflect.Type, uniques []string) (*StructTable, error)

func (*StructTable) Count

func (st *StructTable) Count() int

func (*StructTable) Delete

func (st *StructTable) Delete(where string) (int, error)

func (*StructTable) Insert

func (st *StructTable) Insert(data interface{}) error

func (*StructTable) Select

func (st *StructTable) Select(where string, orderBy []Order, offset, len int) ([]interface{}, error)

func (*StructTable) Update

func (st *StructTable) Update(set []KeyValue, where string) (int, error)

Jump to

Keyboard shortcuts

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