Documentation
¶
Overview ¶
Package sqlbuilder provides an interface for building SQL queries programatically.
Index ¶
- type AsCommonTableExpression
- type AsDistinct
- type AsExpr
- type AsNamed
- type AsNamedShort
- type AsOffsetLimit
- type AsOrderingTerm
- type AsResultColumn
- type AsTableOrSubquery
- type AsTableOrSubqueryAndWithColumns
- type AsUnion
- type BasicColumn
- type BinaryOperatorExpr
- func And(left, right AsExpr) *BinaryOperatorExpr
- func BinaryOperator(operator string, left, right AsExpr) *BinaryOperatorExpr
- func Eq(left, right AsExpr) *BinaryOperatorExpr
- func Gt(left, right AsExpr) *BinaryOperatorExpr
- func Gte(left, right AsExpr) *BinaryOperatorExpr
- func Lt(left, right AsExpr) *BinaryOperatorExpr
- func Lte(left, right AsExpr) *BinaryOperatorExpr
- func Ne(left, right AsExpr) *BinaryOperatorExpr
- func Or(left, right AsExpr) *BinaryOperatorExpr
- type BooleanOperatorExpr
- type BoundVariable
- type CaseExpr
- type CaseWhenClause
- type CastExpr
- type ColumnAlias
- type CommonTableExpressionExpr
- func (e *CommonTableExpressionExpr) As(as *SelectStatement) *CommonTableExpressionExpr
- func (e *CommonTableExpressionExpr) AsCommonTableExpression(s *Serializer)
- func (e *CommonTableExpressionExpr) AsNamed(s *Serializer)
- func (e *CommonTableExpressionExpr) AsTableOrSubquery(s *Serializer)
- func (e *CommonTableExpressionExpr) C(name string) *BasicColumn
- func (e *CommonTableExpressionExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (e *CommonTableExpressionExpr) IsRecursive() bool
- func (e *CommonTableExpressionExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (e *CommonTableExpressionExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
- func (e *CommonTableExpressionExpr) Recursive(recursive bool) *CommonTableExpressionExpr
- type DeleteStatement
- type Dialect
- type DialectGeneric
- type DialectMSSQL
- type DialectPostgres
- type DialectSQLite
- type DistinctExpr
- type ExpressionTableExpr
- func (t *ExpressionTableExpr) AsNamed(s *Serializer)
- func (t *ExpressionTableExpr) AsTableOrSubquery(s *Serializer)
- func (t *ExpressionTableExpr) C(name string) *BasicColumn
- func (t *ExpressionTableExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (t *ExpressionTableExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (t *ExpressionTableExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
- type FilterExpr
- type FuncExpr
- type FuncTableExpr
- func (t *FuncTableExpr) AsNamed(s *Serializer)
- func (t *FuncTableExpr) AsTableOrSubquery(s *Serializer)
- func (t *FuncTableExpr) C(name string) *BasicColumn
- func (t *FuncTableExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (t *FuncTableExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (t *FuncTableExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
- type FuncTableWithoutNameExpr
- func (t *FuncTableWithoutNameExpr) AsTableOrSubquery(s *Serializer)
- func (t *FuncTableWithoutNameExpr) C(name string) *BasicColumn
- func (t *FuncTableWithoutNameExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (t *FuncTableWithoutNameExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (t *FuncTableWithoutNameExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
- type InOperatorExpr
- type InfixOperatorExpr
- type InsertColumns
- type InsertStatement
- type JoinExpr
- func (j *JoinExpr) AsTableOrSubquery(s *Serializer)
- func (j *JoinExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (j *JoinExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (j *JoinExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
- func (j *JoinExpr) On(condition AsExpr) *JoinExpr
- type LikeOperatorExpr
- type LiteralExpr
- type MSSQLDistinctExpr
- type MSSQLOffsetLimitClause
- type OffsetLimitClause
- type OrderingTerm
- func OrderAsc(expr AsExpr) *OrderingTerm
- func OrderAscNullsFirst(expr AsExpr) *OrderingTerm
- func OrderAscNullsLast(expr AsExpr) *OrderingTerm
- func OrderDefault(expr AsExpr) *OrderingTerm
- func OrderDefaultNullsFirst(expr AsExpr) *OrderingTerm
- func OrderDefaultNullsLast(expr AsExpr) *OrderingTerm
- func OrderDesc(expr AsExpr) *OrderingTerm
- func OrderDescNullsFirst(expr AsExpr) *OrderingTerm
- func OrderDescNullsLast(expr AsExpr) *OrderingTerm
- type PostfixOperatorExpr
- type PrefixOperatorExpr
- type SelectStatement
- func (s *SelectStatement) AndOrderBy(orderBy ...AsOrderingTerm) *SelectStatement
- func (s *SelectStatement) AndUnion(union ...AsUnion) *SelectStatement
- func (s *SelectStatement) AndWhere(where AsExpr) *SelectStatement
- func (s *SelectStatement) AndWith(with ...AsCommonTableExpression) *SelectStatement
- func (q *SelectStatement) As(alias string) AsExpr
- func (q *SelectStatement) AsExpr(s *Serializer)
- func (q *SelectStatement) AsStatement(s *Serializer)
- func (q *SelectStatement) AsTableOrSubquery(s *Serializer)
- func (q *SelectStatement) C(name string) *BasicColumn
- func (s *SelectStatement) Columns(columns ...AsExpr) *SelectStatement
- func (q *SelectStatement) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (s *SelectStatement) Distinct(distinct AsDistinct) *SelectStatement
- func (s *SelectStatement) From(from AsTableOrSubquery) *SelectStatement
- func (s *SelectStatement) GetFrom() AsTableOrSubquery
- func (s *SelectStatement) GetWhere() AsExpr
- func (s *SelectStatement) GroupBy(groupBy ...AsExpr) *SelectStatement
- func (s *SelectStatement) Having(having AsExpr) *SelectStatement
- func (q *SelectStatement) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (q *SelectStatement) LeftJoin(right AsTableOrSubquery) *JoinExpr
- func (s *SelectStatement) OffsetLimit(offsetLimit AsOffsetLimit) *SelectStatement
- func (s *SelectStatement) OrderBy(orderBy ...AsOrderingTerm) *SelectStatement
- func (s *SelectStatement) Union(union ...AsUnion) *SelectStatement
- func (s *SelectStatement) Where(where AsExpr) *SelectStatement
- func (s *SelectStatement) With(with ...AsCommonTableExpression) *SelectStatement
- type Serializer
- func (s *Serializer) Bind(val interface{}) *BoundVariable
- func (s *Serializer) BindAllAsExpr(vals ...interface{}) []AsExpr
- func (s *Serializer) BindAllIntsAsExpr(vals ...int) []AsExpr
- func (s *Serializer) BindAllStringsAsExpr(vals ...string) []AsExpr
- func (s *Serializer) D(data string) *Serializer
- func (s *Serializer) DC(data string, w bool) *Serializer
- func (s *Serializer) F(f func(s *Serializer)) *Serializer
- func (s *Serializer) FC(f func(s *Serializer), w bool) *Serializer
- func (s *Serializer) N(name string) *Serializer
- func (s *Serializer) NC(name string, w bool) *Serializer
- func (s *Serializer) SetDialect(d Dialect)
- func (s *Serializer) ToSQL() (string, []interface{}, error)
- func (s *Serializer) V(val interface{}) *Serializer
- func (s *Serializer) VC(val interface{}, w bool) *Serializer
- type Table
- func (t *Table) AsNamed(s *Serializer)
- func (t *Table) AsTableOrSubquery(s *Serializer)
- func (t *Table) C(name string) *BasicColumn
- func (t *Table) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (t *Table) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (t *Table) LeftJoin(right AsTableOrSubquery) *JoinExpr
- type TableAlias
- func (a *TableAlias) AsNamed(s *Serializer)
- func (a *TableAlias) AsTableOrSubquery(s *Serializer)
- func (a *TableAlias) C(name string) *BasicColumn
- func (a *TableAlias) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (a *TableAlias) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (a *TableAlias) LeftJoin(right AsTableOrSubquery) *JoinExpr
- type TypedLiteralExpr
- type UnionExpr
- type UpdateColumns
- type UpdateField
- type UpdateStatement
- func (s *UpdateStatement) AndField(field UpdateField) *UpdateStatement
- func (s *UpdateStatement) AndSet(column *BasicColumn, expr AsExpr) *UpdateStatement
- func (s *UpdateStatement) AndWith(with ...AsCommonTableExpression) *UpdateStatement
- func (q *UpdateStatement) AsStatement(s *Serializer)
- func (s *UpdateStatement) Fields(fields []UpdateField) *UpdateStatement
- func (s *UpdateStatement) From(from AsTableOrSubquery) *UpdateStatement
- func (s *UpdateStatement) GetTarget() AsTableOrSubquery
- func (s *UpdateStatement) Returning(returning ...AsExpr) *UpdateStatement
- func (s *UpdateStatement) Set(columns UpdateColumns) *UpdateStatement
- func (s *UpdateStatement) Table(table *Table) *UpdateStatement
- func (s *UpdateStatement) Target(target AsTableOrSubquery) *UpdateStatement
- func (s *UpdateStatement) Where(where AsExpr) *UpdateStatement
- func (s *UpdateStatement) With(with ...AsCommonTableExpression) *UpdateStatement
- type ValuesExpr
- type ValuesRowExpr
- type ValuesTableExpr
- func (t *ValuesTableExpr) AsNamed(s *Serializer)
- func (t *ValuesTableExpr) AsTableOrSubquery(s *Serializer)
- func (t *ValuesTableExpr) C(name string) *BasicColumn
- func (t *ValuesTableExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
- func (t *ValuesTableExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
- func (t *ValuesTableExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
- type WithColumns
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsCommonTableExpression ¶
type AsCommonTableExpression interface { AsCommonTableExpression(s *Serializer) IsRecursive() bool }
type AsDistinct ¶
type AsDistinct interface {
AsDistinct(s *Serializer)
}
type AsExpr ¶
type AsExpr interface {
AsExpr(s *Serializer)
}
func BindAllAsExpr ¶
func BindAllAsExpr(vals ...interface{}) []AsExpr
BindAllAsExpr binds multiple variables at once, returning them as []AsExpr. This is most useful for In and NotIn conditions.
func BindAllIntsAsExpr ¶
BindAllIntsAsExpr binds multiple variables at once, returning them as []AsExpr. This is most useful for In and NotIn conditions.
func BindAllStringsAsExpr ¶
BindAllStringsAsExpr binds multiple variables at once, returning them as []AsExpr. This is most useful for In and NotIn conditions.
type AsNamed ¶
type AsNamed interface {
AsNamed(s *Serializer)
}
type AsNamedShort ¶
type AsNamedShort interface {
AsNamedShort(s *Serializer)
}
type AsOffsetLimit ¶
type AsOffsetLimit interface {
AsOffsetLimit(s *Serializer)
}
type AsOrderingTerm ¶
type AsOrderingTerm interface {
AsOrderingTerm(s *Serializer)
}
type AsResultColumn ¶
type AsResultColumn interface {
AsResultColumn(s *Serializer)
}
type AsTableOrSubquery ¶
type AsTableOrSubquery interface {
AsTableOrSubquery(s *Serializer)
}
type AsTableOrSubqueryAndWithColumns ¶
type AsTableOrSubqueryAndWithColumns interface { AsTableOrSubquery WithColumns }
type AsUnion ¶
type AsUnion interface {
AsUnion(s *Serializer)
}
type BasicColumn ¶
type BasicColumn struct {
// contains filtered or unexported fields
}
func BareColumn ¶
func BareColumn(name string) *BasicColumn
func (*BasicColumn) As ¶
func (c *BasicColumn) As(alias string) *ColumnAlias
func (*BasicColumn) AsExpr ¶
func (c *BasicColumn) AsExpr(s *Serializer)
func (*BasicColumn) AsNamedShort ¶
func (c *BasicColumn) AsNamedShort(s *Serializer)
type BinaryOperatorExpr ¶
type BinaryOperatorExpr struct {
// contains filtered or unexported fields
}
func And ¶
func And(left, right AsExpr) *BinaryOperatorExpr
func BinaryOperator ¶
func BinaryOperator(operator string, left, right AsExpr) *BinaryOperatorExpr
func Eq ¶
func Eq(left, right AsExpr) *BinaryOperatorExpr
func Gt ¶
func Gt(left, right AsExpr) *BinaryOperatorExpr
func Gte ¶
func Gte(left, right AsExpr) *BinaryOperatorExpr
func Lt ¶
func Lt(left, right AsExpr) *BinaryOperatorExpr
func Lte ¶
func Lte(left, right AsExpr) *BinaryOperatorExpr
func Ne ¶
func Ne(left, right AsExpr) *BinaryOperatorExpr
func Or ¶
func Or(left, right AsExpr) *BinaryOperatorExpr
func (*BinaryOperatorExpr) AsExpr ¶
func (o *BinaryOperatorExpr) AsExpr(s *Serializer)
type BooleanOperatorExpr ¶
type BooleanOperatorExpr struct {
// contains filtered or unexported fields
}
func BooleanOperator ¶
func BooleanOperator(operator string, elements ...AsExpr) *BooleanOperatorExpr
func (*BooleanOperatorExpr) AsExpr ¶
func (b *BooleanOperatorExpr) AsExpr(s *Serializer)
type BoundVariable ¶
type BoundVariable struct {
// contains filtered or unexported fields
}
func Bind ¶
func Bind(value interface{}) *BoundVariable
func (*BoundVariable) As ¶
func (b *BoundVariable) As(alias string) *ColumnAlias
func (*BoundVariable) AsExpr ¶
func (b *BoundVariable) AsExpr(s *Serializer)
type CaseExpr ¶
type CaseExpr struct {
// contains filtered or unexported fields
}
func (*CaseExpr) AsExpr ¶
func (c *CaseExpr) AsExpr(s *Serializer)
func (*CaseExpr) When ¶
func (c *CaseExpr) When(whenClause ...*CaseWhenClause) *CaseExpr
type CaseWhenClause ¶
type CaseWhenClause struct {
// contains filtered or unexported fields
}
func CaseWhen ¶
func CaseWhen(whenExpr, resultExpr AsExpr) *CaseWhenClause
type CastExpr ¶
type CastExpr struct {
// contains filtered or unexported fields
}
func (*CastExpr) AsExpr ¶
func (c *CastExpr) AsExpr(s *Serializer)
type ColumnAlias ¶
type ColumnAlias struct {
// contains filtered or unexported fields
}
func AliasColumn ¶
func AliasColumn(expr AsExpr, alias string) *ColumnAlias
func (*ColumnAlias) As ¶
func (e *ColumnAlias) As(alias string) *ColumnAlias
func (*ColumnAlias) AsExpr ¶
func (e *ColumnAlias) AsExpr(s *Serializer)
func (*ColumnAlias) AsResultColumn ¶
func (e *ColumnAlias) AsResultColumn(s *Serializer)
type CommonTableExpressionExpr ¶
type CommonTableExpressionExpr struct {
// contains filtered or unexported fields
}
func CommonTableExpression ¶
func CommonTableExpression(name string) *CommonTableExpressionExpr
func (*CommonTableExpressionExpr) As ¶
func (e *CommonTableExpressionExpr) As(as *SelectStatement) *CommonTableExpressionExpr
func (*CommonTableExpressionExpr) AsCommonTableExpression ¶
func (e *CommonTableExpressionExpr) AsCommonTableExpression(s *Serializer)
func (*CommonTableExpressionExpr) AsNamed ¶
func (e *CommonTableExpressionExpr) AsNamed(s *Serializer)
func (*CommonTableExpressionExpr) AsTableOrSubquery ¶
func (e *CommonTableExpressionExpr) AsTableOrSubquery(s *Serializer)
func (*CommonTableExpressionExpr) C ¶
func (e *CommonTableExpressionExpr) C(name string) *BasicColumn
func (*CommonTableExpressionExpr) CrossJoin ¶
func (e *CommonTableExpressionExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*CommonTableExpressionExpr) IsRecursive ¶
func (e *CommonTableExpressionExpr) IsRecursive() bool
func (*CommonTableExpressionExpr) Join ¶
func (e *CommonTableExpressionExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
func (*CommonTableExpressionExpr) LeftJoin ¶
func (e *CommonTableExpressionExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
func (*CommonTableExpressionExpr) Recursive ¶
func (e *CommonTableExpressionExpr) Recursive(recursive bool) *CommonTableExpressionExpr
type DeleteStatement ¶
type DeleteStatement struct {
// contains filtered or unexported fields
}
func Delete ¶
func Delete() *DeleteStatement
func (*DeleteStatement) AsStatement ¶
func (q *DeleteStatement) AsStatement(s *Serializer)
func (*DeleteStatement) Table ¶
func (s *DeleteStatement) Table(table *Table) *DeleteStatement
func (*DeleteStatement) Where ¶
func (s *DeleteStatement) Where(where AsExpr) *DeleteStatement
type DialectGeneric ¶
type DialectGeneric struct{}
func (DialectGeneric) Bind ¶
func (DialectGeneric) Bind(i int) string
func (DialectGeneric) QuoteName ¶
func (DialectGeneric) QuoteName(name string) string
type DialectMSSQL ¶
type DialectMSSQL struct{ QuoteEverything bool }
func (DialectMSSQL) Bind ¶
func (DialectMSSQL) Bind(i int) string
func (DialectMSSQL) QuoteName ¶
func (d DialectMSSQL) QuoteName(name string) string
type DialectPostgres ¶
type DialectPostgres struct{}
func (DialectPostgres) Bind ¶
func (DialectPostgres) Bind(i int) string
func (DialectPostgres) QuoteName ¶
func (DialectPostgres) QuoteName(name string) string
type DialectSQLite ¶
type DialectSQLite struct{}
func (DialectSQLite) Bind ¶
func (DialectSQLite) Bind(i int) string
func (DialectSQLite) QuoteName ¶
func (DialectSQLite) QuoteName(name string) string
type DistinctExpr ¶
type DistinctExpr struct {
// contains filtered or unexported fields
}
func Distinct ¶
func Distinct(on ...AsExpr) *DistinctExpr
func (*DistinctExpr) AsDistinct ¶
func (e *DistinctExpr) AsDistinct(s *Serializer)
type ExpressionTableExpr ¶
type ExpressionTableExpr struct {
// contains filtered or unexported fields
}
func ExpressionTable ¶
func ExpressionTable(expr AsExpr, name string, names ...string) *ExpressionTableExpr
func (*ExpressionTableExpr) AsNamed ¶
func (t *ExpressionTableExpr) AsNamed(s *Serializer)
func (*ExpressionTableExpr) AsTableOrSubquery ¶
func (t *ExpressionTableExpr) AsTableOrSubquery(s *Serializer)
func (*ExpressionTableExpr) C ¶
func (t *ExpressionTableExpr) C(name string) *BasicColumn
func (*ExpressionTableExpr) CrossJoin ¶
func (t *ExpressionTableExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*ExpressionTableExpr) Join ¶
func (t *ExpressionTableExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
func (*ExpressionTableExpr) LeftJoin ¶
func (t *ExpressionTableExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
type FilterExpr ¶
type FilterExpr struct {
// contains filtered or unexported fields
}
func Filter ¶
func Filter(left, right AsExpr) *FilterExpr
func (*FilterExpr) AsExpr ¶
func (c *FilterExpr) AsExpr(s *Serializer)
type FuncExpr ¶
type FuncExpr struct {
// contains filtered or unexported fields
}
func (*FuncExpr) As ¶
func (e *FuncExpr) As(alias string) *ColumnAlias
func (*FuncExpr) AsExpr ¶
func (e *FuncExpr) AsExpr(s *Serializer)
type FuncTableExpr ¶
type FuncTableExpr struct {
// contains filtered or unexported fields
}
FuncTableExpr is deprecated in favour of FuncTableWithoutNameExpr
func FuncTable ¶
func FuncTable(expr *FuncExpr, name string) *FuncTableExpr
FuncTable is deprecated in favour of FuncTableWithoutName
func (*FuncTableExpr) AsNamed ¶
func (t *FuncTableExpr) AsNamed(s *Serializer)
func (*FuncTableExpr) AsTableOrSubquery ¶
func (t *FuncTableExpr) AsTableOrSubquery(s *Serializer)
func (*FuncTableExpr) C ¶
func (t *FuncTableExpr) C(name string) *BasicColumn
func (*FuncTableExpr) CrossJoin ¶
func (t *FuncTableExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*FuncTableExpr) Join ¶
func (t *FuncTableExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
func (*FuncTableExpr) LeftJoin ¶
func (t *FuncTableExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
type FuncTableWithoutNameExpr ¶ added in v1.3.0
type FuncTableWithoutNameExpr struct {
// contains filtered or unexported fields
}
func FuncTableWithoutName ¶ added in v1.3.0
func FuncTableWithoutName(expr *FuncExpr, names ...string) *FuncTableWithoutNameExpr
func (*FuncTableWithoutNameExpr) AsTableOrSubquery ¶ added in v1.3.0
func (t *FuncTableWithoutNameExpr) AsTableOrSubquery(s *Serializer)
func (*FuncTableWithoutNameExpr) C ¶ added in v1.3.0
func (t *FuncTableWithoutNameExpr) C(name string) *BasicColumn
func (*FuncTableWithoutNameExpr) CrossJoin ¶ added in v1.3.0
func (t *FuncTableWithoutNameExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*FuncTableWithoutNameExpr) Join ¶ added in v1.3.0
func (t *FuncTableWithoutNameExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
func (*FuncTableWithoutNameExpr) LeftJoin ¶ added in v1.3.0
func (t *FuncTableWithoutNameExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
type InOperatorExpr ¶
type InOperatorExpr struct {
// contains filtered or unexported fields
}
func In ¶
func In(expr AsExpr, v ...AsExpr) *InOperatorExpr
func InOperator ¶
func InOperator(operator string, expr AsExpr, v ...AsExpr) *InOperatorExpr
func NotIn ¶
func NotIn(expr AsExpr, v ...AsExpr) *InOperatorExpr
func (*InOperatorExpr) AsExpr ¶
func (o *InOperatorExpr) AsExpr(s *Serializer)
type InfixOperatorExpr ¶
type InfixOperatorExpr struct {
// contains filtered or unexported fields
}
func InfixOperator ¶
func InfixOperator(operator string, exprs ...AsExpr) *InfixOperatorExpr
func (*InfixOperatorExpr) AsExpr ¶
func (o *InfixOperatorExpr) AsExpr(s *Serializer)
type InsertColumns ¶
type InsertColumns map[*BasicColumn]AsExpr
type InsertStatement ¶
type InsertStatement struct {
// contains filtered or unexported fields
}
func Insert ¶
func Insert() *InsertStatement
func (*InsertStatement) AsStatement ¶
func (q *InsertStatement) AsStatement(s *Serializer)
func (*InsertStatement) Columns ¶
func (s *InsertStatement) Columns(columns InsertColumns) *InsertStatement
func (*InsertStatement) Returning ¶ added in v1.1.0
func (s *InsertStatement) Returning(returning ...AsExpr) *InsertStatement
func (*InsertStatement) Table ¶
func (s *InsertStatement) Table(table *Table) *InsertStatement
type JoinExpr ¶
type JoinExpr struct {
// contains filtered or unexported fields
}
func CrossJoin ¶
func CrossJoin(left, right AsTableOrSubquery) *JoinExpr
func Join ¶
func Join(kind string, left, right AsTableOrSubquery) *JoinExpr
func LeftJoin ¶
func LeftJoin(left, right AsTableOrSubquery) *JoinExpr
func (*JoinExpr) AsTableOrSubquery ¶
func (j *JoinExpr) AsTableOrSubquery(s *Serializer)
func (*JoinExpr) CrossJoin ¶
func (j *JoinExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*JoinExpr) LeftJoin ¶
func (j *JoinExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
type LikeOperatorExpr ¶
type LikeOperatorExpr struct {
// contains filtered or unexported fields
}
func Like ¶
func Like(left, right AsExpr) *LikeOperatorExpr
func (*LikeOperatorExpr) AsExpr ¶
func (o *LikeOperatorExpr) AsExpr(s *Serializer)
type LiteralExpr ¶
type LiteralExpr struct {
// contains filtered or unexported fields
}
func Literal ¶
func Literal(text string) *LiteralExpr
func (*LiteralExpr) As ¶
func (e *LiteralExpr) As(alias string) *ColumnAlias
func (*LiteralExpr) AsExpr ¶
func (l *LiteralExpr) AsExpr(s *Serializer)
type MSSQLDistinctExpr ¶
type MSSQLDistinctExpr struct{}
func MSSQLDistinct ¶
func MSSQLDistinct() *MSSQLDistinctExpr
func (*MSSQLDistinctExpr) AsDistinct ¶
func (e *MSSQLDistinctExpr) AsDistinct(s *Serializer)
type MSSQLOffsetLimitClause ¶
type MSSQLOffsetLimitClause struct {
// contains filtered or unexported fields
}
func MSSQLOffsetLimit ¶
func MSSQLOffsetLimit(offset, limit AsExpr) *MSSQLOffsetLimitClause
func (*MSSQLOffsetLimitClause) AsOffsetLimit ¶
func (c *MSSQLOffsetLimitClause) AsOffsetLimit(s *Serializer)
type OffsetLimitClause ¶
type OffsetLimitClause struct {
// contains filtered or unexported fields
}
func OffsetLimit ¶
func OffsetLimit(offset, limit AsExpr) *OffsetLimitClause
func (*OffsetLimitClause) AsOffsetLimit ¶
func (c *OffsetLimitClause) AsOffsetLimit(s *Serializer)
type OrderingTerm ¶
type OrderingTerm struct {
// contains filtered or unexported fields
}
func OrderAsc ¶
func OrderAsc(expr AsExpr) *OrderingTerm
func OrderAscNullsFirst ¶ added in v1.4.0
func OrderAscNullsFirst(expr AsExpr) *OrderingTerm
func OrderAscNullsLast ¶ added in v1.4.0
func OrderAscNullsLast(expr AsExpr) *OrderingTerm
func OrderDefault ¶
func OrderDefault(expr AsExpr) *OrderingTerm
func OrderDefaultNullsFirst ¶ added in v1.4.0
func OrderDefaultNullsFirst(expr AsExpr) *OrderingTerm
func OrderDefaultNullsLast ¶ added in v1.4.0
func OrderDefaultNullsLast(expr AsExpr) *OrderingTerm
func OrderDesc ¶
func OrderDesc(expr AsExpr) *OrderingTerm
func OrderDescNullsFirst ¶ added in v1.4.0
func OrderDescNullsFirst(expr AsExpr) *OrderingTerm
func OrderDescNullsLast ¶ added in v1.4.0
func OrderDescNullsLast(expr AsExpr) *OrderingTerm
func (*OrderingTerm) AsOrderingTerm ¶
func (t *OrderingTerm) AsOrderingTerm(s *Serializer)
type PostfixOperatorExpr ¶
type PostfixOperatorExpr struct {
// contains filtered or unexported fields
}
func IsNotNull ¶
func IsNotNull(expr AsExpr) *PostfixOperatorExpr
func IsNull ¶
func IsNull(expr AsExpr) *PostfixOperatorExpr
func PostfixOperator ¶
func PostfixOperator(expr AsExpr, operator string) *PostfixOperatorExpr
func (*PostfixOperatorExpr) AsExpr ¶
func (o *PostfixOperatorExpr) AsExpr(s *Serializer)
type PrefixOperatorExpr ¶
type PrefixOperatorExpr struct {
// contains filtered or unexported fields
}
func Not ¶
func Not(expr AsExpr) *PrefixOperatorExpr
func PrefixOperator ¶
func PrefixOperator(operator string, expr AsExpr) *PrefixOperatorExpr
func (*PrefixOperatorExpr) AsExpr ¶
func (o *PrefixOperatorExpr) AsExpr(s *Serializer)
type SelectStatement ¶
type SelectStatement struct {
// contains filtered or unexported fields
}
func Select ¶
func Select() *SelectStatement
func (*SelectStatement) AndOrderBy ¶
func (s *SelectStatement) AndOrderBy(orderBy ...AsOrderingTerm) *SelectStatement
func (*SelectStatement) AndUnion ¶
func (s *SelectStatement) AndUnion(union ...AsUnion) *SelectStatement
func (*SelectStatement) AndWhere ¶
func (s *SelectStatement) AndWhere(where AsExpr) *SelectStatement
func (*SelectStatement) AndWith ¶
func (s *SelectStatement) AndWith(with ...AsCommonTableExpression) *SelectStatement
func (*SelectStatement) As ¶
func (q *SelectStatement) As(alias string) AsExpr
func (*SelectStatement) AsExpr ¶
func (q *SelectStatement) AsExpr(s *Serializer)
func (*SelectStatement) AsStatement ¶
func (q *SelectStatement) AsStatement(s *Serializer)
func (*SelectStatement) AsTableOrSubquery ¶
func (q *SelectStatement) AsTableOrSubquery(s *Serializer)
func (*SelectStatement) C ¶
func (q *SelectStatement) C(name string) *BasicColumn
func (*SelectStatement) Columns ¶
func (s *SelectStatement) Columns(columns ...AsExpr) *SelectStatement
func (*SelectStatement) CrossJoin ¶
func (q *SelectStatement) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*SelectStatement) Distinct ¶
func (s *SelectStatement) Distinct(distinct AsDistinct) *SelectStatement
func (*SelectStatement) From ¶
func (s *SelectStatement) From(from AsTableOrSubquery) *SelectStatement
func (*SelectStatement) GetFrom ¶
func (s *SelectStatement) GetFrom() AsTableOrSubquery
func (*SelectStatement) GetWhere ¶
func (s *SelectStatement) GetWhere() AsExpr
func (*SelectStatement) GroupBy ¶
func (s *SelectStatement) GroupBy(groupBy ...AsExpr) *SelectStatement
func (*SelectStatement) Having ¶
func (s *SelectStatement) Having(having AsExpr) *SelectStatement
func (*SelectStatement) Join ¶
func (q *SelectStatement) Join(kind string, right AsTableOrSubquery) *JoinExpr
func (*SelectStatement) LeftJoin ¶
func (q *SelectStatement) LeftJoin(right AsTableOrSubquery) *JoinExpr
func (*SelectStatement) OffsetLimit ¶
func (s *SelectStatement) OffsetLimit(offsetLimit AsOffsetLimit) *SelectStatement
func (*SelectStatement) OrderBy ¶
func (s *SelectStatement) OrderBy(orderBy ...AsOrderingTerm) *SelectStatement
func (*SelectStatement) Union ¶
func (s *SelectStatement) Union(union ...AsUnion) *SelectStatement
func (*SelectStatement) Where ¶
func (s *SelectStatement) Where(where AsExpr) *SelectStatement
func (*SelectStatement) With ¶
func (s *SelectStatement) With(with ...AsCommonTableExpression) *SelectStatement
type Serializer ¶
type Serializer struct {
// contains filtered or unexported fields
}
func NewSerializer ¶
func NewSerializer(d Dialect) *Serializer
func (*Serializer) Bind ¶
func (s *Serializer) Bind(val interface{}) *BoundVariable
Bind binds a variable to this serializer - this can be used for e.g. symbolic representation of user input.
func (*Serializer) BindAllAsExpr ¶
func (s *Serializer) BindAllAsExpr(vals ...interface{}) []AsExpr
BindAllAsExpr binds multiple variables to this serializer at once, returning them as []AsExpr. This is most useful for In and NotIn conditions.
func (*Serializer) BindAllIntsAsExpr ¶
func (s *Serializer) BindAllIntsAsExpr(vals ...int) []AsExpr
BindAllIntsAsExpr binds multiple variables to this serializer at once, returning them as []AsExpr. This is most useful for In and NotIn conditions.
func (*Serializer) BindAllStringsAsExpr ¶
func (s *Serializer) BindAllStringsAsExpr(vals ...string) []AsExpr
BindAllStringsAsExpr binds multiple variables to this serializer at once, returning them as []AsExpr. This is most useful for In and NotIn conditions.
func (*Serializer) D ¶
func (s *Serializer) D(data string) *Serializer
D adds string data to the query
func (*Serializer) DC ¶
func (s *Serializer) DC(data string, w bool) *Serializer
DC adds string data to the query, only if "w" is true
func (*Serializer) F ¶
func (s *Serializer) F(f func(s *Serializer)) *Serializer
F runs a function taking the Serializer as its only argument
func (*Serializer) FC ¶
func (s *Serializer) FC(f func(s *Serializer), w bool) *Serializer
FC runs a function taking the Serializer as its only argument, only if "w" is true
func (*Serializer) N ¶
func (s *Serializer) N(name string) *Serializer
N adds a "name" value to the query, which should be quoted as per the dialect
func (*Serializer) NC ¶
func (s *Serializer) NC(name string, w bool) *Serializer
NC adds a "name" value to the query, which should be quoted as per the dialect, only if "w" is true
func (*Serializer) SetDialect ¶
func (s *Serializer) SetDialect(d Dialect)
SetDialect sets the dialect for this serializer
func (*Serializer) ToSQL ¶
func (s *Serializer) ToSQL() (string, []interface{}, error)
ToSQL serializes the whole query, returning the query itself and any variables requred to execute it
func (*Serializer) V ¶
func (s *Serializer) V(val interface{}) *Serializer
V adds a value to the query, where the value should be replaced with a placeholder
func (*Serializer) VC ¶
func (s *Serializer) VC(val interface{}, w bool) *Serializer
VC adds a value to the query, where the value should be replaced with a placeholder, only if "w" is true
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) AsNamed ¶
func (t *Table) AsNamed(s *Serializer)
func (*Table) AsTableOrSubquery ¶
func (t *Table) AsTableOrSubquery(s *Serializer)
func (*Table) C ¶
func (t *Table) C(name string) *BasicColumn
func (*Table) CrossJoin ¶
func (t *Table) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*Table) LeftJoin ¶
func (t *Table) LeftJoin(right AsTableOrSubquery) *JoinExpr
type TableAlias ¶
type TableAlias struct {
// contains filtered or unexported fields
}
func AliasTable ¶
func AliasTable(t AsTableOrSubqueryAndWithColumns, name string) *TableAlias
func (*TableAlias) AsNamed ¶
func (a *TableAlias) AsNamed(s *Serializer)
func (*TableAlias) AsTableOrSubquery ¶
func (a *TableAlias) AsTableOrSubquery(s *Serializer)
func (*TableAlias) C ¶
func (a *TableAlias) C(name string) *BasicColumn
func (*TableAlias) CrossJoin ¶
func (a *TableAlias) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*TableAlias) Join ¶
func (a *TableAlias) Join(kind string, right AsTableOrSubquery) *JoinExpr
func (*TableAlias) LeftJoin ¶
func (a *TableAlias) LeftJoin(right AsTableOrSubquery) *JoinExpr
type TypedLiteralExpr ¶ added in v1.1.0
type TypedLiteralExpr struct {
// contains filtered or unexported fields
}
func TypedLiteral ¶ added in v1.1.0
func TypedLiteral(typ, text string) *TypedLiteralExpr
func (*TypedLiteralExpr) As ¶ added in v1.1.0
func (e *TypedLiteralExpr) As(alias string) *ColumnAlias
func (*TypedLiteralExpr) AsExpr ¶ added in v1.1.0
func (l *TypedLiteralExpr) AsExpr(s *Serializer)
type UnionExpr ¶
type UnionExpr struct {
// contains filtered or unexported fields
}
func Union ¶
func Union(all bool, stmt *SelectStatement) *UnionExpr
func (*UnionExpr) AsUnion ¶
func (e *UnionExpr) AsUnion(s *Serializer)
type UpdateColumns ¶
type UpdateColumns map[*BasicColumn]AsExpr
type UpdateField ¶ added in v1.2.0
type UpdateField struct { Name AsNamedShort Value AsExpr }
type UpdateStatement ¶
type UpdateStatement struct {
// contains filtered or unexported fields
}
func Update ¶
func Update() *UpdateStatement
func (*UpdateStatement) AndField ¶ added in v1.2.0
func (s *UpdateStatement) AndField(field UpdateField) *UpdateStatement
func (*UpdateStatement) AndSet ¶
func (s *UpdateStatement) AndSet(column *BasicColumn, expr AsExpr) *UpdateStatement
func (*UpdateStatement) AndWith ¶ added in v1.1.0
func (s *UpdateStatement) AndWith(with ...AsCommonTableExpression) *UpdateStatement
func (*UpdateStatement) AsStatement ¶
func (q *UpdateStatement) AsStatement(s *Serializer)
func (*UpdateStatement) Fields ¶ added in v1.2.0
func (s *UpdateStatement) Fields(fields []UpdateField) *UpdateStatement
func (*UpdateStatement) From ¶ added in v1.1.0
func (s *UpdateStatement) From(from AsTableOrSubquery) *UpdateStatement
func (*UpdateStatement) GetTarget ¶ added in v1.1.0
func (s *UpdateStatement) GetTarget() AsTableOrSubquery
func (*UpdateStatement) Returning ¶ added in v1.1.0
func (s *UpdateStatement) Returning(returning ...AsExpr) *UpdateStatement
func (*UpdateStatement) Set ¶
func (s *UpdateStatement) Set(columns UpdateColumns) *UpdateStatement
func (*UpdateStatement) Table ¶
func (s *UpdateStatement) Table(table *Table) *UpdateStatement
func (*UpdateStatement) Target ¶ added in v1.1.0
func (s *UpdateStatement) Target(target AsTableOrSubquery) *UpdateStatement
func (*UpdateStatement) Where ¶
func (s *UpdateStatement) Where(where AsExpr) *UpdateStatement
func (*UpdateStatement) With ¶ added in v1.1.0
func (s *UpdateStatement) With(with ...AsCommonTableExpression) *UpdateStatement
type ValuesExpr ¶
type ValuesExpr struct {
// contains filtered or unexported fields
}
func Values ¶
func Values(rows ...*ValuesRowExpr) *ValuesExpr
func (*ValuesExpr) AsExpr ¶
func (v *ValuesExpr) AsExpr(s *Serializer)
type ValuesRowExpr ¶
type ValuesRowExpr struct {
// contains filtered or unexported fields
}
func ValuesRow ¶
func ValuesRow(values ...AsExpr) *ValuesRowExpr
func (*ValuesRowExpr) AsExpr ¶
func (r *ValuesRowExpr) AsExpr(s *Serializer)
type ValuesTableExpr ¶
type ValuesTableExpr struct {
// contains filtered or unexported fields
}
func ValuesTable ¶
func ValuesTable(expr *ValuesExpr, name string, names ...string) *ValuesTableExpr
func (*ValuesTableExpr) AsNamed ¶
func (t *ValuesTableExpr) AsNamed(s *Serializer)
func (*ValuesTableExpr) AsTableOrSubquery ¶
func (t *ValuesTableExpr) AsTableOrSubquery(s *Serializer)
func (*ValuesTableExpr) C ¶
func (t *ValuesTableExpr) C(name string) *BasicColumn
func (*ValuesTableExpr) CrossJoin ¶
func (t *ValuesTableExpr) CrossJoin(right AsTableOrSubquery) *JoinExpr
func (*ValuesTableExpr) Join ¶
func (t *ValuesTableExpr) Join(kind string, right AsTableOrSubquery) *JoinExpr
func (*ValuesTableExpr) LeftJoin ¶
func (t *ValuesTableExpr) LeftJoin(right AsTableOrSubquery) *JoinExpr
type WithColumns ¶
type WithColumns interface {
C(name string) *BasicColumn
}