ordering

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: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternalError is an internal sorting error.
	ErrInternalError = errors.New("internal error")

	// ErrInvalidField is an error returned by the parser when the sorting expression
	// contains invalid field name.
	ErrInvalidField = errors.New("invalid field")

	// ErrInvalidSyntax is an error returned by the parser when the sorting expression
	// has invalid syntax.
	ErrInvalidSyntax = errors.New("invalid syntax")

	// ErrSortingForbidden is an error returned by the parser when the sorting
	// is forbidden of specific field.
	ErrSortingForbidden = errors.New("sorting forbidden")
)

Functions

This section is empty.

Types

type ErrHandlerFn

type ErrHandlerFn func(pos token.Position, msg string)

ErrHandlerFn is a function that handles errors

type Parser

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

Parser parses an order by expression

func NewParser

func NewParser(msg protoreflect.MessageDescriptor, opts ...ParserOpt) (*Parser, error)

NewParser creates a new parser with a message descriptor and optional error handler.

func (*Parser) Parse

func (p *Parser) Parse(orderBy string) (oe *expr.OrderByExpr, err error)

Parse parses a sorting order option and returns an expression.

func (*Parser) Reset

func (p *Parser) Reset(msgDesc protoreflect.MessageDescriptor, opts ...ParserOpt) error

Reset resets the parser with a new message descriptor and optional error handler. If the error handler is nil, the parser will handling errors.

type ParserOpt

type ParserOpt func(p *Parser) error

ParserOpt is an option function for the parser.

func ErrHandler

func ErrHandler(fn scanner.ErrorHandler) ParserOpt

ErrHandler sets the error handler for the parser.

Jump to

Keyboard shortcuts

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