Documentation
¶
Index ¶
- Constants
- Variables
- type Aliaseable
- type AliasedExpression
- type AppendableExpression
- type BitwiseExpression
- type BitwiseOperation
- type Bitwiseable
- type BooleanExpression
- type BooleanOperation
- type CaseElse
- type CaseExpression
- type CaseWhen
- type CastExpression
- type Castable
- type ColumnListExpression
- type CommonTableExpression
- type Comparable
- type CompoundExpression
- type CompoundType
- type ConditionedJoinExpression
- type ConflictAction
- type ConflictExpression
- type ConflictUpdateExpression
- type DeleteClauses
- type Distinctable
- type Ex
- type ExOr
- type Expression
- type ExpressionList
- type ExpressionListType
- type IdentifierExpression
- type Inable
- type InsertClauses
- type InsertExpression
- type Isable
- type JoinCondition
- type JoinConditionType
- type JoinExpression
- type JoinExpressions
- type JoinOnCondition
- type JoinType
- type JoinUsingCondition
- type LateralExpression
- type Likeable
- type LiteralExpression
- type Lock
- type LockStrength
- type NullSortType
- type Op
- type Orderable
- type OrderedExpression
- type RangeExpression
- type RangeOperation
- type RangeVal
- type Rangeable
- type Record
- type SQLExpression
- type SQLFunctionExpression
- type SQLWindowFunctionExpression
- type SelectClauses
- type SortDirection
- type TruncateClauses
- type TruncateOptions
- type UpdateClauses
- type UpdateExpression
- type Updateable
- type Vals
- type WaitOption
- type WindowExpression
- type Windowable
Constants ¶
const ( UnionCompoundType CompoundType = iota UnionAllCompoundType IntersectCompoundType IntersectAllCompoundType DoNothingConflictAction ConflictAction = iota DoUpdateConflictAction AndType ExpressionListType = iota OrType InnerJoinType JoinType = iota FullOuterJoinType RightOuterJoinType LeftOuterJoinType FullJoinType RightJoinType LeftJoinType NaturalJoinType NaturalLeftJoinType NaturalRightJoinType NaturalFullJoinType CrossJoinType UsingJoinCondType JoinConditionType = iota OnJoinCondType // Default null sort type with no null sort order NoNullsSortType NullSortType = iota // NULLS FIRST NullsFirstSortType // NULLS LAST NullsLastSortType // ASC AscDir SortDirection = iota // DESC DescSortDir // BETWEEN BetweenOp RangeOperation = iota // NOT BETWEEN NotBetweenOp // = EqOp BooleanOperation = iota // != or <> NeqOp // IS IsOp // IS NOT IsNotOp // > GtOp // >= GteOp // < LtOp // <= LteOp // IN InOp // NOT IN NotInOp // LIKE, LIKE BINARY... LikeOp // NOT LIKE, NOT LIKE BINARY... NotLikeOp // ILIKE, LIKE ILikeOp // NOT ILIKE, NOT LIKE NotILikeOp // ~, REGEXP BINARY RegexpLikeOp // !~, NOT REGEXP BINARY RegexpNotLikeOp // ~*, REGEXP RegexpILikeOp // !~*, NOT REGEXP RegexpNotILikeOp BitwiseInversionOp BitwiseOperation = iota BitwiseOrOp BitwiseAndOp BitwiseXorOp BitwiseLeftShiftOp BitwiseRightShiftOp )
const ( ForNolock LockStrength = iota ForUpdate ForNoKeyUpdate Wait WaitOption = iota NoWait SkipLocked )
Variables ¶
var ( ConditionedJoinTypes = map[JoinType]bool{ InnerJoinType: true, FullOuterJoinType: true, RightOuterJoinType: true, LeftOuterJoinType: true, FullJoinType: true, RightJoinType: true, LeftJoinType: true, } )
Functions ¶
This section is empty.
Types ¶
type Aliaseable ¶
type Aliaseable interface {
// Returns an AliasedExpression
// I("col").As("other_col") //"col" AS "other_col"
// I("col").As(I("other_col")) //"col" AS "other_col"
As(interface{}) AliasedExpression
}
Interface that an expression should implement if it can be aliased.
type AliasedExpression ¶
type AliasedExpression interface {
Expression
// Returns the Epxression being aliased
Aliased() Expression
// Returns the alias value as an identiier expression
GetAs() IdentifierExpression
// Returns a new IdentifierExpression with the specified schema
Schema(string) IdentifierExpression
// Returns a new IdentifierExpression with the specified table
Table(string) IdentifierExpression
// Returns a new IdentifierExpression with the specified column
Col(interface{}) IdentifierExpression
// Returns a new IdentifierExpression with the column set to *
// I("my_table").All() //"my_table".*
All() IdentifierExpression
}
Expression for Aliased expressions
I("a").As("b") -> "a" AS "b"
SUM("a").As(I("a_sum")) -> SUM("a") AS "a_sum"
func NewAliasExpression ¶
func NewAliasExpression(exp Expression, alias interface{}) AliasedExpression
Creates a new AliasedExpression for the Expression and alias
type AppendableExpression ¶
type AppendableExpression interface {
Expression
AppendSQL(b sb.SQLBuilder)
// Returns the alias value as an identiier expression
GetAs() IdentifierExpression
// Returns true if this expression returns columns.
// Used to determine if a Select, Update, Insert, or Delete query returns columns
ReturnsColumns() bool
}
type BitwiseExpression ¶
type BitwiseExpression interface {
Expression
Aliaseable
Comparable
Isable
Inable
Likeable
Rangeable
Orderable
Distinctable
// Returns the operator for the expression
Op() BitwiseOperation
// The left hand side of the expression (e.g. I("a")
LHS() Expression
// The right hand side of the expression could be a primitive value, dataset, or expression
RHS() interface{}
}
func NewBitwiseExpression ¶
func NewBitwiseExpression(op BitwiseOperation, lhs Expression, rhs interface{}) BitwiseExpression
type BitwiseOperation ¶
type BitwiseOperation int
func (BitwiseOperation) String ¶
func (bi BitwiseOperation) String() string
type Bitwiseable ¶
type Bitwiseable interface {
// Creates a Bit Operation Expresion for sql ~
// I("col").BitiInversion() // (~ "col")
BitwiseInversion() BitwiseExpression
// Creates a Bit Operation Expresion for sql |
// I("col").BitOr(1) // ("col" | 1)
BitwiseOr(interface{}) BitwiseExpression
// Creates a Bit Operation Expresion for sql &
// I("col").BitAnd(1) // ("col" & 1)
BitwiseAnd(interface{}) BitwiseExpression
// Creates a Bit Operation Expresion for sql ^
// I("col").BitXor(1) // ("col" ^ 1)
BitwiseXor(interface{}) BitwiseExpression
// Creates a Bit Operation Expresion for sql <<
// I("col").BitLeftShift(1) // ("col" << 1)
BitwiseLeftShift(interface{}) BitwiseExpression
// Creates a Bit Operation Expresion for sql >>
// I("col").BitRighttShift(1) // ("col" >> 1)
BitwiseRightShift(interface{}) BitwiseExpression
}
Behaviors
type BooleanExpression ¶
type BooleanExpression interface {
Expression
Aliaseable
// Returns the operator for the expression
Op() BooleanOperation
// The left hand side of the expression (e.g. I("a")
LHS() Expression
// The right hand side of the expression could be a primitive value, dataset, or expression
RHS() interface{}
}
func NewBooleanExpression ¶
func NewBooleanExpression(op BooleanOperation, lhs Expression, rhs interface{}) BooleanExpression
type BooleanOperation ¶
type BooleanOperation int
func (BooleanOperation) String ¶
func (bo BooleanOperation) String() string
type CaseElse ¶
type CaseElse interface {
Result() interface{}
}
func NewCaseElse ¶
func NewCaseElse(result interface{}) CaseElse
type CaseExpression ¶
type CaseExpression interface {
Expression
Aliaseable
Orderable
GetValue() interface{}
GetWhens() []CaseWhen
GetElse() CaseElse
Value(val interface{}) CaseExpression
When(condition, result interface{}) CaseExpression
Else(result interface{}) CaseExpression
}
func NewCaseExpression ¶
func NewCaseExpression() CaseExpression
type CaseWhen ¶
type CaseWhen interface {
Condition() interface{}
Result() interface{}
}
func NewCaseWhen ¶
func NewCaseWhen(condition, result interface{}) CaseWhen
type CastExpression ¶
type CastExpression interface {
Expression
Aliaseable
Comparable
Inable
Isable
Likeable
Orderable
Distinctable
Rangeable
// The exression being casted
Casted() Expression
// The the SQL type to cast the expression to
Type() LiteralExpression
}
An Expression that represents another Expression casted to a SQL type
func NewCastExpression ¶
func NewCastExpression(e Expression, t string) CastExpression
Creates a new Casted expression
Cast(I("a"), "NUMERIC") -> CAST("a" AS NUMERIC)
type Castable ¶
type Castable interface {
// Casts an expression to the specified type
// I("a").Cast("numeric")//CAST("a" AS numeric)
Cast(val string) CastExpression
}
Interface that an expression should implement if it can be casted to another SQL type .
type ColumnListExpression ¶
type ColumnListExpression interface {
Expression
// Returns the list of columns
Columns() []Expression
// Returns true if the column list is empty
IsEmpty() bool
// Returns a new ColumnListExpression with the columns appended.
Append(...Expression) ColumnListExpression
}
A list of columns. Typically used internally by Select, Order, From
func NewColumnListExpression ¶
func NewColumnListExpression(vals ...interface{}) ColumnListExpression
func NewOrderedColumnList ¶
func NewOrderedColumnList(vals ...OrderedExpression) ColumnListExpression
type CommonTableExpression ¶
type CommonTableExpression interface {
Expression
IsRecursive() bool
// Returns the alias name for the extracted expression
Name() LiteralExpression
// Returns the Expression being extracted
SubQuery() Expression
}
func NewCommonTableExpression ¶
func NewCommonTableExpression(recursive bool, name string, subQuery Expression) CommonTableExpression
Creates a new WITH common table expression for a SQLExpression, typically Datasets'. This function is used internally by Dataset when a CTE is added to another Dataset
type Comparable ¶
type Comparable interface {
// Creates a Boolean expression comparing equality
// I("col").Eq(1) //("col" = 1)
Eq(interface{}) BooleanExpression
// Creates a Boolean expression comparing in-equality
// I("col").Neq(1) //("col" != 1)
Neq(interface{}) BooleanExpression
// Creates a Boolean expression for greater than comparisons
// I("col").Gt(1) //("col" > 1)
Gt(interface{}) BooleanExpression
// Creates a Boolean expression for greater than or equal to than comparisons
// I("col").Gte(1) //("col" >= 1)
Gte(interface{}) BooleanExpression
// Creates a Boolean expression for less than comparisons
// I("col").Lt(1) //("col" < 1)
Lt(interface{}) BooleanExpression
// Creates a Boolean expression for less than or equal to comparisons
// I("col").Lte(1) //("col" <= 1)
Lte(interface{}) BooleanExpression
}
Interface that an expression should implement if it can be compared with other values.
type CompoundExpression ¶
type CompoundExpression interface {
Expression
Type() CompoundType
RHS() AppendableExpression
}
func NewCompoundExpression ¶
func NewCompoundExpression(ct CompoundType, rhs AppendableExpression) CompoundExpression
type CompoundType ¶
type CompoundType int
type ConditionedJoinExpression ¶
type ConditionedJoinExpression interface {
JoinExpression
Condition() JoinCondition
IsConditionEmpty() bool
}
Parent type for join expressions
func NewConditionedJoinExpression ¶
func NewConditionedJoinExpression(joinType JoinType, table Expression, condition JoinCondition) ConditionedJoinExpression
type ConflictAction ¶
type ConflictAction int
An Expression that the ON CONFLICT/ON DUPLICATE KEY portion of an INSERT statement
type ConflictExpression ¶
type ConflictExpression interface {
Expression
Action() ConflictAction
}
func NewDoNothingConflictExpression ¶
func NewDoNothingConflictExpression() ConflictExpression
Creates a conflict struct to be passed to InsertConflict to ignore constraint errors
InsertConflict(DoNothing(),...) -> INSERT INTO ... ON CONFLICT DO NOTHING
type ConflictUpdateExpression ¶
type ConflictUpdateExpression interface {
ConflictExpression
TargetColumn() string
Where(expressions ...Expression) ConflictUpdateExpression
WhereClause() ExpressionList
Update() interface{}
}
func NewDoUpdateConflictExpression ¶
func NewDoUpdateConflictExpression(target string, update interface{}) ConflictUpdateExpression
Creates a ConflictUpdate struct to be passed to InsertConflict Represents a ON CONFLICT DO UPDATE portion of an INSERT statement (ON DUPLICATE KEY UPDATE for mysql)
InsertConflict(DoUpdate("target_column", update),...) ->
INSERT INTO ... ON CONFLICT DO UPDATE SET a=b
InsertConflict(DoUpdate("target_column", update).Where(Ex{"a": 1},...) ->
INSERT INTO ... ON CONFLICT DO UPDATE SET a=b WHERE a=1
type DeleteClauses ¶
type DeleteClauses interface {
HasFrom() bool
CommonTables() []CommonTableExpression
CommonTablesAppend(cte CommonTableExpression) DeleteClauses
From() IdentifierExpression
SetFrom(table IdentifierExpression) DeleteClauses
Where() ExpressionList
ClearWhere() DeleteClauses
WhereAppend(expressions ...Expression) DeleteClauses
Order() ColumnListExpression
HasOrder() bool
ClearOrder() DeleteClauses
SetOrder(oes ...OrderedExpression) DeleteClauses
OrderAppend(...OrderedExpression) DeleteClauses
OrderPrepend(...OrderedExpression) DeleteClauses
Limit() interface{}
HasLimit() bool
ClearLimit() DeleteClauses
SetLimit(limit interface{}) DeleteClauses
Returning() ColumnListExpression
HasReturning() bool
SetReturning(cl ColumnListExpression) DeleteClauses
// contains filtered or unexported methods
}
func NewDeleteClauses ¶
func NewDeleteClauses() DeleteClauses
type Distinctable ¶
type Distinctable interface {
// Creates a DISTINCT clause
// I("a").Distinct() //DISTINCT("a")
Distinct() SQLFunctionExpression
}
Interface that an expression should implement if it can be used in a DISTINCT epxression.
type Ex ¶
type Ex map[string]interface{}
A map of expressions to be ANDed together where the keys are string that will be used as Identifiers and values will be used in a boolean operation. The Ex map can be used in tandem with Op map to create more complex expression such as LIKE, GT, LT... See examples.
func (Ex) Clone ¶
func (e Ex) Clone() Expression
func (Ex) Expression ¶
func (e Ex) Expression() Expression
func (Ex) ToExpressions ¶
func (e Ex) ToExpressions() (ExpressionList, error)
type ExOr ¶
type ExOr map[string]interface{}
A map of expressions to be ORed together where the keys are string that will be used as Identifiers and values will be used in a boolean operation. The Ex map can be used in tandem with Op map to create more complex expression such as LIKE, GT, LT... See examples.
func (ExOr) Clone ¶
func (eo ExOr) Clone() Expression
func (ExOr) Expression ¶
func (eo ExOr) Expression() Expression
func (ExOr) ToExpressions ¶
func (eo ExOr) ToExpressions() (ExpressionList, error)
type Expression ¶
type Expression interface {
Clone() Expression
Expression() Expression
}
Parent of all expression types
type ExpressionList ¶
type ExpressionList interface {
Expression
// Returns type (e.g. OR, AND)
Type() ExpressionListType
// Slice of expressions that should be joined together
Expressions() []Expression
// Returns a new expression list with the given expressions appended to the current Expressions list
Append(...Expression) ExpressionList
IsEmpty() bool
}
A list of expressions that should be joined together
And(I("a").Eq(10), I("b").Eq(11)) //(("a" = 10) AND ("b" = 11))
Or(I("a").Eq(10), I("b").Eq(11)) //(("a" = 10) OR ("b" = 11))
func NewExpressionList ¶
func NewExpressionList(operator ExpressionListType, expressions ...Expression) ExpressionList
A list of expressions that should be ORed together
Or(I("a").Eq(10), I("b").Eq(11)) //(("a" = 10) OR ("b" = 11))
type ExpressionListType ¶
type ExpressionListType int
type IdentifierExpression ¶
type IdentifierExpression interface {
Expression
Aliaseable
Comparable
Inable
Isable
Likeable
Rangeable
Orderable
Updateable
Distinctable
Castable
Bitwiseable
// returns true if this identifier has more more than on part (Schema, Table or Col)
// "schema" -> true //cant qualify anymore
// "schema.table" -> true
// "table" -> false
// "schema"."table"."col" -> true
// "table"."col" -> true
// "col" -> false
IsQualified() bool
// Returns a new IdentifierExpression with the specified schema
Schema(string) IdentifierExpression
// Returns the current schema
GetSchema() string
// Returns a new IdentifierExpression with the specified table
Table(string) IdentifierExpression
// Returns the current table
GetTable() string
// Returns a new IdentifierExpression with the specified column
Col(interface{}) IdentifierExpression
// Returns the current column
GetCol() interface{}
// Returns a new IdentifierExpression with the column set to *
// I("my_table").All() //"my_table".*
All() IdentifierExpression
// Returns true if schema table and identifier are all zero values.
IsEmpty() bool
}
An Identifier that can contain schema, table and column identifiers
func NewIdentifierExpression ¶
func NewIdentifierExpression(schema, table string, col interface{}) IdentifierExpression
func ParseIdentifier ¶
func ParseIdentifier(ident string) IdentifierExpression
type Inable ¶
type Inable interface {
// Creates a Boolean expression for IN clauses
// I("col").In([]string{"a", "b", "c"}) //("col" IN ('a', 'b', 'c'))
In(...interface{}) BooleanExpression
// Creates a Boolean expression for NOT IN clauses
// I("col").NotIn([]string{"a", "b", "c"}) //("col" NOT IN ('a', 'b', 'c'))
NotIn(...interface{}) BooleanExpression
}
Behaviors
type InsertClauses ¶
type InsertClauses interface {
CommonTables() []CommonTableExpression
CommonTablesAppend(cte CommonTableExpression) InsertClauses
HasInto() bool
Cols() ColumnListExpression
HasCols() bool
ColsAppend(cols ColumnListExpression) InsertClauses
SetCols(cols ColumnListExpression) InsertClauses
Into() Expression
SetInto(cl Expression) InsertClauses
Returning() ColumnListExpression
HasReturning() bool
SetReturning(cl ColumnListExpression) InsertClauses
From() AppendableExpression
HasFrom() bool
SetFrom(ae AppendableExpression) InsertClauses
Rows() []interface{}
HasRows() bool
SetRows(rows []interface{}) InsertClauses
HasAlias() bool
Alias() IdentifierExpression
SetAlias(ie IdentifierExpression) InsertClauses
Vals() [][]interface{}
HasVals() bool
SetVals(vals [][]interface{}) InsertClauses
ValsAppend(vals [][]interface{}) InsertClauses
OnConflict() ConflictExpression
SetOnConflict(expression ConflictExpression) InsertClauses
// contains filtered or unexported methods
}
func NewInsertClauses ¶
func NewInsertClauses() InsertClauses
type InsertExpression ¶
type InsertExpression interface {
Expression
IsEmpty() bool
IsInsertFrom() bool
From() AppendableExpression
Cols() ColumnListExpression
SetCols(cols ColumnListExpression) InsertExpression
Vals() [][]interface{}
SetVals([][]interface{}) InsertExpression
}
func NewInsertExpression ¶
func NewInsertExpression(rows ...interface{}) (insertExpression InsertExpression, err error)
type Isable ¶
type Isable interface {
// Creates an Boolean expression IS clauses
// ds.Where(I("a").Is(nil)) //("a" IS NULL)
// ds.Where(I("a").Is(true)) //("a" IS TRUE)
// ds.Where(I("a").Is(false)) //("a" IS FALSE)
Is(interface{}) BooleanExpression
// Creates an Boolean expression IS NOT clauses
// ds.Where(I("a").IsNot(nil)) //("a" IS NOT NULL)
// ds.Where(I("a").IsNot(true)) //("a" IS NOT TRUE)
// ds.Where(I("a").IsNot(false)) //("a" IS NOT FALSE)
IsNot(interface{}) BooleanExpression
// Shortcut for Is(nil)
IsNull() BooleanExpression
// Shortcut for IsNot(nil)
IsNotNull() BooleanExpression
// Shortcut for Is(true)
IsTrue() BooleanExpression
// Shortcut for IsNot(true)
IsNotTrue() BooleanExpression
// Shortcut for Is(false)
IsFalse() BooleanExpression
// Shortcut for IsNot(false)
IsNotFalse() BooleanExpression
}
Behaviors
type JoinCondition ¶
type JoinCondition interface {
Type() JoinConditionType
IsEmpty() bool
}
func NewJoinOnCondition ¶
func NewJoinOnCondition(expressions ...Expression) JoinCondition
Creates a new ON clause to be used within a join
ds.Join(I("my_table"), On(I("my_table.fkey").Eq(I("other_table.id")))
func NewJoinUsingCondition ¶
func NewJoinUsingCondition(expressions ...interface{}) JoinCondition
Creates a new USING clause to be used within a join
type JoinConditionType ¶
type JoinConditionType int
type JoinExpression ¶
type JoinExpression interface {
Expression
JoinType() JoinType
IsConditioned() bool
Table() Expression
}
func NewUnConditionedJoinExpression ¶
func NewUnConditionedJoinExpression(joinType JoinType, table Expression) JoinExpression
type JoinExpressions ¶
type JoinExpressions []JoinExpression
func (JoinExpressions) Clone ¶
func (jes JoinExpressions) Clone() JoinExpressions
type JoinOnCondition ¶
type JoinOnCondition interface {
JoinCondition
On() ExpressionList
}
type JoinUsingCondition ¶
type JoinUsingCondition interface {
JoinCondition
Using() ColumnListExpression
}
type LateralExpression ¶
type LateralExpression interface {
Expression
Aliaseable
Table() AppendableExpression
}
func NewLateralExpression ¶
func NewLateralExpression(table AppendableExpression) LateralExpression
Creates a new SQL lateral expression
L(From("test")) -> LATERAL (SELECT * FROM "tests")
type Likeable ¶
type Likeable interface {
// Creates an Boolean expression for LIKE clauses
// ds.Where(I("a").Like("a%")) //("a" LIKE 'a%')
Like(interface{}) BooleanExpression
// Creates an Boolean expression for NOT LIKE clauses
// ds.Where(I("a").NotLike("a%")) //("a" NOT LIKE 'a%')
NotLike(interface{}) BooleanExpression
// Creates an Boolean expression for case insensitive LIKE clauses
// ds.Where(I("a").ILike("a%")) //("a" ILIKE 'a%')
ILike(interface{}) BooleanExpression
// Creates an Boolean expression for case insensitive NOT LIKE clauses
// ds.Where(I("a").NotILike("a%")) //("a" NOT ILIKE 'a%')
NotILike(interface{}) BooleanExpression
// Creates an Boolean expression for REGEXP LIKE clauses
// ds.Where(I("a").RegexpLike("a%")) //("a" ~ 'a%')
RegexpLike(interface{}) BooleanExpression
// Creates an Boolean expression for REGEXP NOT LIKE clauses
// ds.Where(I("a").RegexpNotLike("a%")) //("a" !~ 'a%')
RegexpNotLike(interface{}) BooleanExpression
// Creates an Boolean expression for case insensitive REGEXP ILIKE clauses
// ds.Where(I("a").RegexpILike("a%")) //("a" ~* 'a%')
RegexpILike(interface{}) BooleanExpression
// Creates an Boolean expression for case insensitive REGEXP NOT ILIKE clauses
// ds.Where(I("a").RegexpNotILike("a%")) //("a" !~* 'a%')
RegexpNotILike(interface{}) BooleanExpression
}
Behaviors
type LiteralExpression ¶
type LiteralExpression interface {
Expression
Aliaseable
Comparable
Isable
Inable
Likeable
Rangeable
Orderable
Bitwiseable
// Returns the literal sql
Literal() string
// Arguments to be replaced within the sql
Args() []interface{}
}
Expression for representing "literal" sql.
L("col = 1") -> col = 1)
L("? = ?", I("col"), 1) -> "col" = 1
func NewLiteralExpression ¶
func NewLiteralExpression(sql string, args ...interface{}) LiteralExpression
Creates a new SQL literal with the provided arguments.
L("a = 1") -> a = 1
You can also you placeholders. All placeholders within a Literal are represented by '?'
L("a = ?", "b") -> a = 'b'
Literals can also contain placeholders for other expressions
L("(? AND ?) OR (?)", I("a").Eq(1), I("b").Eq("b"), I("c").In([]string{"a", "b", "c"}))
type Lock ¶
type Lock interface {
Strength() LockStrength
WaitOption() WaitOption
Of() []IdentifierExpression
}
func NewLock ¶
func NewLock(strength LockStrength, option WaitOption, of ...IdentifierExpression) Lock
type LockStrength ¶
type LockStrength int
type NullSortType ¶
type NullSortType int
type Op ¶
type Op map[string]interface{}
Used in tandem with the Ex map to create complex comparisons such as LIKE, GT, LT... See examples
type Orderable ¶
type Orderable interface {
// Creates an Ordered Expression for sql ASC order
// ds.Order(I("a").Asc()) //ORDER BY "a" ASC
Asc() OrderedExpression
// Creates an Ordered Expression for sql DESC order
// ds.Order(I("a").Desc()) //ORDER BY "a" DESC
Desc() OrderedExpression
}
Interface that an expression should implement if it can be ORDERED.
type OrderedExpression ¶
type OrderedExpression interface {
Expression
// The expression being sorted
SortExpression() Expression
// Sort direction (e.g. ASC, DESC)
IsAsc() bool
// If the adapter supports it null sort type (e.g. NULLS FIRST, NULLS LAST)
NullSortType() NullSortType
// Returns a new OrderedExpression with NullSortType set to NULLS_FIRST
NullsFirst() OrderedExpression
// Returns a new OrderedExpression with NullSortType set to NULLS_LAST
NullsLast() OrderedExpression
}
An expression for specifying sort order and options
func NewOrderedExpression ¶
func NewOrderedExpression(exp Expression, direction SortDirection, sortType NullSortType) OrderedExpression
used internally to create a new SORT_ASC OrderedExpression
type RangeExpression ¶
type RangeExpression interface {
Expression
// Returns the operator for the expression
Op() RangeOperation
// The left hand side of the expression (e.g. I("a")
LHS() Expression
// The right hand side of the expression could be a primitive value, dataset, or expression
RHS() RangeVal
}
func NewRangeExpression ¶
func NewRangeExpression(op RangeOperation, lhs Expression, rhs RangeVal) RangeExpression
type RangeOperation ¶
type RangeOperation int
func (RangeOperation) String ¶
func (ro RangeOperation) String() string
type RangeVal ¶
type RangeVal interface {
Start() interface{}
End() interface{}
}
func NewRangeVal ¶
func NewRangeVal(start, end interface{}) RangeVal
Creates a new Range to be used with a Between expression
exp.C("col").Between(exp.Range(1, 10))
type Rangeable ¶
type Rangeable interface {
// Creates a Range expression for between comparisons
// I("col").Between(RangeVal{Start:1, End:10}) //("col" BETWEEN 1 AND 10)
Between(RangeVal) RangeExpression
// Creates a Range expression for between comparisons
// I("col").NotBetween(RangeVal{Start:1, End:10}) //("col" NOT BETWEEN 1 AND 10)
NotBetween(RangeVal) RangeExpression
}
Behaviors
type Record ¶
type Record map[string]interface{}
Alternative to writing map[string]interface{}. Can be used for Inserts, Updates or Deletes
func NewRecordFromStruct ¶
type SQLExpression ¶
type SQLExpression interface {
Expression
ToSQL() (string, []interface{}, error)
IsPrepared() bool
}
An Expression that generates its own sql (e.g Dataset)
type SQLFunctionExpression ¶
type SQLFunctionExpression interface {
Expression
Aliaseable
Rangeable
Comparable
Orderable
Isable
Inable
Likeable
Windowable
// The function name
Name() string
// Arguments to be passed to the function
Args() []interface{}
}
Expression for representing a SQLFunction(e.g. COUNT, SUM, MIN, MAX...)
func NewSQLFunctionExpression ¶
func NewSQLFunctionExpression(name string, args ...interface{}) SQLFunctionExpression
Creates a new SQLFunctionExpression with the given name and arguments
type SQLWindowFunctionExpression ¶
type SQLWindowFunctionExpression interface {
Expression
Aliaseable
Rangeable
Comparable
Orderable
Isable
Inable
Likeable
Func() SQLFunctionExpression
Window() WindowExpression
WindowName() IdentifierExpression
HasWindow() bool
HasWindowName() bool
}
func NewSQLWindowFunctionExpression ¶
func NewSQLWindowFunctionExpression( fn SQLFunctionExpression, windowName IdentifierExpression, window WindowExpression) SQLWindowFunctionExpression
type SelectClauses ¶
type SelectClauses interface {
HasSources() bool
IsDefaultSelect() bool
Select() ColumnListExpression
SelectAppend(cl ColumnListExpression) SelectClauses
SetSelect(cl ColumnListExpression) SelectClauses
Distinct() ColumnListExpression
SetDistinct(cle ColumnListExpression) SelectClauses
From() ColumnListExpression
SetFrom(cl ColumnListExpression) SelectClauses
HasAlias() bool
Alias() IdentifierExpression
SetAlias(ie IdentifierExpression) SelectClauses
Joins() JoinExpressions
JoinsAppend(jc JoinExpression) SelectClauses
Where() ExpressionList
ClearWhere() SelectClauses
WhereAppend(expressions ...Expression) SelectClauses
Having() ExpressionList
ClearHaving() SelectClauses
HavingAppend(expressions ...Expression) SelectClauses
Order() ColumnListExpression
HasOrder() bool
ClearOrder() SelectClauses
SetOrder(oes ...OrderedExpression) SelectClauses
OrderAppend(...OrderedExpression) SelectClauses
OrderPrepend(...OrderedExpression) SelectClauses
GroupBy() ColumnListExpression
SetGroupBy(cl ColumnListExpression) SelectClauses
GroupByAppend(cl ColumnListExpression) SelectClauses
Limit() interface{}
HasLimit() bool
ClearLimit() SelectClauses
SetLimit(limit interface{}) SelectClauses
Offset() uint
ClearOffset() SelectClauses
SetOffset(offset uint) SelectClauses
Compounds() []CompoundExpression
CompoundsAppend(ce CompoundExpression) SelectClauses
Lock() Lock
SetLock(l Lock) SelectClauses
CommonTables() []CommonTableExpression
CommonTablesAppend(cte CommonTableExpression) SelectClauses
Windows() []WindowExpression
SetWindows(ws []WindowExpression) SelectClauses
WindowsAppend(ws ...WindowExpression) SelectClauses
ClearWindows() SelectClauses
// contains filtered or unexported methods
}
func NewSelectClauses ¶
func NewSelectClauses() SelectClauses
type SortDirection ¶
type SortDirection int
type TruncateClauses ¶
type TruncateClauses interface {
HasTable() bool
Table() ColumnListExpression
SetTable(tables ColumnListExpression) TruncateClauses
Options() TruncateOptions
SetOptions(opts TruncateOptions) TruncateClauses
// contains filtered or unexported methods
}
func NewTruncateClauses ¶
func NewTruncateClauses() TruncateClauses
type TruncateOptions ¶
type TruncateOptions struct {
// Set to true to add CASCADE to the TRUNCATE statement
Cascade bool
// Set to true to add RESTRICT to the TRUNCATE statement
Restrict bool
// Set to true to specify IDENTITY options, (e.g. RESTART, CONTINUE) to the TRUNCATE statement
Identity string
}
Options to use when generating a TRUNCATE statement
type UpdateClauses ¶
type UpdateClauses interface {
HasTable() bool
CommonTables() []CommonTableExpression
CommonTablesAppend(cte CommonTableExpression) UpdateClauses
Table() Expression
SetTable(table Expression) UpdateClauses
SetValues() interface{}
HasSetValues() bool
SetSetValues(values interface{}) UpdateClauses
From() ColumnListExpression
HasFrom() bool
SetFrom(tables ColumnListExpression) UpdateClauses
Where() ExpressionList
ClearWhere() UpdateClauses
WhereAppend(expressions ...Expression) UpdateClauses
Order() ColumnListExpression
HasOrder() bool
ClearOrder() UpdateClauses
SetOrder(oes ...OrderedExpression) UpdateClauses
OrderAppend(...OrderedExpression) UpdateClauses
OrderPrepend(...OrderedExpression) UpdateClauses
Limit() interface{}
HasLimit() bool
ClearLimit() UpdateClauses
SetLimit(limit interface{}) UpdateClauses
Returning() ColumnListExpression
HasReturning() bool
SetReturning(cl ColumnListExpression) UpdateClauses
// contains filtered or unexported methods
}
func NewUpdateClauses ¶
func NewUpdateClauses() UpdateClauses
type UpdateExpression ¶
type UpdateExpression interface {
Col() IdentifierExpression
Val() interface{}
}
func NewUpdateExpressions ¶
func NewUpdateExpressions(update interface{}) (updates []UpdateExpression, err error)
type Updateable ¶
type Updateable interface {
// Used internally by update sql
Set(interface{}) UpdateExpression
}
Behaviors
type WaitOption ¶
type WaitOption int
type WindowExpression ¶
type WindowExpression interface {
Expression
Name() IdentifierExpression
HasName() bool
Parent() IdentifierExpression
HasParent() bool
PartitionCols() ColumnListExpression
HasPartitionBy() bool
OrderCols() ColumnListExpression
HasOrder() bool
Inherit(parent string) WindowExpression
PartitionBy(cols ...interface{}) WindowExpression
OrderBy(cols ...interface{}) WindowExpression
}
func NewWindowExpression ¶
func NewWindowExpression(window, parent IdentifierExpression, partitionCols, orderCols ColumnListExpression) WindowExpression
type Windowable ¶
type Windowable interface {
Over(WindowExpression) SQLWindowFunctionExpression
OverName(IdentifierExpression) SQLWindowFunctionExpression
}
Source Files
¶
- alias.go
- bitwise.go
- bool.go
- case.go
- cast.go
- col.go
- compound.go
- conflict.go
- cte.go
- delete_clauses.go
- exp.go
- exp_list.go
- exp_map.go
- func.go
- ident.go
- insert.go
- insert_clauses.go
- join.go
- lateral.go
- literal.go
- lock.go
- order.go
- range.go
- record.go
- select_clauses.go
- truncate.go
- truncate_clauses.go
- update.go
- update_clauses.go
- window.go
- window_func.go