Documentation ¶
Overview ¶
Package query is inspired and partially copied from by github.com/cch123/elasticsql.
Index ¶
- Variables
- func NewConverterError(format string, a ...interface{}) error
- func ParseExecutionDurationStr(durationStr string) (time.Duration, error)
- func ParseSqlValue(sqlValue string) (interface{}, error)
- type Converter
- type ConverterError
- type ExprConverter
- func NewAndConverter(whereConverter ExprConverter) ExprConverter
- func NewComparisonExprConverter(fnInterceptor FieldNameInterceptor, fvInterceptor FieldValuesInterceptor, ...) ExprConverter
- func NewIsConverter(fnInterceptor FieldNameInterceptor) ExprConverter
- func NewNotSupportedExprConverter() ExprConverter
- func NewOrConverter(whereConverter ExprConverter) ExprConverter
- func NewRangeCondConverter(fnInterceptor FieldNameInterceptor, fvInterceptor FieldValuesInterceptor, ...) ExprConverter
- func NewWhereConverter(and ExprConverter, or ExprConverter, rangeCond ExprConverter, ...) ExprConverter
- type FieldNameInterceptor
- type FieldNameUsage
- type FieldValuesInterceptor
- type NopFieldNameInterceptor
- type NopFieldValuesInterceptor
- type QueryParams
- type WhereConverter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MalformedSqlQueryErrMessage = "malformed SQL query" NotSupportedErrMessage = "operation is not supported" InvalidExpressionErrMessage = "invalid expression" )
Functions ¶
func NewConverterError ¶
func ParseExecutionDurationStr ¶ added in v1.23.0
func ParseSqlValue ¶ added in v1.20.0
ParseSqlValue returns a string, int64 or float64 if the parsing succeeds.
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
func NewConverter ¶
func NewConverter(fnInterceptor FieldNameInterceptor, whereConverter ExprConverter) *Converter
func (*Converter) ConvertSql ¶
func (c *Converter) ConvertSql(sql string) (*QueryParams, error)
ConvertSql transforms SQL to Elasticsearch query.
func (*Converter) ConvertWhereOrderBy ¶
func (c *Converter) ConvertWhereOrderBy(whereOrderBy string) (*QueryParams, error)
ConvertWhereOrderBy transforms WHERE SQL statement to Elasticsearch query. It also supports ORDER BY clause.
type ConverterError ¶
type ConverterError struct {
// contains filtered or unexported fields
}
func (*ConverterError) Error ¶
func (c *ConverterError) Error() string
func (*ConverterError) ToInvalidArgument ¶ added in v1.15.0
func (c *ConverterError) ToInvalidArgument() error
type ExprConverter ¶
func NewAndConverter ¶
func NewAndConverter(whereConverter ExprConverter) ExprConverter
func NewComparisonExprConverter ¶
func NewComparisonExprConverter( fnInterceptor FieldNameInterceptor, fvInterceptor FieldValuesInterceptor, allowedOperators map[string]struct{}, saNameType searchattribute.NameTypeMap, ) ExprConverter
func NewIsConverter ¶
func NewIsConverter(fnInterceptor FieldNameInterceptor) ExprConverter
func NewNotSupportedExprConverter ¶
func NewNotSupportedExprConverter() ExprConverter
func NewOrConverter ¶
func NewOrConverter(whereConverter ExprConverter) ExprConverter
func NewRangeCondConverter ¶
func NewRangeCondConverter( fnInterceptor FieldNameInterceptor, fvInterceptor FieldValuesInterceptor, notBetweenSupported bool, ) ExprConverter
func NewWhereConverter ¶
func NewWhereConverter( and ExprConverter, or ExprConverter, rangeCond ExprConverter, comparisonExpr ExprConverter, is ExprConverter) ExprConverter
type FieldNameInterceptor ¶
type FieldNameInterceptor interface {
Name(name string, usage FieldNameUsage) (string, error)
}
type FieldNameUsage ¶
type FieldNameUsage int
const ( FieldNameFilter FieldNameUsage = iota FieldNameSorter FieldNameGroupBy )
type FieldValuesInterceptor ¶
type NopFieldNameInterceptor ¶
type NopFieldNameInterceptor struct{}
func (*NopFieldNameInterceptor) Name ¶
func (n *NopFieldNameInterceptor) Name(name string, _ FieldNameUsage) (string, error)
type NopFieldValuesInterceptor ¶
type NopFieldValuesInterceptor struct{}
func (*NopFieldValuesInterceptor) Values ¶
func (n *NopFieldValuesInterceptor) Values(_ string, values ...interface{}) ([]interface{}, error)
type QueryParams ¶ added in v1.21.0
type QueryParams struct { Query elastic.Query Sorter []elastic.Sorter GroupBy []string }
type WhereConverter ¶
type WhereConverter struct { And ExprConverter Or ExprConverter RangeCond ExprConverter ComparisonExpr ExprConverter Is ExprConverter }
Click to show internal directories.
Click to hide internal directories.