v1

package
v0.0.0-...-36d8597 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Type_name = map[int32]string{
		0: "TYPE_UNSPECIFIED",
		1: "TYPE_SELECT",
		2: "TYPE_UPDATE",
		3: "TYPE_INSERT",
		4: "TYPE_DELETE",
		5: "TYPE_CREATE_TABLE",
		6: "TYPE_DROP_TABLE",
		7: "TYPE_CREATE_INDEX",
		8: "TYPE_DELETE_INDEX",
	}
	Type_value = map[string]int32{
		"TYPE_UNSPECIFIED":  0,
		"TYPE_SELECT":       1,
		"TYPE_UPDATE":       2,
		"TYPE_INSERT":       3,
		"TYPE_DELETE":       4,
		"TYPE_CREATE_TABLE": 5,
		"TYPE_DROP_TABLE":   6,
		"TYPE_CREATE_INDEX": 7,
		"TYPE_DELETE_INDEX": 8,
	}
)

Enum value maps for Type.

View Source
var (
	Operator_name = map[int32]string{
		0: "OPERATOR_UNSPECIFIED",
		1: "OPERATOR_EQ",
		2: "OPERATOR_NE",
		3: "OPERATOR_GT",
		4: "OPERATOR_LT",
		5: "OPERATOR_GTE",
		6: "OPERATOR_LTE",
	}
	Operator_value = map[string]int32{
		"OPERATOR_UNSPECIFIED": 0,
		"OPERATOR_EQ":          1,
		"OPERATOR_NE":          2,
		"OPERATOR_GT":          3,
		"OPERATOR_LT":          4,
		"OPERATOR_GTE":         5,
		"OPERATOR_LTE":         6,
	}
)

Enum value maps for Operator.

View Source
var File_shortdb_domain_query_v1_query_proto protoreflect.FileDescriptor

Functions

func Filter

func Filter[V vector.Type](LValue, RValue V, operator Operator) bool

func FilterBool

func FilterBool(LValue, RValue bool, operator Operator) bool

Types

type Condition

type Condition struct {

	// LValue is the left hand side operand
	LValue string `protobuf:"bytes,1,opt,name=l_value,json=lValue,proto3" json:"l_value,omitempty"`
	// LValueIsField determines if Operand1 is a literal or a field name
	LValueIsField bool `protobuf:"varint,2,opt,name=l_value_is_field,json=lValueIsField,proto3" json:"l_value_is_field,omitempty"`
	// Operator is e.g. "=", ">"
	Operator Operator `protobuf:"varint,3,opt,name=operator,proto3,enum=shortdb.domain.query.v1.Operator" json:"operator,omitempty"`
	// RValue is the right hand side operand
	RValue string `protobuf:"bytes,4,opt,name=r_value,json=rValue,proto3" json:"r_value,omitempty"`
	// RValueIsField determines if Operand2 is a literal or a field name
	RValueIsField bool `protobuf:"varint,5,opt,name=r_value_is_field,json=rValueIsField,proto3" json:"r_value_is_field,omitempty"`
	// contains filtered or unexported fields
}

Condition is a single boolean condition in a WHERE clause

func (*Condition) Descriptor deprecated

func (*Condition) Descriptor() ([]byte, []int)

Deprecated: Use Condition.ProtoReflect.Descriptor instead.

func (*Condition) GetLValue

func (x *Condition) GetLValue() string

func (*Condition) GetLValueIsField

func (x *Condition) GetLValueIsField() bool

func (*Condition) GetOperator

func (x *Condition) GetOperator() Operator

func (*Condition) GetRValue

func (x *Condition) GetRValue() string

func (*Condition) GetRValueIsField

func (x *Condition) GetRValueIsField() bool

func (*Condition) ProtoMessage

func (*Condition) ProtoMessage()

func (*Condition) ProtoReflect

func (x *Condition) ProtoReflect() protoreflect.Message

func (*Condition) Reset

func (x *Condition) Reset()

func (*Condition) String

func (x *Condition) String() string

type Join

type Join struct {
	Type       string           `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	Table      string           `protobuf:"bytes,2,opt,name=table,proto3" json:"table,omitempty"`
	Conditions []*JoinCondition `protobuf:"bytes,3,rep,name=conditions,proto3" json:"conditions,omitempty"`
	// contains filtered or unexported fields
}

func (*Join) Descriptor deprecated

func (*Join) Descriptor() ([]byte, []int)

Deprecated: Use Join.ProtoReflect.Descriptor instead.

func (*Join) GetConditions

func (x *Join) GetConditions() []*JoinCondition

func (*Join) GetTable

func (x *Join) GetTable() string

func (*Join) GetType

func (x *Join) GetType() string

func (*Join) ProtoMessage

func (*Join) ProtoMessage()

func (*Join) ProtoReflect

func (x *Join) ProtoReflect() protoreflect.Message

func (*Join) Reset

func (x *Join) Reset()

func (*Join) String

func (x *Join) String() string

type JoinCondition

type JoinCondition struct {

	// LHS table name
	LTable string `protobuf:"bytes,1,opt,name=l_table,json=lTable,proto3" json:"l_table,omitempty"`
	// Level operand is the left hand side operand
	LOperand string `protobuf:"bytes,2,opt,name=l_operand,json=lOperand,proto3" json:"l_operand,omitempty"`
	// Operator is e.g. "=", ">"
	Operator Operator `protobuf:"varint,3,opt,name=operator,proto3,enum=shortdb.domain.query.v1.Operator" json:"operator,omitempty"`
	// RHS table name
	RTable string `protobuf:"bytes,4,opt,name=r_table,json=rTable,proto3" json:"r_table,omitempty"`
	// Right operand1 is the right hand side operand
	ROperand string `protobuf:"bytes,5,opt,name=r_operand,json=rOperand,proto3" json:"r_operand,omitempty"`
	// contains filtered or unexported fields
}

Condition is a single boolean condition in a WHERE clause

func (*JoinCondition) Descriptor deprecated

func (*JoinCondition) Descriptor() ([]byte, []int)

Deprecated: Use JoinCondition.ProtoReflect.Descriptor instead.

func (*JoinCondition) GetLOperand

func (x *JoinCondition) GetLOperand() string

func (*JoinCondition) GetLTable

func (x *JoinCondition) GetLTable() string

func (*JoinCondition) GetOperator

func (x *JoinCondition) GetOperator() Operator

func (*JoinCondition) GetROperand

func (x *JoinCondition) GetROperand() string

func (*JoinCondition) GetRTable

func (x *JoinCondition) GetRTable() string

func (*JoinCondition) ProtoMessage

func (*JoinCondition) ProtoMessage()

func (*JoinCondition) ProtoReflect

func (x *JoinCondition) ProtoReflect() protoreflect.Message

func (*JoinCondition) Reset

func (x *JoinCondition) Reset()

func (*JoinCondition) String

func (x *JoinCondition) String() string

type Operator

type Operator int32

Operator is between operands in a condition

const (
	// OPERATOR_UNSPECIFIED is the zero value for an Operator
	Operator_OPERATOR_UNSPECIFIED Operator = 0
	Operator_OPERATOR_EQ          Operator = 1 // Eq -> "="
	Operator_OPERATOR_NE          Operator = 2 // Ne -> "!="
	Operator_OPERATOR_GT          Operator = 3 // Gt -> ">"
	Operator_OPERATOR_LT          Operator = 4 // Lt -> "<"
	Operator_OPERATOR_GTE         Operator = 5 // Gte -> ">="
	Operator_OPERATOR_LTE         Operator = 6 // Lte -> "<="
)

func (Operator) Descriptor

func (Operator) Descriptor() protoreflect.EnumDescriptor

func (Operator) Enum

func (x Operator) Enum() *Operator

func (Operator) EnumDescriptor deprecated

func (Operator) EnumDescriptor() ([]byte, []int)

Deprecated: Use Operator.Descriptor instead.

func (Operator) Number

func (x Operator) Number() protoreflect.EnumNumber

func (Operator) String

func (x Operator) String() string

func (Operator) Type

type Query

type Query struct {
	FieldMask   *fieldmaskpb.FieldMask `protobuf:"bytes,16,opt,name=field_mask,json=fieldMask,proto3" json:"field_mask,omitempty"`
	Type        Type                   `protobuf:"varint,1,opt,name=type,proto3,enum=shortdb.domain.query.v1.Type" json:"type,omitempty"`
	Database    string                 `protobuf:"bytes,2,opt,name=database,proto3" json:"database,omitempty"`
	TableName   string                 `protobuf:"bytes,3,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty"`
	TableFields map[string]v1.Type     `` /* 217-byte string literal not displayed */
	Indexs      []*v11.Index           `protobuf:"bytes,5,rep,name=indexs,proto3" json:"indexs,omitempty"`
	Conditions  []*Condition           `protobuf:"bytes,6,rep,name=conditions,proto3" json:"conditions,omitempty"`
	Updates     map[string]string      `` /* 155-byte string literal not displayed */
	Inserts     []*Query_Array         `protobuf:"bytes,8,rep,name=inserts,proto3" json:"inserts,omitempty"`
	// Used for SELECT (i.e. SELECTed field names) and INSERT (INSERTEDed field names)
	Fields      []string          `protobuf:"bytes,9,rep,name=fields,proto3" json:"fields,omitempty"`
	Aliases     map[string]string `` /* 156-byte string literal not displayed */
	OrderFields []string          `protobuf:"bytes,11,rep,name=order_fields,json=orderFields,proto3" json:"order_fields,omitempty"`
	OrderDir    []string          `protobuf:"bytes,12,rep,name=order_dir,json=orderDir,proto3" json:"order_dir,omitempty"`
	Joins       []*Join           `protobuf:"bytes,13,rep,name=joins,proto3" json:"joins,omitempty"`
	MaxRows     int32             `protobuf:"varint,14,opt,name=max_rows,json=maxRows,proto3" json:"max_rows,omitempty"`
	Limit       int32             `protobuf:"varint,15,opt,name=limit,proto3" json:"limit,omitempty"`
	// contains filtered or unexported fields
}

Query represents a parsed query

func New

func New() *Query

func (*Query) Descriptor deprecated

func (*Query) Descriptor() ([]byte, []int)

Deprecated: Use Query.ProtoReflect.Descriptor instead.

func (*Query) GetAliases

func (x *Query) GetAliases() map[string]string

func (*Query) GetConditions

func (x *Query) GetConditions() []*Condition

func (*Query) GetDatabase

func (x *Query) GetDatabase() string

func (*Query) GetFieldMask

func (x *Query) GetFieldMask() *fieldmaskpb.FieldMask

func (*Query) GetFields

func (x *Query) GetFields() []string

func (*Query) GetIndexs

func (x *Query) GetIndexs() []*v11.Index

func (*Query) GetInserts

func (x *Query) GetInserts() []*Query_Array

func (*Query) GetJoins

func (x *Query) GetJoins() []*Join

func (*Query) GetLimit

func (x *Query) GetLimit() int32

func (*Query) GetMaxRows

func (x *Query) GetMaxRows() int32

func (*Query) GetOrderDir

func (x *Query) GetOrderDir() []string

func (*Query) GetOrderFields

func (x *Query) GetOrderFields() []string

func (*Query) GetTableFields

func (x *Query) GetTableFields() map[string]v1.Type

func (*Query) GetTableName

func (x *Query) GetTableName() string

func (*Query) GetType

func (x *Query) GetType() Type

func (*Query) GetUpdates

func (x *Query) GetUpdates() map[string]string

func (*Query) IsFilter

func (q *Query) IsFilter(record *page.Row, fields map[string]field.Type) bool

func (*Query) IsLimit

func (q *Query) IsLimit() bool

func (*Query) ProtoMessage

func (*Query) ProtoMessage()

func (*Query) ProtoReflect

func (x *Query) ProtoReflect() protoreflect.Message

func (*Query) Reset

func (x *Query) Reset()

func (*Query) String

func (x *Query) String() string

type Query_Array

type Query_Array struct {
	Items []string `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
	// contains filtered or unexported fields
}

func (*Query_Array) Descriptor deprecated

func (*Query_Array) Descriptor() ([]byte, []int)

Deprecated: Use Query_Array.ProtoReflect.Descriptor instead.

func (*Query_Array) GetItems

func (x *Query_Array) GetItems() []string

func (*Query_Array) ProtoMessage

func (*Query_Array) ProtoMessage()

func (*Query_Array) ProtoReflect

func (x *Query_Array) ProtoReflect() protoreflect.Message

func (*Query_Array) Reset

func (x *Query_Array) Reset()

func (*Query_Array) String

func (x *Query_Array) String() string

type Type

type Type int32

Type is the type of SQL query, e.g. SELECT/UPDATE

const (
	// TYPE_UNSPECIFIED is the zero value for a Type
	Type_TYPE_UNSPECIFIED Type = 0
	// TYPE_SELECT represents a SELECT query
	Type_TYPE_SELECT Type = 1
	// TYPE_UPDATE represents an UPDATE query
	Type_TYPE_UPDATE Type = 2
	// TYPE_INSERT represents an INSERT query
	Type_TYPE_INSERT Type = 3
	// TYPE_DELETE represents a DELETE query
	Type_TYPE_DELETE Type = 4
	// TYPE_CREATE_TABLE represents a CREATE TABLE query
	Type_TYPE_CREATE_TABLE Type = 5
	// TYPE_DROP_TABLE represents a DROP TABLE query
	Type_TYPE_DROP_TABLE Type = 6
	// TYPE_CREATE_INDEX represents a CREATE INDEX query
	Type_TYPE_CREATE_INDEX Type = 7
	// TYPE_CREATE_INDEX represents a DELETE INDEX query
	Type_TYPE_DELETE_INDEX Type = 8
)

func (Type) Descriptor

func (Type) Descriptor() protoreflect.EnumDescriptor

func (Type) Enum

func (x Type) Enum() *Type

func (Type) EnumDescriptor deprecated

func (Type) EnumDescriptor() ([]byte, []int)

Deprecated: Use Type.Descriptor instead.

func (Type) Number

func (x Type) Number() protoreflect.EnumNumber

func (Type) String

func (x Type) String() string

func (Type) Type

func (Type) Type() protoreflect.EnumType

Jump to

Keyboard shortcuts

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