Documentation
¶
Index ¶
- type Column
- type Constructor
- func (c *Constructor) And(nest func())
- func (c *Constructor) Col(column string, op string, value interface{})
- func (c *Constructor) ColAnyInt16s(column string, values []int16)
- func (c *Constructor) ColAnyInt64s(column string, values []int64)
- func (c *Constructor) ColAnyInts(column string, values []int)
- func (c *Constructor) ColAnyStrings(column string, values []string)
- func (c *Constructor) ColInInt16s(column string, values []int16)
- func (c *Constructor) ColInInt64s(column string, values []int64)
- func (c *Constructor) ColInInts(column string, values []int)
- func (c *Constructor) ColInStrings(column string, values []string)
- func (c *Constructor) CountFilter() gosql.Filter
- func (c *Constructor) Filter() gosql.Filter
- func (c *Constructor) Init(colmap map[string]string, tscol string)
- func (c *Constructor) InitV2(colmap map[string]Column, tscol string)
- func (c *Constructor) Limit(count int64)
- func (c *Constructor) Offset(start int64)
- func (c *Constructor) Or(nest func())
- func (c *Constructor) OrderBy(column string, desc, nullsfirst bool)
- func (c *Constructor) OrderByV2(column string, desc, nullable, nullsfirst bool)
- func (c *Constructor) Page(page int64)
- func (c *Constructor) StrictSwitch()
- func (c *Constructor) TextSearch(value string)
- func (c *Constructor) UnmarshalFQL(str string) error
- func (c *Constructor) UnmarshalSort(str string) error
- type UnknownColumnKeyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶ added in v0.2.0
type Column struct {
// Name is the name of the column.
Name string
// ConvertValue, when set, will be used convert
// the column's FQL-parsed value.
ConvertValue func(any) (any, error)
// IsNULLable indicates whether or not the column's NULLable.
IsNULLable bool
}
The Column type XXX
type Constructor ¶ added in v0.0.3
type Constructor struct {
// contains filtered or unexported fields
}
The Constructor type can be used to dynamically construct a "filter" for an SQL query.
The Constructor type implements the gosql.Filter and the gosql.FilterConstructor interface.
func (*Constructor) And ¶ added in v0.0.3
func (c *Constructor) And(nest func())
And adds the AND logical operator argument for the WHERE clause. If the given nest function is not nil it will be executed and its result will be wrapped in parentheses.
The And method implements part of the gosql.FilterConstructor interface.
func (*Constructor) Col ¶ added in v0.0.3
func (c *Constructor) Col(column string, op string, value interface{})
Col prepares a new, column-specific predicate for the WHERE clause. The column is assumed to already be vetted.
The Col method implements part of the gosql.FilterConstructor interface.
func (*Constructor) ColAnyInt16s ¶ added in v0.6.0
func (c *Constructor) ColAnyInt16s(column string, values []int16)
func (*Constructor) ColAnyInt64s ¶ added in v0.6.0
func (c *Constructor) ColAnyInt64s(column string, values []int64)
func (*Constructor) ColAnyInts ¶ added in v0.6.0
func (c *Constructor) ColAnyInts(column string, values []int)
func (*Constructor) ColAnyStrings ¶ added in v0.6.0
func (c *Constructor) ColAnyStrings(column string, values []string)
func (*Constructor) ColInInt16s ¶ added in v0.6.0
func (c *Constructor) ColInInt16s(column string, values []int16)
func (*Constructor) ColInInt64s ¶ added in v0.6.0
func (c *Constructor) ColInInt64s(column string, values []int64)
func (*Constructor) ColInInts ¶ added in v0.6.0
func (c *Constructor) ColInInts(column string, values []int)
func (*Constructor) ColInStrings ¶ added in v0.6.0
func (c *Constructor) ColInStrings(column string, values []string)
func (*Constructor) CountFilter ¶ added in v0.0.3
func (c *Constructor) CountFilter() gosql.Filter
CountFilter returns an alternative implementation of the constructed gosql.Filter, one that that omits clauses that are unnecessary in the context of a SELECT COUNT query, like, for example, the LIMIT clause.
func (*Constructor) Filter ¶ added in v0.0.3
func (c *Constructor) Filter() gosql.Filter
Filter returns the constructed gosql.Filter instance.
func (*Constructor) Init ¶ added in v0.0.3
func (c *Constructor) Init(colmap map[string]string, tscol string)
Init initializes the Constructor's colmap and tscol fields using the given values.
The Init method implements part of the gosql.FilterConstructor interface.
func (*Constructor) InitV2 ¶ added in v0.2.0
func (c *Constructor) InitV2(colmap map[string]Column, tscol string)
InitV2 initializes the Constructor's colmap and tscol fields using the given values.
The Init method implements part of the gosql.FilterConstructor interface.
func (*Constructor) Limit ¶ added in v0.0.3
func (c *Constructor) Limit(count int64)
Limit sets the given value as the argument for the LIMIT clause.
func (*Constructor) Offset ¶ added in v0.0.3
func (c *Constructor) Offset(start int64)
Offset sets the given value as the argument for the OFFSET clause.
func (*Constructor) Or ¶ added in v0.0.3
func (c *Constructor) Or(nest func())
Or adds the OR logical operator argument for the WHERE clause. If the given nest function is not nil it will be executed and its result will be wrapped in parentheses.
The Or method implements part of the gosql.FilterConstructor interface.
func (*Constructor) OrderBy ¶ added in v0.0.3
func (c *Constructor) OrderBy(column string, desc, nullsfirst bool)
OrderBy adds a new argument to the ORDER BY clause.
The column is assumed to already be vetted.
func (*Constructor) OrderByV2 ¶ added in v0.3.0
func (c *Constructor) OrderByV2(column string, desc, nullable, nullsfirst bool)
OrderByV2 adds a new argument to the ORDER BY clause.
The column is assumed to already be vetted.
func (*Constructor) Page ¶ added in v0.0.3
func (c *Constructor) Page(page int64)
Page, using the given value, calculates the argument for the OFFSET clause.
func (*Constructor) StrictSwitch ¶ added in v0.0.3
func (c *Constructor) StrictSwitch()
StrictSwitch switches the strict mode on and off.
func (*Constructor) TextSearch ¶ added in v0.0.3
func (c *Constructor) TextSearch(value string)
TextSearch prepares a new, text-search predicate for the WHERE clause.
func (*Constructor) UnmarshalFQL ¶ added in v0.0.3
func (c *Constructor) UnmarshalFQL(str string) error
UnmarshalFQL unmarshals the given string using the github.com/frk/fql package. If the given string is not valid FQL an error will be returned. If the Constructor is in strict mode and the column keys in the FQL do not have an entry in the Constructor's colmap, the UnknownColumnKeyError will be returned.
func (*Constructor) UnmarshalSort ¶ added in v0.0.3
func (c *Constructor) UnmarshalSort(str string) error
UnmarshalSort parses the given string as a comma separated list of column keys that can optionally be preceded by a hyphen to indicate the descending sort order. The keys are then used to build the ORDER BY clause of the filter. Empty items between commas in the str are ignored. If the Constructor is in strict mode and the column keys in the input do not have an entry in the Constructor's colmap, the UnknownColumnKeyError will be returned.
Example value:
"-created_at,label"
type UnknownColumnKeyError ¶
type UnknownColumnKeyError struct {
Key string
}
The UnknownColumnKeyError indicates that a provided key has no matching entry in the colmap of the Filter from which the error was retruned.
func (UnknownColumnKeyError) Error ¶
func (e UnknownColumnKeyError) Error() string
Error implements the error interface.