common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

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

func NewTable

func NewTable(name TableName) aliasedTable

TODO: Support new alias per table in case a table is selected twice in the same query (for different joins)

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 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

func (n FieldName) WriteString(b Builder)

type JoinedTable

type JoinedTable interface {
	ConditionSerializable
	Join(Table, ConditionSerializable) JoinedTable
}

type PagInterpreter

type PagInterpreter interface {
	// Interpret modifies the SQL query to add pagination support
	Interpret(p driver.Pagination, sb Builder)
}

PagInterpreter is the pagination interpreter

type Param

type Param = any

Param is a value for a field

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

type TableName

type TableName string

type Tuple

type Tuple = []Param

Tuple is a tuple of parameters

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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