expr

package
v0.0.0-...-c824f4b Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Overview

Package expr contain expression types that can be used to handle AIP based requests.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrComposerEmptySelector = errors.New("empty selector")
)

Functions

This section is empty.

Types

type AndExpr

type AndExpr struct {
	// Expr is a list of expressions that should be evaluated with AND operator.
	Expr []FilterExpr
	// contains filtered or unexported fields
}

AndExpr is an expression that can be evaluated.

func AcquireAndExpr

func AcquireAndExpr() *AndExpr

AcquireAndExpr acquires an AndExpr from the pool. Once acquired it must be released via Free method.

func (*AndExpr) Clone

func (e *AndExpr) Clone() Expr

Clone returns a deep copy of the AndExpr.

func (*AndExpr) Complexity

func (e *AndExpr) Complexity() int64

Complexity of the AndExpr is the sum of complexities of the inner expressions + 1.

func (*AndExpr) Equals

func (e *AndExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*AndExpr) Free

func (e *AndExpr) Free()

Free puts the AndExpr back to the pool.

type ArrayExpr

type ArrayExpr struct {
	// Elements is a list of expression values.
	Elements []FilterExpr
	// contains filtered or unexported fields
}

ArrayExpr is an expression that can be represented as an array of expressions.

func AcquireArrayExpr

func AcquireArrayExpr() *ArrayExpr

AcquireArrayExpr acquires an ArrayExpr from the pool. Once acquired it must be released via Free method.

func (*ArrayExpr) Clone

func (e *ArrayExpr) Clone() Expr

Clone returns a copy of the ArrayExpr.

func (*ArrayExpr) Complexity

func (e *ArrayExpr) Complexity() int64

Complexity of the ArrayExpr is the number of values + 1.

func (*ArrayExpr) Equals

func (e *ArrayExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*ArrayExpr) Free

func (e *ArrayExpr) Free()

Free puts the ArrayExpr back to the pool.

type ArrayUpdateExpr

type ArrayUpdateExpr struct {
	// Elements is a list of expression values.
	Elements []*UpdateExpr
	// contains filtered or unexported fields
}

ArrayUpdateExpr is an expression that can be used as a value in UpdateExpr. It describes an input array of UpdateExpr.

func AcquireArrayUpdateExpr

func AcquireArrayUpdateExpr() *ArrayUpdateExpr

AcquireArrayUpdateExpr acquires an ArrayUpdateExpr from the pool. Once acquired it must be released via Free method.

func (*ArrayUpdateExpr) Clone

func (e *ArrayUpdateExpr) Clone() Expr

Clone returns a copy of the ArrayUpdateExpr.

func (*ArrayUpdateExpr) Equals

func (e *ArrayUpdateExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*ArrayUpdateExpr) Free

func (e *ArrayUpdateExpr) Free()

Free puts the ArrayUpdateExpr back to the pool.

type Comparator

type Comparator int

Comparator is a defined type for comparators.

const (

	// EQ is the equal to comparator.
	EQ Comparator
	// LE is the less than or equal to comparator.
	LE
	// LT is the less than comparator.
	LT
	// GE is the greater than or equal to comparator.
	GE
	// GT is the greater than comparator.
	GT
	// NE is the not equal to comparator.
	NE
	// HAS is the has comparator.
	HAS
	// IN is the in comparator.
	IN
)

func (Comparator) String

func (c Comparator) String() string

String returns the string representation of the comparator.

type CompareExpr

type CompareExpr struct {
	// Left is the left hand side of the expression, the field to compare.
	Left FilterExpr

	// Comparator is the comparator to use.
	Comparator Comparator

	// Right is the right hand side of the expression, the value to compare to.
	Right FilterExpr
	// contains filtered or unexported fields
}

CompareExpr is a restriction

func AcquireCompareExpr

func AcquireCompareExpr() *CompareExpr

AcquireCompareExpr acquires a CompareExpr from the pool. Once acquired it must be released via Free method.

func (*CompareExpr) Clone

func (x *CompareExpr) Clone() Expr

Clone returns a copy of the CompareExpr.

func (*CompareExpr) Complexity

func (x *CompareExpr) Complexity() int64

Complexity returns the complexity of the expression. The complexity is taken from the field options.

func (*CompareExpr) Equals

func (x *CompareExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*CompareExpr) Free

func (x *CompareExpr) Free()

Free puts the CompareExpr back to the pool.

type Composer

type Composer struct {
	Desc protoreflect.MessageDescriptor
}

Composer is an expression composer that can be used to efficiently compose filter expressions. Each composed expression is allocated from the pool, and needs to be released back to the pool after use by calling Free method. If the expression is composed into a larger expression, then the larger expression is responsible for releasing the sub-expression, thus only a single call to Free is required.

func (*Composer) And

func (c *Composer) And(sub ...FilterExpr) *AndExpr

And returns an AndExpr that can be used to compose a filter expression.

Example
package main

import (
	"github.com/blockysource/blocky-aip/expr"
	"github.com/blockysource/blocky-aip/internal/testpb"
)

func main() {
	md := new(testpb.Message).ProtoReflect().Descriptor()

	c := expr.Composer{Desc: md}

	// (i32 > 1) && (i64 < 2)
	x := c.And(
		c.Composite(
			c.Compare(
				c.MustSelect("i32"),
				expr.GT,
				c.Value(1),
			),
		),
		c.Composite(
			c.Compare(
				c.MustSelect("i64"),
				expr.LT,
				c.Value(2),
			),
		),
	)
	defer x.Free()

}
Output:

func (*Composer) Array

func (c *Composer) Array(v ...FilterExpr) *ArrayExpr

Array returns an ArrayExpr that can be used to compose a filter expression.

func (*Composer) Compare

func (c *Composer) Compare(left FilterExpr, cmp Comparator, right FilterExpr) *CompareExpr

Compare returns a CompareExpr that can be used to compose a filter expression.

func (*Composer) Composite

func (c *Composer) Composite(x FilterExpr) *CompositeExpr

Composite returns a CompositeExpr that can be used to compose a filter expression.

func (*Composer) Field

func (c *Composer) Field(field string) (*FieldSelectorExpr, error)

Field parses the selector and returns a field selector expression.

func (*Composer) FunctionCall

func (c *Composer) FunctionCall(pkgName, name string, args ...FilterExpr) *FunctionCallExpr

FunctionCall returns a FunctionCallExpr that can be used to compose a filter expression.

func (*Composer) MapKey

func (c *Composer) MapKey(key FilterExpr) *MapKeyExpr

MapKey returns a MapKeyExpr that can be used to compose a filter expression.

func (*Composer) MapValue

func (c *Composer) MapValue(values ...MapValueExprEntry) *MapValueExpr

MapValue returns a MapValueExpr that can be used to compose a filter expression.

func (*Composer) MustOrderByField

func (c *Composer) MustOrderByField(field string, o Order) *OrderByFieldExpr

MustOrderByField returns an OrderByFieldExpr that can be used to compose a filter expression. It panics if the field is invalid.

func (*Composer) MustSelect

func (c *Composer) MustSelect(selector string) *FieldSelectorExpr

MustSelect parses the selector and returns a field selector expression. It panics if the selector is invalid.

func (*Composer) Not

func (c *Composer) Not(sub FilterExpr) *NotExpr

Not returns a NotExpr that can be used to compose a filter expression.

func (*Composer) Or

func (c *Composer) Or(sub ...FilterExpr) *OrExpr

Or returns an OrExpr that can be used to compose a filter expression.

func (*Composer) OrderBy

func (c *Composer) OrderBy(fields ...*OrderByFieldExpr) *OrderByExpr

OrderBy returns an OrderByExpr that can be used to compose a filter expression.

func (*Composer) OrderByField

func (c *Composer) OrderByField(field string, o Order) (*OrderByFieldExpr, error)

OrderByField returns an OrderByFieldExpr that can be used to compose a filter expression.

func (*Composer) Pagination

func (c *Composer) Pagination(pageSize, skip int32) *PaginationExpr

Pagination returns a PaginationExpr that can be used to compose a filter expression.

func (*Composer) Reset

Reset the composer.

func (*Composer) Value

func (c *Composer) Value(v any) *ValueExpr

Value returns a ValueExpr that can be used to compose a filter expression.

type CompositeExpr

type CompositeExpr struct {
	// Expr is the expression to wrap.
	Expr FilterExpr
	// contains filtered or unexported fields
}

CompositeExpr is a composite expression that wraps current expression into logical group.

func AcquireCompositeExpr

func AcquireCompositeExpr() *CompositeExpr

AcquireCompositeExpr acquires a CompositeExpr from the pool. Once acquired it must be released via Free method.

func (*CompositeExpr) Clone

func (e *CompositeExpr) Clone() Expr

Clone returns a copy of the current expression.

func (*CompositeExpr) Complexity

func (e *CompositeExpr) Complexity() int64

Complexity of the CompositeExpr is the complexity of the inner expression + 1.

func (*CompositeExpr) Equals

func (e *CompositeExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*CompositeExpr) Free

func (e *CompositeExpr) Free()

Free puts the CompositeExpr back to the pool.

type Expr

type Expr interface {
	// Free releases expression resources.
	// No further calls to the expression are allowed after calling Free.
	// This should release the resource related to the expression back to the pool.
	Free()

	// Equals returns true if the expression is equal to the other expression.
	Equals(other Expr) bool

	// Clone returns a deep copy of the expression.
	Clone() Expr
}

Expr is a generic expression interface that can be used to represent any expression.

type FieldSelectorExpr

type FieldSelectorExpr struct {
	// Message is the message descriptor of the literal.
	Message protoreflect.FullName

	// Field is the field name of the literal.
	Field protoreflect.Name

	// Traversal is the expression related to this field literal.
	// This field is used as a linked list to traverse the field literals.
	// The whole path can be reconstructed by traversing the linked list.
	// It may be another FieldSelectorExpr, MapKeyExpr and MessageSelectExpr.
	Traversal Expr

	// FieldComplexity is the complexity of the field, assigned by the parser.
	FieldComplexity int64
	// contains filtered or unexported fields
}

FieldSelectorExpr is a literal that represents a message field or a path of fields. It describes the expression "a.b.c" where b is a field of a, and c is a field of b.

func AcquireFieldSelectorExpr

func AcquireFieldSelectorExpr() *FieldSelectorExpr

AcquireFieldSelectorExpr acquires a FieldSelectorExpr from the pool. Once acquired it must be released via Free method.

func (*FieldSelectorExpr) Clone

func (e *FieldSelectorExpr) Clone() Expr

Clone returns a copy of the FieldSelectorExpr.

func (*FieldSelectorExpr) Complexity

func (e *FieldSelectorExpr) Complexity() int64

Complexity returns the complexity of the field literal.

func (*FieldSelectorExpr) Equals

func (e *FieldSelectorExpr) Equals(o Expr) bool

func (*FieldSelectorExpr) Free

func (e *FieldSelectorExpr) Free()

Free puts the FieldSelectorExpr back to the pool.

type FilterExpr

type FilterExpr interface {
	// Complexity returns approximate complexity of the expression.
	// It is used to estimate the cost of the expression.
	// The complexity is a number of nodes in the expression tree,
	// increased by field defined complexity.
	// Each expression evaluates its complexity based on its rules.
	Complexity() int64

	// Free releases expression resources.
	// No further calls to the expression are allowed after calling Free.
	// This should release the resource related to the expression back to the pool.
	Free()

	// Equals returns true if the expression is equal to the other expression.
	Equals(other Expr) bool

	// Clone returns a copy of the expression.
	Clone() Expr
	// contains filtered or unexported methods
}

FilterExpr is a filter expression that can be evaluated.

type FunctionCallExpr

type FunctionCallExpr struct {
	// PkgName is the name of the package where the function is defined.
	PkgName string

	// Name is the name of the function call.
	Name string

	// Arguments is a list of arguments of the function call.
	// If empty then the function call has no arguments.
	Arguments []FilterExpr

	// CallComplexity is the complexity of the function call,
	// predefined by the parser or the function call handler.
	CallComplexity int64
	// contains filtered or unexported fields
}

FunctionCallExpr is an expression that represents a function call. It should be used by the service that handles the function call. It may be used by the Database, filtering service, etc.

func AcquireFunctionCallExpr

func AcquireFunctionCallExpr() *FunctionCallExpr

AcquireFunctionCallExpr acquires a FunctionCallExpr from the pool. Once acquired it must be released via Free method.

func (*FunctionCallExpr) Clone

func (x *FunctionCallExpr) Clone() Expr

Clone returns a copy of the current expression.

func (*FunctionCallExpr) Complexity

func (x *FunctionCallExpr) Complexity() int64

Complexity returns the complexity of the expression.

func (*FunctionCallExpr) Equals

func (x *FunctionCallExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*FunctionCallExpr) Free

func (x *FunctionCallExpr) Free()

Free puts the FunctionCallExpr back to the pool.

func (*FunctionCallExpr) FullName

func (x *FunctionCallExpr) FullName() string

type MapKeyExpr

type MapKeyExpr struct {
	// Key is the key expression of the map field.
	Key Expr
	// Traversal is the traversal expression of the map field.
	Traversal Expr
	// contains filtered or unexported fields
}

MapKeyExpr is an expression that represents a map field - key. This expression might be used for filtering map key presence or for filtering map key value.

func AcquireMapKeyExpr

func AcquireMapKeyExpr() *MapKeyExpr

AcquireMapKeyExpr acquires a MapKeyExpr from the pool. Once acquired it must be released via Free method.

func (*MapKeyExpr) Clone

func (e *MapKeyExpr) Clone() Expr

Clone returns a copy of the MapKeyExpr.

func (*MapKeyExpr) Complexity

func (e *MapKeyExpr) Complexity() int64

Complexity returns the complexity of the expression.

func (*MapKeyExpr) Equals

func (e *MapKeyExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*MapKeyExpr) Free

func (e *MapKeyExpr) Free()

Free puts the MapKeyExpr back to the pool.

type MapSelectKeysExpr

type MapSelectKeysExpr struct {
	// Keys is the list of keys to select from the map.
	Keys []*MapKeyExpr
	// contains filtered or unexported fields
}

MapSelectKeysExpr is an expression that represents a map field - key.

func AcquireMapSelectKeysExpr

func AcquireMapSelectKeysExpr() *MapSelectKeysExpr

AcquireMapSelectKeysExpr acquires a MapSelectKeysExpr from the pool. Once acquired it must be released via Free method.

func (*MapSelectKeysExpr) Clone

func (e *MapSelectKeysExpr) Clone() Expr

Clone returns a copy of the MapSelectKeysExpr.

func (*MapSelectKeysExpr) Equals

func (e *MapSelectKeysExpr) Equals(other Expr) bool

Equals returns true if the other expression is equal to the current one.

func (*MapSelectKeysExpr) Free

func (e *MapSelectKeysExpr) Free()

Free puts the MapSelectKeysExpr back to the pool.

type MapValueExpr

type MapValueExpr struct {
	Values []MapValueExprEntry
	// contains filtered or unexported fields
}

MapValueExpr is an expression that can be represented as a map of values.

func AcquireMapValueExpr

func AcquireMapValueExpr() *MapValueExpr

AcquireMapValueExpr acquires a MapValueExpr from the pool. Once acquired it must be released via Free method.

func (*MapValueExpr) Clone

func (e *MapValueExpr) Clone() Expr

Clone returns a copy of the current expression.

func (*MapValueExpr) Complexity

func (e *MapValueExpr) Complexity() int64

Complexity of the MapValueExpr is the sum of complexities of the inner expressions + 1.

func (*MapValueExpr) Equals

func (e *MapValueExpr) Equals(other Expr) bool

Equals returns true if the MapValueExpr is equal to the given expression.

func (*MapValueExpr) Free

func (e *MapValueExpr) Free()

Free puts the MapValueExpr back to the pool.

type MapValueExprEntry

type MapValueExprEntry struct {
	Key   *ValueExpr
	Value FilterExpr
}

MapValueExprEntry is an entry of the MapValueExpr.

type MessageSelectExpr

type MessageSelectExpr struct {
	// Message is the full name of the message paths.
	Message protoreflect.FullName

	// Fields is a list of field selector expressions.
	Fields []*FieldSelectorExpr
	// contains filtered or unexported fields
}

MessageSelectExpr is a select expression. It provides a way to select specific fields from a message. It is used by the fieldmask parser.

func AcquireMessageSelectExpr

func AcquireMessageSelectExpr() *MessageSelectExpr

AcquireMessageSelectExpr acquires a select expression from the pool.

func (*MessageSelectExpr) Clone

func (e *MessageSelectExpr) Clone() Expr

Clone returns a deep copy of the select expression.

func (*MessageSelectExpr) Equals

func (e *MessageSelectExpr) Equals(other Expr) bool

Equals returns true if the select expressions are equal.

func (*MessageSelectExpr) Free

func (e *MessageSelectExpr) Free()

Free frees the select expression.

type NotExpr

type NotExpr struct {
	// Expr is an expression that should be negated.
	Expr FilterExpr
	// contains filtered or unexported fields
}

NotExpr is an expression that returns a negated result.

func AcquireNotExpr

func AcquireNotExpr() *NotExpr

AcquireNotExpr acquires a NotExpr from the pool. Once acquired it must be released via Free method.

func (*NotExpr) Clone

func (e *NotExpr) Clone() Expr

Clone returns a copy of the current expression.

func (*NotExpr) Complexity

func (e *NotExpr) Complexity() int64

Complexity of the NotExpr is 1 + complexity of the inner expression.

func (*NotExpr) Equals

func (e *NotExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*NotExpr) Free

func (e *NotExpr) Free()

Free puts the NotExpr back to the pool.

type OrExpr

type OrExpr struct {
	// Expr is a list of expressions to be evaluated.
	Expr []FilterExpr
	// contains filtered or unexported fields
}

OrExpr is an expression that envelops multiple expressions into a logical OR group.

func AcquireOrExpr

func AcquireOrExpr() *OrExpr

AcquireOrExpr acquires an OrExpr from the pool. Once acquired it must be released via Free method.

func (*OrExpr) Clone

func (e *OrExpr) Clone() Expr

Clone returns a copy of the current expression.

func (*OrExpr) Complexity

func (e *OrExpr) Complexity() int64

Complexity of the OrExpr is the product of complexities of the inner expressions + 1.

func (*OrExpr) Equals

func (e *OrExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*OrExpr) Free

func (e *OrExpr) Free()

Free puts the OrExpr back to the pool.

type Order

type Order int

Order is an enum for the order of the order by expression

const (
	// ASC determines the order to be ascending.
	// This is the default order.
	ASC Order = iota
	// DESC determines the order to be descending.
	DESC
)

func (Order) String

func (o Order) String() string

type OrderByExpr

type OrderByExpr struct {
	// Fields is a list of fields to be used for ordering
	Fields []*OrderByFieldExpr
	// contains filtered or unexported fields
}

OrderByExpr is an expression that selects a field to be used for ordering

func AcquireOrderByExpr

func AcquireOrderByExpr() *OrderByExpr

AcquireOrderByExpr acquires an OrderByExpr from the pool.

func (*OrderByExpr) Clone

func (o *OrderByExpr) Clone() Expr

Clone returns a copy of the OrderByExpr.

func (*OrderByExpr) Complexity

func (o *OrderByExpr) Complexity() int64

Complexity returns the complexity of the expression

func (*OrderByExpr) Equals

func (o *OrderByExpr) Equals(order Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*OrderByExpr) Free

func (o *OrderByExpr) Free()

Free puts the OrderByExpr back to the pool.

func (*OrderByExpr) Merge

func (o *OrderByExpr) Merge(other *OrderByExpr)

Merge merges the other OrderByExpr into the current one. If the field is already present, it is skipped and not added. The other OrderByExpr is not modified and is safe to use or Free after the merge.

type OrderByFieldExpr

type OrderByFieldExpr struct {
	// Field is the field to be used for ordering
	// It can be a traversal selector.
	Field *FieldSelectorExpr

	// Order is the order of the order by expression
	Order Order
	// contains filtered or unexported fields
}

OrderByFieldExpr is an expression that selects a field to be used for ordering

func AcquireOrderByFieldExpr

func AcquireOrderByFieldExpr() *OrderByFieldExpr

AcquireOrderByFieldExpr acquires an OrderByFieldExpr from the pool.

func (*OrderByFieldExpr) Clone

func (o *OrderByFieldExpr) Clone() Expr

Clone returns a copy of the OrderByFieldExpr.

func (*OrderByFieldExpr) Complexity

func (o *OrderByFieldExpr) Complexity() int64

Complexity returns the complexity of the expression

func (*OrderByFieldExpr) Equals

func (o *OrderByFieldExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*OrderByFieldExpr) Free

func (o *OrderByFieldExpr) Free()

Free puts the OrderByFieldExpr back to the pool.

type PaginationExpr

type PaginationExpr struct {
	// PageSize is the number of items to return per page.
	PageSize int32

	// Skip is the number of items to skip.
	Skip int32
	// contains filtered or unexported fields
}

PaginationExpr is an expression that defines pagination.

func AcquirePaginationExpr

func AcquirePaginationExpr() *PaginationExpr

AcquirePaginationExpr acquires a PaginationExpr from the pool. Once acquired it must be released via Free method.

func (*PaginationExpr) Clone

func (x *PaginationExpr) Clone() Expr

Clone returns a copy of the current expression.

func (*PaginationExpr) Equals

func (x *PaginationExpr) Equals(other Expr) bool

Equals returns true if the other expression is equal to the current one.

func (*PaginationExpr) Free

func (x *PaginationExpr) Free()

Free puts the PaginationExpr back to the pool.

type StringSearchExpr

type StringSearchExpr struct {
	// Value is the string value to search for (without wildcard characters (if present)).
	Value string

	// PrefixWildcard is true if the value has a prefix wildcard.
	PrefixWildcard bool

	// SuffixWildcard is true if the value has a suffix wildcard.
	SuffixWildcard bool

	// SearchComplexity is the complexity assigned by the parser.
	SearchComplexity int64
	// contains filtered or unexported fields
}

StringSearchExpr is a restriction that searches for a string in a string field. The string can have a prefix or suffix wildcard.

func AcquireStringSearchExpr

func AcquireStringSearchExpr() *StringSearchExpr

AcquireStringSearchExpr acquires a StringSearchExpr from the pool. Once acquired it must be released via Free method.

func (*StringSearchExpr) Clone

func (x *StringSearchExpr) Clone() Expr

Clone returns a copy of the StringSearchExpr.

func (*StringSearchExpr) Complexity

func (x *StringSearchExpr) Complexity() int64

Complexity returns the complexity of the expression. The complexity is taken from the field options. If the value has a prefix or suffix wildcard, the complexity is multiplied by 2, by each of them. This means that the complexity is multiplied by 4 if both are present. Resultant complexity is increased by 1 for the node.

func (*StringSearchExpr) Equals

func (x *StringSearchExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*StringSearchExpr) Free

func (x *StringSearchExpr) Free()

Free puts the StringSearchExpr back to the pool.

type UpdateExpr

type UpdateExpr struct {
	// Elements is a list of fields to update along with their values.
	Elements []UpdateFieldValue
	// contains filtered or unexported fields
}

UpdateExpr is an expression that contains fields to update along with their values. The UpdateExpr can be a value of UpdateFieldValue. In that case, the elements of the Value UpdateExpr, are relative to the field of the parent UpdateExpr.

func AcquireUpdateExpr

func AcquireUpdateExpr() *UpdateExpr

AcquireUpdateExpr acquires an UpdateExpr from the pool. Once acquired it must be released via Free method.

func (*UpdateExpr) Clone

func (e *UpdateExpr) Clone() Expr

Clone returns a copy of the UpdateExpr.

func (*UpdateExpr) Equals

func (e *UpdateExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*UpdateExpr) Free

func (e *UpdateExpr) Free()

Free puts the UpdateExpr back to the pool.

type UpdateFieldValue

type UpdateFieldValue struct {
	// Field is a field name to update.
	Field *FieldSelectorExpr

	// Value is a value to set.
	Value UpdateValueExpr
}

UpdateFieldValue is a field to update along with its value.

type UpdateValueExpr

type UpdateValueExpr interface {
	Expr
	// contains filtered or unexported methods
}

UpdateValueExpr is an expression that can be used as a value in UpdateExpr.

type ValueExpr

type ValueExpr struct {
	// Value is the value of the expression.
	Value any
	// contains filtered or unexported fields
}

ValueExpr is a simple value expression that contains a value. The value may be of any type that matches related to this expression. Standard field types used in the expressions are: - string - int64 - uint64 - bool - float64 - []byte - time.Time - time.Duration - protoreflect.EnumNumber -- enum value - protoreflect.Message - message value (dynamicpb.Message for dynamic structs) - structpb.Value - nil - used for nullable fields This can be extended by custom types.

func AcquireValueExpr

func AcquireValueExpr() *ValueExpr

AcquireValueExpr acquires a ValueExpr from the pool. Once acquired it must be released via Free method.

func (*ValueExpr) Clone

func (x *ValueExpr) Clone() Expr

Clone returns a copy of the ValueExpr.

func (*ValueExpr) Complexity

func (x *ValueExpr) Complexity() int64

Complexity of the ValueExpr is 1.

func (*ValueExpr) Equals

func (x *ValueExpr) Equals(other Expr) bool

Equals returns true if the given expression is equal to the current one.

func (*ValueExpr) Free

func (x *ValueExpr) Free()

Free puts the ValueExpr back to the pool.

type WildcardExpr

type WildcardExpr struct {
	// contains filtered or unexported fields
}

WildcardExpr is a wildcard expression. It is used by the fieldmask parser.

func AcquireWildcardExpr

func AcquireWildcardExpr() *WildcardExpr

AcquireWildcardExpr acquires a wildcard expression from the pool.

func (*WildcardExpr) Clone

func (e *WildcardExpr) Clone() Expr

Clone returns a deep copy of the wildcard expression.

func (*WildcardExpr) Equals

func (e *WildcardExpr) Equals(other Expr) bool

Equals returns true if the wildcard expression is equal to the other expression.

func (*WildcardExpr) Free

func (e *WildcardExpr) Free()

Free frees the wildcard expression.

Jump to

Keyboard shortcuts

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