Documentation
¶
Index ¶
- Constants
- func NewAliasedTable(name TableName, alias TableAlias) aliasedTable
- func NewBuilder() *builder
- func NewBuilderWithOffset(pc *int) *builder
- func NewTable(name TableName) aliasedTable
- type Builder
- type CondInterpreter
- type Condition
- type ConditionSerializable
- type Field
- type FieldName
- type JoinType
- type JoinedTable
- type ModifiableQuery
- type OrderBy
- type PagInterpreter
- type Param
- type Serializable
- type Table
- type TableAlias
- type TableName
- type Tuple
Constants ¶
View Source
const (
// ZeroLimit is used to signal to AddLimit to include a `LIMIT 0` clause
ZeroLimit = -1
)
Variables ¶
This section is empty.
Functions ¶
func NewAliasedTable ¶
func NewAliasedTable(name TableName, alias TableAlias) aliasedTable
func NewBuilder ¶
func NewBuilder() *builder
func NewBuilderWithOffset ¶
func NewBuilderWithOffset(pc *int) *builder
Types ¶
type Builder ¶
type Builder interface {
WriteParam(Param) Builder
WriteTuples([]Tuple) Builder
WriteString(string) Builder
WriteRune(rune) Builder
WriteSerializables(...Serializable) Builder
WriteConditionSerializable(ConditionSerializable, CondInterpreter) Builder
Build() (string, []Param)
}
Builder is the string builder
type CondInterpreter ¶
type CondInterpreter interface {
// TimeOffset appends NOW() - '10 seconds'
TimeOffset(duration time.Duration, sb Builder)
// InTuple creates the condition (field1, field2, ...) IN ((val1, val2, ...), (val3, val4, ...))
InTuple(fields []Serializable, vals []Tuple, sb Builder)
}
CondInterpreter is the condition interpreter for the WHERE clauses It specifies the behaviors that differ among different DBs
type Condition ¶ added in v0.5.2
type Condition ConditionSerializable
type ConditionSerializable ¶
type ConditionSerializable interface {
WriteString(CondInterpreter, Builder)
}
ConditionSerializable is any type that can be transformed to a query part but needs condition interpreter support, e.g. condition, join
type Field ¶
type Field Serializable
type FieldName ¶
type FieldName string
FieldName is the name of the DB column
func (FieldName) WriteString ¶
type JoinedTable ¶
type JoinedTable interface {
ConditionSerializable
JoinAs(typ JoinType, other Table, ons ConditionSerializable) JoinedTable
Join(Table, ConditionSerializable) JoinedTable
}
type ModifiableQuery ¶ added in v0.5.2
type ModifiableQuery interface {
AddField(Field)
AddWhere(Condition)
AddOrderBy(OrderBy)
// AddLimit is used to manage the LIMIT clause.
// Any passed value larger than zero will trigger the inclusion of the clause.
// If one wants to explicitly insert a clause as `LIMIT 0`, then oen should use the constant ZeroLimit
AddLimit(int)
AddOffset(int)
}
type OrderBy ¶ added in v0.5.2
type OrderBy Serializable
type PagInterpreter ¶
type PagInterpreter interface {
// PreProcess modifies the SQL query to add pagination support
PreProcess(driver.Pagination, ModifiableQuery)
}
PagInterpreter is the pagination interpreter
type Serializable ¶
type Serializable interface {
WriteString(Builder)
}
Serializable is any type can be transformed to a query part, e.g. field, order-by
func ToSerializables ¶
func ToSerializables[S Serializable](vs []S) []Serializable
type Table ¶
type Table interface {
JoinedTable
Field(name FieldName) Field
}
type TableAlias ¶
type TableAlias string
Click to show internal directories.
Click to hide internal directories.