filter

package
v0.0.0-...-912f3db Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandOp

type CommandOp int32
const (
	CmdEq CommandOp = iota
	CmdNotEq
	CmdGt
	CmdGte
	CmdLt
	CmdLte
	CmdIsNull
	CmdIsNotNull
	CmdLike
	CmdILike
	CmdIn
)

type ConditionNode

type ConditionNode struct {
	FieldIdx int
	Op       CommandOp
	Value    any
}

ConditionNode — лист дерева фильтра: одно условие над полем. EN: ConditionNode — filter tree leaf: a single condition on a field.

func Cond

func Cond(fieldIdx int, op CommandOp, value any) *ConditionNode

Cond создаёт узел условия: fieldIdx — индекс поля вstruct_info.TableFields, op — оператор, value — значение. EN: Cond creates a condition node: fieldIdx — field index instruct_info.TableFields, op — operator, value — value.

func (ConditionNode) Build

func (cn ConditionNode) Build(tf struct_info.TableFields, d dialect.SQLDialect, argIdx *int) (string, []any, error)

type Filter

type Filter struct {
	Offset uint32
	Limit  uint32
	Range  FilterNode
}

Filter — структура фильтра для Many(). Offset и Limit задают пагинацию, Range — дерево условий. EN: Filter — filter structure for Many(). Offset and Limit set pagination, Range — condition tree.

func (*Filter) BuildOffsetAndLimit

func (f *Filter) BuildOffsetAndLimit(d dialect.SQLDialect) string

func (*Filter) BuildWhere

func (f *Filter) BuildWhere(tf struct_info.TableFields, d dialect.SQLDialect) (query string, args []any, err error)

type FilterNode

type FilterNode interface {
	Build(tf struct_info.TableFields, d dialect.SQLDialect, argIdx *int) (clause string, args []any, err error)
}

FilterNode — интерфейс узла дерева фильтра. Реализации: ConditionNode (условие), GroupNode (And/Or/Not-группа). EN: FilterNode — filter tree node interface. Implementations: ConditionNode (condition), GroupNode (And/Or/Not group).

type GroupNode

type GroupNode struct {
	Logic    LogicOp
	Children []FilterNode
}

GroupNode — группа условий с логическим оператором. EN: GroupNode — group of conditions with a logical operator.

func And

func And(children ...FilterNode) *GroupNode

And создаёт группу с логическим AND. EN: And creates a logical AND group.

func Not

func Not(child FilterNode) *GroupNode

Not создаёт группу с логическим NOT (ровно один ребёнок). EN: Not creates a logical NOT group (exactly one child).

func Or

func Or(children ...FilterNode) *GroupNode

Or создаёт группу с логическим OR. EN: Or creates a logical OR group.

func (GroupNode) Build

func (gn GroupNode) Build(tf struct_info.TableFields, d dialect.SQLDialect, argIdx *int) (string, []any, error)

type LogicOp

type LogicOp int32
const (
	LogicAnd LogicOp = iota
	LogicOr
	LogicNot
)

Jump to

Keyboard shortcuts

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