Documentation
¶
Index ¶
- Constants
- Variables
- func AVG(numericExpression Expression) floatWindowExpression
- func BIT_AND(integerExpression IntegerExpression) integerWindowExpression
- func BIT_OR(integerExpression IntegerExpression) integerWindowExpression
- func BOOL_AND(boolExpression BoolExpression) boolWindowExpression
- func BOOL_OR(boolExpression BoolExpression) boolWindowExpression
- func COUNT(expression Expression) integerWindowExpression
- func CUME_DIST() floatWindowExpression
- func DENSE_RANK() integerWindowExpression
- func EVERY(boolExpression BoolExpression) boolWindowExpression
- func FIRST_VALUE(value Expression) windowExpression
- func FixedLiteral(value interface{}) *literalExpressionImpl
- func LAG(expr Expression, offsetAndDefault ...interface{}) windowExpression
- func LAST_VALUE(value Expression) windowExpression
- func LEAD(expr Expression, offsetAndDefault ...interface{}) windowExpression
- func Literal(value interface{}) *literalExpressionImpl
- func MAXf(floatExpression FloatExpression) floatWindowExpression
- func MAXi(integerExpression IntegerExpression) integerWindowExpression
- func MINf(floatExpression FloatExpression) floatWindowExpression
- func MINi(integerExpression IntegerExpression) integerWindowExpression
- func NTH_VALUE(value Expression, nth int64) windowExpression
- func NTILE(numOfBuckets int64) integerWindowExpression
- func NewDateFunc(name string, expressions ...Expression) *dateFunc
- func NewFloatWindowFunc(name string, expressions ...Expression) floatWindowExpression
- func NewFunc(name string, expressions []Expression, parent Expression) *funcExpressionImpl
- func NewRowLock(name string) func() RowLock
- func NewSelectTable(selectStmt SerializerHasProjections, alias string) selectTableImpl
- func NewTimeFunc(name string, expressions ...Expression) *timeFunc
- func NewTimestampFunc(name string, expressions ...Expression) *timestampFunc
- func OptionalOrDefaultString(defaultStr string, str ...string) string
- func PERCENT_RANK() floatWindowExpression
- func RANK() integerWindowExpression
- func ROW_NUMBER() integerWindowExpression
- func SUMf(floatExpression FloatExpression) floatWindowExpression
- func SUMi(integerExpression IntegerExpression) integerWindowExpression
- func Serialize(exp Serializer, statementType StatementType, out *SQLBuilder, ...)
- func SerializeClauseList(statement StatementType, clauses []Serializer, out *SQLBuilder)
- func SerializeColumnExpressionNames(columns []ColumnExpression, out *SQLBuilder)
- func SerializeColumnExpressions(columns []ColumnExpression, statementType StatementType, out *SQLBuilder, ...)
- func SerializeColumnNames(columns []Column, out *SQLBuilder)
- func SerializeForProjection(projection Projection, statementType StatementType, out *SQLBuilder)
- func SerializeProjectionList(statement StatementType, projections []Projection, out *SQLBuilder)
- func SetLoggerFunc(loggerFunc LoggerFunc)
- func SetQueryLogger(loggerFunc QueryLoggerFunc)
- func SetSubQuery(columnExpression ColumnExpression, subQuery SelectTable)
- func SetTableName(columnExpression ColumnExpression, tableName string)
- func UnwindRowsFromModels(columns []Column, data interface{}) [][]Serializer
- func WITH(dialect Dialect, recursive bool, cte ...*CommonTableExpression) func(statement Statement) Statement
- type BoolExpression
- func AND(expressions ...BoolExpression) BoolExpression
- func Bool(value bool) BoolExpression
- func BoolExp(expression Expression) BoolExpression
- func EXISTS(subQuery Expression) BoolExpression
- func Eq(lhs, rhs Expression) BoolExpression
- func Gt(lhs, rhs Expression) BoolExpression
- func GtEq(lhs, rhs Expression) BoolExpression
- func IsDistinctFrom(lhs, rhs Expression) BoolExpression
- func IsNotDistinctFrom(lhs, rhs Expression) BoolExpression
- func Lt(lhs Expression, rhs Expression) BoolExpression
- func LtEq(lhs, rhs Expression) BoolExpression
- func NOT(exp BoolExpression) BoolExpression
- func NewBetweenOperatorExpression(expression, min, max Expression, notBetween bool) BoolExpression
- func NotEq(lhs, rhs Expression) BoolExpression
- func OR(expressions ...BoolExpression) BoolExpression
- func REGEXP_LIKE(stringExp StringExpression, pattern StringExpression, matchType ...string) BoolExpression
- type CaseOperator
- type Cast
- type Clause
- type ClauseDelete
- type ClauseFor
- type ClauseFrom
- type ClauseGroupBy
- type ClauseHaving
- type ClauseIn
- type ClauseInsert
- type ClauseLimit
- type ClauseOffset
- type ClauseOptional
- type ClauseOrderBy
- type ClauseQuery
- type ClauseReturning
- type ClauseSelect
- type ClauseSetStmtOperator
- type ClauseStatementBegin
- type ClauseUpdate
- type ClauseValues
- type ClauseValuesQuery
- type ClauseWhere
- type ClauseWindow
- type ClauseWithProjections
- type Column
- type ColumnAssigment
- type ColumnBool
- type ColumnDate
- type ColumnExpression
- type ColumnExpressionImpl
- type ColumnFloat
- type ColumnInteger
- type ColumnList
- type ColumnSerializer
- type ColumnString
- type ColumnTime
- type ColumnTimestamp
- type ColumnTimestampz
- type ColumnTimez
- type CommonTableExpression
- type DateExpression
- func CURRENT_DATE() DateExpression
- func Date(year int, month time.Month, day int) DateExpression
- func DateExp(expression Expression) DateExpression
- func DateT(t time.Time) DateExpression
- func RawDate(raw string, namedArgs ...map[string]interface{}) DateExpression
- func TO_DATE(dateStr, format StringExpression) DateExpression
- type Dialect
- type DialectParams
- type Expression
- func Add(lhs, rhs Serializer) Expression
- func BoolExpressionListToExpressionList(expressions []BoolExpression) []Expression
- func COALESCE(value Expression, values ...Expression) Expression
- func DISTINCT(expr Expression) Expression
- func Div(lhs, rhs Serializer) Expression
- func Func(name string, expressions ...Expression) Expression
- func GREATEST(value Expression, values ...Expression) Expression
- func LEAST(value Expression, values ...Expression) Expression
- func MAX(expression Expression) Expression
- func MIN(expression Expression) Expression
- func Mod(lhs, rhs Serializer) Expression
- func Mul(lhs, rhs Serializer) Expression
- func NULLIF(value1, value2 Expression) Expression
- func NewBinaryOperatorExpression(lhs, rhs Serializer, operator string, additionalParam ...Expression) Expression
- func OptionalOrDefaultExpression(defaultExpression Expression, expression ...Expression) Expression
- func ROW(expressions ...Expression) Expression
- func Raw(raw string, namedArgs ...map[string]interface{}) Expression
- func RawWithParent(raw string, parent ...Expression) Expression
- func SUM(expression Expression) Expression
- func Sub(lhs, rhs Serializer) Expression
- func WRAP(expression ...Expression) Expression
- type ExpressionInterfaceImpl
- func (e *ExpressionInterfaceImpl) AS(alias string) Projection
- func (e *ExpressionInterfaceImpl) ASC() OrderByClause
- func (e *ExpressionInterfaceImpl) DESC() OrderByClause
- func (e *ExpressionInterfaceImpl) IN(expressions ...Expression) BoolExpression
- func (e *ExpressionInterfaceImpl) IS_NOT_NULL() BoolExpression
- func (e *ExpressionInterfaceImpl) IS_NULL() BoolExpression
- func (e *ExpressionInterfaceImpl) NOT_IN(expressions ...Expression) BoolExpression
- type ExpressionStatement
- type FloatExpression
- func ABSf(floatExpression FloatExpression) FloatExpression
- func CBRT(numericExpression NumericExpression) FloatExpression
- func CEIL(floatExpression FloatExpression) FloatExpression
- func Decimal(value string) FloatExpression
- func FLOOR(floatExpression FloatExpression) FloatExpression
- func Float(value float64) FloatExpression
- func FloatExp(expression Expression) FloatExpression
- func LN(floatExpression FloatExpression) FloatExpression
- func LOG(floatExpression FloatExpression) FloatExpression
- func NewFloatFunc(name string, expressions ...Expression) FloatExpression
- func POW(base, exponent NumericExpression) FloatExpression
- func POWER(base, exponent NumericExpression) FloatExpression
- func ROUND(floatExpression FloatExpression, precision ...IntegerExpression) FloatExpression
- func RawFloat(raw string, namedArgs ...map[string]interface{}) FloatExpression
- func SIGN(floatExpression FloatExpression) FloatExpression
- func SQRT(numericExpression NumericExpression) FloatExpression
- func TO_NUMBER(floatStr, format StringExpression) FloatExpression
- func TRUNC(floatExpression FloatExpression, precision ...IntegerExpression) FloatExpression
- type FrameExtent
- type GroupByClause
- type HasProjections
- type IntegerExpression
- func ABSi(integerExpression IntegerExpression) IntegerExpression
- func BIT_LENGTH(stringExpression StringExpression) IntegerExpression
- func BIT_NOT(expr IntegerExpression) IntegerExpression
- func CHAR_LENGTH(stringExpression StringExpression) IntegerExpression
- func Int(value int64) IntegerExpression
- func Int16(value int16) IntegerExpression
- func Int32(value int32) IntegerExpression
- func Int8(value int8) IntegerExpression
- func IntExp(expression Expression) IntegerExpression
- func OCTET_LENGTH(stringExpression StringExpression) IntegerExpression
- func RawInt(raw string, namedArgs ...map[string]interface{}) IntegerExpression
- func STRPOS(str, substring StringExpression) IntegerExpression
- func Uint16(value uint16) IntegerExpression
- func Uint32(value uint32) IntegerExpression
- func Uint64(value uint64) IntegerExpression
- func Uint8(value uint8) IntegerExpression
- type Interval
- type IntervalImpl
- type IsInterval
- type IsIntervalImpl
- type JoinTable
- type JoinType
- type Keyword
- type KeywordClause
- type ListSerializer
- type LiteralExpression
- type LoggerFunc
- type NumericExpression
- type OrderByClause
- type OrderSetAggregateFunc
- type PrintableStatement
- type Projection
- type ProjectionList
- type QueryInfo
- type QueryLoggerFunc
- type QueryPlaceholderFunc
- type RowLock
- type Rows
- type SQLBuilder
- func (s *SQLBuilder) DecreaseIdent(ident ...int)
- func (s *SQLBuilder) IncreaseIdent(ident ...int)
- func (s *SQLBuilder) NewLine()
- func (s *SQLBuilder) WriteAlias(str string)
- func (s *SQLBuilder) WriteByte(b byte)
- func (s *SQLBuilder) WriteIdentifier(name string, alwaysQuote ...bool)
- func (s *SQLBuilder) WriteProjections(statement StatementType, projections []Projection)
- func (s *SQLBuilder) WriteString(str string)
- type SelectTable
- type SerializeOption
- type SerializeOverride
- type Serializer
- func ExpressionListToSerializerList(expressions []Expression) []Serializer
- func NewSerializerClauseImpl(clauses ...Clause) Serializer
- func ToSerializerValue(value interface{}) Serializer
- func UnwindRowFromModel(columns []Column, data interface{}) []Serializer
- func UnwindRowFromValues(value interface{}, values []interface{}) []Serializer
- type SerializerFunc
- type SerializerHasProjections
- type SerializerStatement
- type SerializerTable
- type SetClause
- type SetClauseNew
- type SetPair
- type Statement
- type StatementType
- type StringExpression
- func BTRIM(stringExpression StringExpression, trimChars ...StringExpression) StringExpression
- func CHR(integerExpression IntegerExpression) StringExpression
- func CONCAT(expressions ...Expression) StringExpression
- func CONCAT_WS(separator Expression, expressions ...Expression) StringExpression
- func CONVERT(str StringExpression, srcEncoding StringExpression, ...) StringExpression
- func CONVERT_FROM(str StringExpression, srcEncoding StringExpression) StringExpression
- func CONVERT_TO(str StringExpression, toEncoding StringExpression) StringExpression
- func DECODE(data StringExpression, format StringExpression) StringExpression
- func ENCODE(data StringExpression, format StringExpression) StringExpression
- func FORMAT(formatStr StringExpression, formatArgs ...Expression) StringExpression
- func INITCAP(str StringExpression) StringExpression
- func LEFT(str StringExpression, n IntegerExpression) StringExpression
- func LENGTH(str StringExpression, encoding ...StringExpression) StringExpression
- func LOWER(stringExpression StringExpression) StringExpression
- func LPAD(str StringExpression, length IntegerExpression, text ...StringExpression) StringExpression
- func LTRIM(str StringExpression, trimChars ...StringExpression) StringExpression
- func MD5(stringExpression StringExpression) StringExpression
- func NewEnumValue(name string) StringExpression
- func NewStringFunc(name string, expressions ...Expression) StringExpression
- func REPEAT(str StringExpression, n IntegerExpression) StringExpression
- func REPLACE(text, from, to StringExpression) StringExpression
- func REVERSE(stringExpression StringExpression) StringExpression
- func RIGHT(str StringExpression, n IntegerExpression) StringExpression
- func RPAD(str StringExpression, length IntegerExpression, text ...StringExpression) StringExpression
- func RTRIM(str StringExpression, trimChars ...StringExpression) StringExpression
- func RawString(raw string, namedArgs ...map[string]interface{}) StringExpression
- func SUBSTR(str StringExpression, from IntegerExpression, count ...IntegerExpression) StringExpression
- func String(value string) StringExpression
- func StringExp(expression Expression) StringExpression
- func TO_ASCII(str StringExpression, encoding ...StringExpression) StringExpression
- func TO_CHAR(expression Expression, format StringExpression) StringExpression
- func TO_HEX(number IntegerExpression) StringExpression
- func UPPER(stringExpression StringExpression) StringExpression
- func UUID(value fmt.Stringer) StringExpression
- type Table
- type TimeExpression
- type TimestampExpression
- func LOCALTIMESTAMP(precision ...int) TimestampExpression
- func RawTimestamp(raw string, namedArgs ...map[string]interface{}) TimestampExpression
- func Timestamp(year int, month time.Month, day, hour, minute, second int, ...) TimestampExpression
- func TimestampExp(expression Expression) TimestampExpression
- func TimestampT(t time.Time) TimestampExpression
- type TimestampzExpression
- func CURRENT_TIMESTAMP(precision ...int) TimestampzExpression
- func NOW() TimestampzExpression
- func RawTimestampz(raw string, namedArgs ...map[string]interface{}) TimestampzExpression
- func TO_TIMESTAMP(timestampzStr, format StringExpression) TimestampzExpression
- func Timestampz(year int, month time.Month, day, hour, minute, second int, ...) TimestampzExpression
- func TimestampzExp(expression Expression) TimestampzExpression
- func TimestampzT(t time.Time) TimestampzExpression
- type TimezExpression
- func CURRENT_TIME(precision ...int) TimezExpression
- func RawTimez(raw string, namedArgs ...map[string]interface{}) TimezExpression
- func Timez(hour, minute, second int, nanoseconds time.Duration, timezone string) TimezExpression
- func TimezExp(expression Expression) TimezExpression
- func TimezT(t time.Time) TimezExpression
- type Window
- type WindowDefinition
Constants ¶
const ( StringConcatOperator = "||" StringRegexpLikeOperator = "REGEXP" StringNotRegexpLikeOperator = "NOT REGEXP" )
Operators
Variables ¶
var ( // NULL is jet equivalent of SQL NULL NULL = newNullLiteral() // STAR is jet equivalent of SQL * STAR = newStarLiteral() )
var ( UNBOUNDED = Keyword("UNBOUNDED") CURRENT_ROW = frameExtentKeyword{"CURRENT ROW"} )
Window function keywords
Functions ¶
func AVG ¶
func AVG(numericExpression Expression) floatWindowExpression
AVG is aggregate function used to calculate avg value from numeric expression
func BIT_AND ¶
func BIT_AND(integerExpression IntegerExpression) integerWindowExpression
BIT_AND is aggregate function used to calculates the bitwise AND of all non-null input values, or null if none.
func BIT_OR ¶
func BIT_OR(integerExpression IntegerExpression) integerWindowExpression
BIT_OR is aggregate function used to calculates the bitwise OR of all non-null input values, or null if none.
func BOOL_AND ¶
func BOOL_AND(boolExpression BoolExpression) boolWindowExpression
BOOL_AND is aggregate function. Returns true if all input values are true, otherwise false
func BOOL_OR ¶
func BOOL_OR(boolExpression BoolExpression) boolWindowExpression
BOOL_OR is aggregate function. Returns true if at least one input value is true, otherwise false
func COUNT ¶
func COUNT(expression Expression) integerWindowExpression
COUNT is aggregate function. Returns number of input rows for which the value of expression is not null.
func CUME_DIST ¶
func CUME_DIST() floatWindowExpression
CUME_DIST calculates cumulative distribution: (number of partition rows preceding or peer with current row) / total partition rows
func DENSE_RANK ¶
func DENSE_RANK() integerWindowExpression
DENSE_RANK returns rank of the current row without gaps; this function counts peer groups
func EVERY ¶
func EVERY(boolExpression BoolExpression) boolWindowExpression
EVERY is aggregate function. Returns true if all input values are true, otherwise false
func FIRST_VALUE ¶
func FIRST_VALUE(value Expression) windowExpression
FIRST_VALUE returns value evaluated at the row that is the first row of the window frame
func FixedLiteral ¶
func FixedLiteral(value interface{}) *literalExpressionImpl
FixedLiteral is injected directly to SQL query, and does not appear in parametrized argument list.
func LAG ¶
func LAG(expr Expression, offsetAndDefault ...interface{}) windowExpression
LAG returns value evaluated at the row that is offset rows before the current row within the partition; if there is no such row, instead return default (which must be of the same type as value). Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null
func LAST_VALUE ¶
func LAST_VALUE(value Expression) windowExpression
LAST_VALUE returns value evaluated at the row that is the last row of the window frame
func LEAD ¶
func LEAD(expr Expression, offsetAndDefault ...interface{}) windowExpression
LEAD returns value evaluated at the row that is offset rows after the current row within the partition; if there is no such row, instead return default (which must be of the same type as value). Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null
func Literal ¶
func Literal(value interface{}) *literalExpressionImpl
Literal is injected directly to SQL query, and does not appear in parametrized argument list.
func MAXf ¶
func MAXf(floatExpression FloatExpression) floatWindowExpression
MAXf is aggregate function. Returns maximum value of float expression across all input values
func MAXi ¶
func MAXi(integerExpression IntegerExpression) integerWindowExpression
MAXi is aggregate function. Returns maximum value of int expression across all input values
func MINf ¶
func MINf(floatExpression FloatExpression) floatWindowExpression
MINf is aggregate function. Returns minimum value of float expression across all input values
func MINi ¶
func MINi(integerExpression IntegerExpression) integerWindowExpression
MINi is aggregate function. Returns minimum value of int expression across all input values
func NTH_VALUE ¶
func NTH_VALUE(value Expression, nth int64) windowExpression
NTH_VALUE returns value evaluated at the row that is the nth row of the window frame (counting from 1); null if no such row
func NTILE ¶
func NTILE(numOfBuckets int64) integerWindowExpression
NTILE returns integer ranging from 1 to the argument value, dividing the partition as equally as possible
func NewDateFunc ¶ added in v2.6.0
func NewDateFunc(name string, expressions ...Expression) *dateFunc
NewDateFunc creates new date function with name and expression parameters
func NewFloatWindowFunc ¶
func NewFloatWindowFunc(name string, expressions ...Expression) floatWindowExpression
NewFloatWindowFunc creates new float function with name and expressions
func NewFunc ¶ added in v2.6.0
func NewFunc(name string, expressions []Expression, parent Expression) *funcExpressionImpl
NewFunc creates new function with name and expressions parameters
func NewSelectTable ¶
func NewSelectTable(selectStmt SerializerHasProjections, alias string) selectTableImpl
NewSelectTable func
func NewTimeFunc ¶ added in v2.6.0
func NewTimeFunc(name string, expressions ...Expression) *timeFunc
NewTimeFunc creates new time function with name and expression parameters
func NewTimestampFunc ¶
func NewTimestampFunc(name string, expressions ...Expression) *timestampFunc
NewTimestampFunc creates new timestamp function with name and expressions
func OptionalOrDefaultString ¶
OptionalOrDefaultString will return first value from variable argument list str or defaultStr if variable argument list is empty
func PERCENT_RANK ¶
func PERCENT_RANK() floatWindowExpression
PERCENT_RANK calculates relative rank of the current row: (rank - 1) / (total partition rows - 1)
func RANK ¶
func RANK() integerWindowExpression
RANK of the current row with gaps; same as row_number of its first peer
func ROW_NUMBER ¶
func ROW_NUMBER() integerWindowExpression
ROW_NUMBER returns number of the current row within its partition, counting from 1
func SUMf ¶
func SUMf(floatExpression FloatExpression) floatWindowExpression
SUMf is aggregate function. Returns sum of expression across all float expressions
func SUMi ¶
func SUMi(integerExpression IntegerExpression) integerWindowExpression
SUMi is aggregate function. Returns sum of expression across all integer expression.
func Serialize ¶
func Serialize(exp Serializer, statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize func
func SerializeClauseList ¶
func SerializeClauseList(statement StatementType, clauses []Serializer, out *SQLBuilder)
SerializeClauseList func
func SerializeColumnExpressionNames ¶
func SerializeColumnExpressionNames(columns []ColumnExpression, out *SQLBuilder)
SerializeColumnExpressionNames func
func SerializeColumnExpressions ¶ added in v2.7.0
func SerializeColumnExpressions(columns []ColumnExpression, statementType StatementType, out *SQLBuilder, options ...SerializeOption)
SerializeColumnExpressions func
func SerializeColumnNames ¶
func SerializeColumnNames(columns []Column, out *SQLBuilder)
SerializeColumnNames func
func SerializeForProjection ¶
func SerializeForProjection(projection Projection, statementType StatementType, out *SQLBuilder)
SerializeForProjection is helper function for serializing projection outside of jet package
func SerializeProjectionList ¶
func SerializeProjectionList(statement StatementType, projections []Projection, out *SQLBuilder)
SerializeProjectionList func
func SetLoggerFunc ¶
func SetLoggerFunc(loggerFunc LoggerFunc)
SetLoggerFunc sets automatic statement logging
func SetQueryLogger ¶ added in v2.7.0
func SetQueryLogger(loggerFunc QueryLoggerFunc)
SetQueryLogger sets automatic query logging function.
func SetSubQuery ¶
func SetSubQuery(columnExpression ColumnExpression, subQuery SelectTable)
SetSubQuery is utility function to set table name from outside of jet package to avoid making public setSubQuery
func SetTableName ¶
func SetTableName(columnExpression ColumnExpression, tableName string)
SetTableName is utility function to set table name from outside of jet package to avoid making public setTableName
func UnwindRowsFromModels ¶
func UnwindRowsFromModels(columns []Column, data interface{}) [][]Serializer
UnwindRowsFromModels func
Types ¶
type BoolExpression ¶
type BoolExpression interface {
Expression
// Check if this expression is equal to rhs
EQ(rhs BoolExpression) BoolExpression
// Check if this expression is not equal to rhs
NOT_EQ(rhs BoolExpression) BoolExpression
// Check if this expression is distinct to rhs
IS_DISTINCT_FROM(rhs BoolExpression) BoolExpression
// Check if this expression is not distinct to rhs
IS_NOT_DISTINCT_FROM(rhs BoolExpression) BoolExpression
// Check if this expression is true
IS_TRUE() BoolExpression
// Check if this expression is not true
IS_NOT_TRUE() BoolExpression
// Check if this expression is false
IS_FALSE() BoolExpression
// Check if this expression is not false
IS_NOT_FALSE() BoolExpression
// Check if this expression is unknown
IS_UNKNOWN() BoolExpression
// Check if this expression is not unknown
IS_NOT_UNKNOWN() BoolExpression
// expression AND operator rhs
AND(rhs BoolExpression) BoolExpression
// expression OR operator rhs
OR(rhs BoolExpression) BoolExpression
}
BoolExpression interface
func AND ¶ added in v2.7.1
func AND(expressions ...BoolExpression) BoolExpression
AND function adds AND operator between expressions. This function can be used, instead of method AND, to have a better inlining of a complex condition in the Go code and in the generated SQL.
func BoolExp ¶
func BoolExp(expression Expression) BoolExpression
BoolExp is bool expression wrapper around arbitrary expression. Allows go compiler to see any expression as bool expression. Does not add sql cast to generated sql builder output.
func EXISTS ¶
func EXISTS(subQuery Expression) BoolExpression
EXISTS checks for existence of the rows in subQuery
func IsDistinctFrom ¶
func IsDistinctFrom(lhs, rhs Expression) BoolExpression
IsDistinctFrom returns a representation of "a IS DISTINCT FROM b"
func IsNotDistinctFrom ¶
func IsNotDistinctFrom(lhs, rhs Expression) BoolExpression
IsNotDistinctFrom returns a representation of "a IS NOT DISTINCT FROM b"
func Lt ¶
func Lt(lhs Expression, rhs Expression) BoolExpression
Lt returns a representation of "a<b"
func NOT ¶
func NOT(exp BoolExpression) BoolExpression
NOT returns negation of bool expression result
func NewBetweenOperatorExpression ¶ added in v2.7.0
func NewBetweenOperatorExpression(expression, min, max Expression, notBetween bool) BoolExpression
NewBetweenOperatorExpression creates new BETWEEN operator expression
func NotEq ¶
func NotEq(lhs, rhs Expression) BoolExpression
NotEq returns a representation of "a!=b"
func OR ¶ added in v2.7.1
func OR(expressions ...BoolExpression) BoolExpression
OR function adds OR operator between expressions. This function can be used, instead of method OR, to have a better inlining of a complex condition in the Go code and in the generated SQL.
func REGEXP_LIKE ¶
func REGEXP_LIKE(stringExp StringExpression, pattern StringExpression, matchType ...string) BoolExpression
REGEXP_LIKE Returns 1 if the string expr matches the regular expression specified by the pattern pat, 0 otherwise.
type CaseOperator ¶
type CaseOperator interface {
Expression
WHEN(condition Expression) CaseOperator
THEN(then Expression) CaseOperator
ELSE(els Expression) CaseOperator
}
CaseOperator is interface for SQL case operator
func CASE ¶
func CASE(expression ...Expression) CaseOperator
CASE create CASE operator with optional list of expressions
type Cast ¶
type Cast interface {
AS(castType string) Expression
}
Cast interface
func NewCastImpl ¶
func NewCastImpl(expression Expression) Cast
NewCastImpl creates new generic cast
type Clause ¶
type Clause interface {
Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
}
Clause interface
type ClauseDelete ¶
type ClauseDelete struct {
Table SerializerTable
}
ClauseDelete struct
func (*ClauseDelete) Serialize ¶
func (d *ClauseDelete) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseFor ¶
type ClauseFor struct {
Lock RowLock
}
ClauseFor struct
func (*ClauseFor) Serialize ¶
func (f *ClauseFor) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseFrom ¶
type ClauseFrom struct {
Name string
Tables []Serializer
}
ClauseFrom struct
func (*ClauseFrom) Serialize ¶
func (f *ClauseFrom) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseGroupBy ¶
type ClauseGroupBy struct {
List []GroupByClause
}
ClauseGroupBy struct
func (*ClauseGroupBy) Serialize ¶
func (c *ClauseGroupBy) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseHaving ¶
type ClauseHaving struct {
Condition BoolExpression
}
ClauseHaving struct
func (*ClauseHaving) Serialize ¶
func (c *ClauseHaving) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseIn ¶
type ClauseIn struct {
LockMode string
}
ClauseIn struct
func (*ClauseIn) Serialize ¶
func (i *ClauseIn) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseInsert ¶
type ClauseInsert struct {
Table SerializerTable
Columns []Column
}
ClauseInsert struct
func (*ClauseInsert) GetColumns ¶
func (i *ClauseInsert) GetColumns() []Column
GetColumns gets list of columns for insert
func (*ClauseInsert) Serialize ¶
func (i *ClauseInsert) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseLimit ¶
type ClauseLimit struct {
Count int64
}
ClauseLimit struct
func (*ClauseLimit) Serialize ¶
func (l *ClauseLimit) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseOffset ¶
type ClauseOffset struct {
Count int64
}
ClauseOffset struct
func (*ClauseOffset) Serialize ¶
func (o *ClauseOffset) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseOptional ¶
ClauseOptional struct
func (*ClauseOptional) Serialize ¶
func (d *ClauseOptional) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseOrderBy ¶
type ClauseOrderBy struct {
List []OrderByClause
SkipNewLine bool
}
ClauseOrderBy struct
func (*ClauseOrderBy) Serialize ¶
func (o *ClauseOrderBy) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseQuery ¶
type ClauseQuery struct {
Query SerializerStatement
SkipSelectWrap bool
}
ClauseQuery struct
func (*ClauseQuery) Serialize ¶
func (v *ClauseQuery) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseReturning ¶ added in v2.6.0
type ClauseReturning struct {
ProjectionList []Projection
}
ClauseReturning type
func (ClauseReturning) Projections ¶ added in v2.6.0
func (r ClauseReturning) Projections() ProjectionList
Projections for ClauseReturning
func (*ClauseReturning) Serialize ¶ added in v2.6.0
func (r *ClauseReturning) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize for ClauseReturning
type ClauseSelect ¶
type ClauseSelect struct {
Distinct bool
DistinctOnColumns []ColumnExpression
ProjectionList []Projection
}
ClauseSelect struct
func (*ClauseSelect) Projections ¶
func (s *ClauseSelect) Projections() ProjectionList
Projections returns list of projections for select clause
func (*ClauseSelect) Serialize ¶
func (s *ClauseSelect) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseSetStmtOperator ¶
type ClauseSetStmtOperator struct {
Operator string
All bool
Selects []SerializerStatement
OrderBy ClauseOrderBy
Limit ClauseLimit
Offset ClauseOffset
SkipSelectWrap bool
}
ClauseSetStmtOperator struct
func (*ClauseSetStmtOperator) Projections ¶
func (s *ClauseSetStmtOperator) Projections() ProjectionList
Projections returns set of projections for ClauseSetStmtOperator
func (*ClauseSetStmtOperator) Serialize ¶
func (s *ClauseSetStmtOperator) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseStatementBegin ¶
type ClauseStatementBegin struct {
Name string
Tables []SerializerTable
}
ClauseStatementBegin struct
func (*ClauseStatementBegin) Serialize ¶
func (d *ClauseStatementBegin) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseUpdate ¶
type ClauseUpdate struct {
Table SerializerTable
}
ClauseUpdate struct
func (*ClauseUpdate) Serialize ¶
func (u *ClauseUpdate) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseValues ¶
type ClauseValues struct {
Rows [][]Serializer
}
ClauseValues struct
func (*ClauseValues) Serialize ¶
func (v *ClauseValues) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseValuesQuery ¶
type ClauseValuesQuery struct {
ClauseValues
ClauseQuery
}
ClauseValuesQuery struct
func (*ClauseValuesQuery) Serialize ¶
func (v *ClauseValuesQuery) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseWhere ¶
type ClauseWhere struct {
Condition BoolExpression
Mandatory bool
}
ClauseWhere struct
func (*ClauseWhere) Serialize ¶
func (c *ClauseWhere) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseWindow ¶
type ClauseWindow struct {
Definitions []WindowDefinition
}
ClauseWindow struct
func (*ClauseWindow) Serialize ¶
func (i *ClauseWindow) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type ClauseWithProjections ¶
type ClauseWithProjections interface {
Clause
Projections() ProjectionList
}
ClauseWithProjections interface
type Column ¶
type Column interface {
Name() string
TableName() string
// contains filtered or unexported methods
}
Column is common column interface for all types of columns.
func UnwindColumns ¶
UnwindColumns func
type ColumnAssigment ¶
type ColumnAssigment interface {
Serializer
// contains filtered or unexported methods
}
ColumnAssigment is interface wrapper around column assigment
type ColumnBool ¶
type ColumnBool interface {
BoolExpression
Column
From(subQuery SelectTable) ColumnBool
SET(boolExp BoolExpression) ColumnAssigment
}
ColumnBool is interface for SQL boolean columns.
type ColumnDate ¶
type ColumnDate interface {
DateExpression
Column
From(subQuery SelectTable) ColumnDate
SET(dateExp DateExpression) ColumnAssigment
}
ColumnDate is interface of SQL date columns.
type ColumnExpression ¶
type ColumnExpression interface {
Column
Expression
}
ColumnExpression interface
type ColumnExpressionImpl ¶
type ColumnExpressionImpl struct {
ExpressionInterfaceImpl
// contains filtered or unexported fields
}
ColumnExpressionImpl is base type for sql columns.
func NewColumnImpl ¶
func NewColumnImpl(name string, tableName string, parent ColumnExpression) ColumnExpressionImpl
NewColumnImpl creates new ColumnExpressionImpl
func (*ColumnExpressionImpl) Name ¶
func (c *ColumnExpressionImpl) Name() string
Name returns name of the column
func (*ColumnExpressionImpl) TableName ¶
func (c *ColumnExpressionImpl) TableName() string
TableName returns column table name
type ColumnFloat ¶
type ColumnFloat interface {
FloatExpression
Column
From(subQuery SelectTable) ColumnFloat
SET(floatExp FloatExpression) ColumnAssigment
}
ColumnFloat is interface for SQL real, numeric, decimal or double precision column.
func FloatColumn ¶
func FloatColumn(name string) ColumnFloat
FloatColumn creates named float column.
type ColumnInteger ¶
type ColumnInteger interface {
IntegerExpression
Column
From(subQuery SelectTable) ColumnInteger
SET(intExp IntegerExpression) ColumnAssigment
}
ColumnInteger is interface for SQL smallint, integer, bigint columns.
func IntegerColumn ¶
func IntegerColumn(name string) ColumnInteger
IntegerColumn creates named integer column.
type ColumnList ¶
type ColumnList []ColumnExpression
ColumnList is a helper type to support list of columns as single projection
func (ColumnList) Except ¶ added in v2.6.0
func (cl ColumnList) Except(excludedColumns ...Column) ColumnList
Except will create new column list in which columns contained in excluded column names are removed
func (ColumnList) Name ¶
func (cl ColumnList) Name() string
Name is placeholder for ColumnList to implement Column interface
func (ColumnList) SET ¶
func (cl ColumnList) SET(expression Expression) ColumnAssigment
SET creates column assigment for each column in column list. expression should be created by ROW function
func (ColumnList) TableName ¶
func (cl ColumnList) TableName() string
TableName is placeholder for ColumnList to implement Column interface
type ColumnSerializer ¶
type ColumnSerializer interface {
Serializer
Column
}
ColumnSerializer is interface for all serializable columns
type ColumnString ¶
type ColumnString interface {
StringExpression
Column
From(subQuery SelectTable) ColumnString
SET(stringExp StringExpression) ColumnAssigment
}
ColumnString is interface for SQL text, character, character varying bytea, uuid columns and enums types.
func StringColumn ¶
func StringColumn(name string) ColumnString
StringColumn creates named string column.
type ColumnTime ¶
type ColumnTime interface {
TimeExpression
Column
From(subQuery SelectTable) ColumnTime
SET(timeExp TimeExpression) ColumnAssigment
}
ColumnTime is interface for SQL time column.
type ColumnTimestamp ¶
type ColumnTimestamp interface {
TimestampExpression
Column
From(subQuery SelectTable) ColumnTimestamp
SET(timestampExp TimestampExpression) ColumnAssigment
}
ColumnTimestamp is interface of SQL timestamp columns.
func TimestampColumn ¶
func TimestampColumn(name string) ColumnTimestamp
TimestampColumn creates named timestamp column
type ColumnTimestampz ¶
type ColumnTimestampz interface {
TimestampzExpression
Column
From(subQuery SelectTable) ColumnTimestampz
SET(timestampzExp TimestampzExpression) ColumnAssigment
}
ColumnTimestampz is interface of SQL timestamp with timezone columns.
func TimestampzColumn ¶
func TimestampzColumn(name string) ColumnTimestampz
TimestampzColumn creates named timestamp with time zone column.
type ColumnTimez ¶
type ColumnTimez interface {
TimezExpression
Column
From(subQuery SelectTable) ColumnTimez
}
ColumnTimez is interface of SQL time with time zone columns.
func TimezColumn ¶
func TimezColumn(name string) ColumnTimez
TimezColumn creates named time with time zone column.
type CommonTableExpression ¶
type CommonTableExpression struct {
NotMaterialized bool
Columns []ColumnExpression
// contains filtered or unexported fields
}
CommonTableExpression contains information about a CTE.
func CTE ¶
func CTE(name string, columns ...ColumnExpression) CommonTableExpression
CTE creates new named CommonTableExpression
func (CommonTableExpression) AllColumns ¶
func (c CommonTableExpression) AllColumns() ProjectionList
AllColumns returns list of all projections in the CTE
type DateExpression ¶
type DateExpression interface {
Expression
EQ(rhs DateExpression) BoolExpression
NOT_EQ(rhs DateExpression) BoolExpression
IS_DISTINCT_FROM(rhs DateExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs DateExpression) BoolExpression
LT(rhs DateExpression) BoolExpression
LT_EQ(rhs DateExpression) BoolExpression
GT(rhs DateExpression) BoolExpression
GT_EQ(rhs DateExpression) BoolExpression
BETWEEN(min, max DateExpression) BoolExpression
NOT_BETWEEN(min, max DateExpression) BoolExpression
ADD(rhs Interval) TimestampExpression
SUB(rhs Interval) TimestampExpression
}
DateExpression is interface for date types
func Date ¶
func Date(year int, month time.Month, day int) DateExpression
Date creates new date literal expression
func DateExp ¶
func DateExp(expression Expression) DateExpression
DateExp is date expression wrapper around arbitrary expression. Allows go compiler to see any expression as date expression. Does not add sql cast to generated sql builder output.
func DateT ¶
func DateT(t time.Time) DateExpression
DateT creates new date literal expression from time.Time object
func RawDate ¶ added in v2.5.0
func RawDate(raw string, namedArgs ...map[string]interface{}) DateExpression
RawDate helper that for date expressions
func TO_DATE ¶
func TO_DATE(dateStr, format StringExpression) DateExpression
TO_DATE converts string to date using format
type Dialect ¶
type Dialect interface {
Name() string
PackageName() string
OperatorSerializeOverride(operator string) SerializeOverride
FunctionSerializeOverride(function string) SerializeOverride
AliasQuoteChar() byte
IdentifierQuoteChar() byte
ArgumentPlaceholder() QueryPlaceholderFunc
IsReservedWord(name string) bool
}
Dialect interface
func NewDialect ¶
func NewDialect(params DialectParams) Dialect
NewDialect creates new dialect with params
type DialectParams ¶
type DialectParams struct {
Name string
PackageName string
OperatorSerializeOverrides map[string]SerializeOverride
FunctionSerializeOverrides map[string]SerializeOverride
AliasQuoteChar byte
IdentifierQuoteChar byte
ArgumentPlaceholder QueryPlaceholderFunc
ReservedWords []string
}
DialectParams struct
type Expression ¶
type Expression interface {
Serializer
Projection
GroupByClause
OrderByClause
// IS_NULL tests expression whether it is a NULL value.
IS_NULL() BoolExpression
// IS_NOT_NULL tests expression whether it is a non-NULL value.
IS_NOT_NULL() BoolExpression
// IN checks if this expressions matches any in expressions list
IN(expressions ...Expression) BoolExpression
// NOT_IN checks if this expressions is different of all expressions in expressions list
NOT_IN(expressions ...Expression) BoolExpression
// AS the temporary alias name to assign to the expression
AS(alias string) Projection
// ASC expression will be used to sort query result in ascending order
ASC() OrderByClause
// DESC expression will be used to sort query result in descending order
DESC() OrderByClause
}
Expression is common interface for all expressions. Can be Bool, Int, Float, String, Date, Time, Timez, Timestamp or Timestampz expressions.
func BoolExpressionListToExpressionList ¶ added in v2.7.1
func BoolExpressionListToExpressionList(expressions []BoolExpression) []Expression
BoolExpressionListToExpressionList converts list of bool expressions to list of expressions
func COALESCE ¶
func COALESCE(value Expression, values ...Expression) Expression
COALESCE function returns the first of its arguments that is not null.
func DISTINCT ¶ added in v2.7.0
func DISTINCT(expr Expression) Expression
DISTINCT operator can be used to return distinct values of expr
func Func ¶ added in v2.5.0
func Func(name string, expressions ...Expression) Expression
Func can be used to call custom or unsupported database functions.
func GREATEST ¶
func GREATEST(value Expression, values ...Expression) Expression
GREATEST selects the largest value from a list of expressions
func LEAST ¶
func LEAST(value Expression, values ...Expression) Expression
LEAST selects the smallest value from a list of expressions
func MAX ¶
func MAX(expression Expression) Expression
MAX is aggregate function. Returns minimum value of expression across all input values.
func MIN ¶
func MIN(expression Expression) Expression
MIN is aggregate function. Returns minimum value of expression across all input values.
func NULLIF ¶
func NULLIF(value1, value2 Expression) Expression
NULLIF function returns a null value if value1 equals value2; otherwise it returns value1.
func NewBinaryOperatorExpression ¶
func NewBinaryOperatorExpression(lhs, rhs Serializer, operator string, additionalParam ...Expression) Expression
NewBinaryOperatorExpression creates new binaryOperatorExpression
func OptionalOrDefaultExpression ¶
func OptionalOrDefaultExpression(defaultExpression Expression, expression ...Expression) Expression
OptionalOrDefaultExpression will return first value from variable argument list expression or defaultExpression if variable argument list is empty
func ROW ¶
func ROW(expressions ...Expression) Expression
ROW is construct one table row from list of expressions.
func Raw ¶
func Raw(raw string, namedArgs ...map[string]interface{}) Expression
Raw can be used for any unsupported functions, operators or expressions. For example: Raw("current_database()")
func RawWithParent ¶ added in v2.5.0
func RawWithParent(raw string, parent ...Expression) Expression
RawWithParent is a Raw constructor used for construction dialect specific expression
func SUM ¶
func SUM(expression Expression) Expression
SUM is aggregate function. Returns sum of all expressions
func WRAP ¶
func WRAP(expression ...Expression) Expression
WRAP wraps list of expressions with brackets '(' and ')'
type ExpressionInterfaceImpl ¶
type ExpressionInterfaceImpl struct {
Parent Expression
}
ExpressionInterfaceImpl implements Expression interface methods
func (*ExpressionInterfaceImpl) AS ¶
func (e *ExpressionInterfaceImpl) AS(alias string) Projection
AS the temporary alias name to assign to the expression
func (*ExpressionInterfaceImpl) ASC ¶
func (e *ExpressionInterfaceImpl) ASC() OrderByClause
ASC expression will be used to sort query result in ascending order
func (*ExpressionInterfaceImpl) DESC ¶
func (e *ExpressionInterfaceImpl) DESC() OrderByClause
DESC expression will be used to sort query result in descending order
func (*ExpressionInterfaceImpl) IN ¶
func (e *ExpressionInterfaceImpl) IN(expressions ...Expression) BoolExpression
IN checks if this expressions matches any in expressions list
func (*ExpressionInterfaceImpl) IS_NOT_NULL ¶
func (e *ExpressionInterfaceImpl) IS_NOT_NULL() BoolExpression
IS_NOT_NULL tests expression whether it is a non-NULL value.
func (*ExpressionInterfaceImpl) IS_NULL ¶
func (e *ExpressionInterfaceImpl) IS_NULL() BoolExpression
IS_NULL tests expression whether it is a NULL value.
func (*ExpressionInterfaceImpl) NOT_IN ¶
func (e *ExpressionInterfaceImpl) NOT_IN(expressions ...Expression) BoolExpression
NOT_IN checks if this expressions is different of all expressions in expressions list
type ExpressionStatement ¶
type ExpressionStatement interface {
Expression
Statement
HasProjections
}
ExpressionStatement interfacess
func NewExpressionStatementImpl ¶
func NewExpressionStatementImpl(Dialect Dialect, statementType StatementType, parent ExpressionStatement, clauses ...Clause) ExpressionStatement
NewExpressionStatementImpl creates new expression statement
type FloatExpression ¶
type FloatExpression interface {
Expression
EQ(rhs FloatExpression) BoolExpression
NOT_EQ(rhs FloatExpression) BoolExpression
IS_DISTINCT_FROM(rhs FloatExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs FloatExpression) BoolExpression
LT(rhs FloatExpression) BoolExpression
LT_EQ(rhs FloatExpression) BoolExpression
GT(rhs FloatExpression) BoolExpression
GT_EQ(rhs FloatExpression) BoolExpression
BETWEEN(min, max FloatExpression) BoolExpression
NOT_BETWEEN(min, max FloatExpression) BoolExpression
ADD(rhs NumericExpression) FloatExpression
SUB(rhs NumericExpression) FloatExpression
MUL(rhs NumericExpression) FloatExpression
DIV(rhs NumericExpression) FloatExpression
MOD(rhs NumericExpression) FloatExpression
POW(rhs NumericExpression) FloatExpression
// contains filtered or unexported methods
}
FloatExpression is interface for SQL float columns
func ABSf ¶
func ABSf(floatExpression FloatExpression) FloatExpression
ABSf calculates absolute value from float expression
func CBRT ¶
func CBRT(numericExpression NumericExpression) FloatExpression
CBRT calculates cube root of numeric expression
func CEIL ¶
func CEIL(floatExpression FloatExpression) FloatExpression
CEIL calculates ceil of float expression
func Decimal ¶ added in v2.5.0
func Decimal(value string) FloatExpression
Decimal creates new float literal from string value
func FLOOR ¶
func FLOOR(floatExpression FloatExpression) FloatExpression
FLOOR calculates floor of float expression
func Float ¶
func Float(value float64) FloatExpression
Float creates new float literal from float64 value
func FloatExp ¶
func FloatExp(expression Expression) FloatExpression
FloatExp is date expression wrapper around arbitrary expression. Allows go compiler to see any expression as float expression. Does not add sql cast to generated sql builder output.
func LN ¶
func LN(floatExpression FloatExpression) FloatExpression
LN calculates natural algorithm of float expression
func LOG ¶
func LOG(floatExpression FloatExpression) FloatExpression
LOG calculates logarithm of float expression
func NewFloatFunc ¶
func NewFloatFunc(name string, expressions ...Expression) FloatExpression
NewFloatFunc creates new float function with name and expressions
func POW ¶
func POW(base, exponent NumericExpression) FloatExpression
POW calculates power of base with exponent
func POWER ¶
func POWER(base, exponent NumericExpression) FloatExpression
POWER calculates power of base with exponent
func ROUND ¶
func ROUND(floatExpression FloatExpression, precision ...IntegerExpression) FloatExpression
ROUND calculates round of a float expressions with optional precision
func RawFloat ¶ added in v2.5.0
func RawFloat(raw string, namedArgs ...map[string]interface{}) FloatExpression
RawFloat helper that for float expressions
func SIGN ¶
func SIGN(floatExpression FloatExpression) FloatExpression
SIGN returns sign of float expression
func SQRT ¶
func SQRT(numericExpression NumericExpression) FloatExpression
SQRT calculates square root of numeric expression
func TO_NUMBER ¶
func TO_NUMBER(floatStr, format StringExpression) FloatExpression
TO_NUMBER converts string to numeric using format
func TRUNC ¶
func TRUNC(floatExpression FloatExpression, precision ...IntegerExpression) FloatExpression
TRUNC calculates trunc of float expression with optional precision
type FrameExtent ¶
type FrameExtent interface {
Serializer
// contains filtered or unexported methods
}
FrameExtent interface
type GroupByClause ¶
type GroupByClause interface {
// contains filtered or unexported methods
}
GroupByClause interface
type HasProjections ¶
type HasProjections interface {
// contains filtered or unexported methods
}
HasProjections interface
type IntegerExpression ¶
type IntegerExpression interface {
Expression
EQ(rhs IntegerExpression) BoolExpression
NOT_EQ(rhs IntegerExpression) BoolExpression
IS_DISTINCT_FROM(rhs IntegerExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs IntegerExpression) BoolExpression
LT(rhs IntegerExpression) BoolExpression
LT_EQ(rhs IntegerExpression) BoolExpression
GT(rhs IntegerExpression) BoolExpression
GT_EQ(rhs IntegerExpression) BoolExpression
BETWEEN(min, max IntegerExpression) BoolExpression
NOT_BETWEEN(min, max IntegerExpression) BoolExpression
ADD(rhs IntegerExpression) IntegerExpression
SUB(rhs IntegerExpression) IntegerExpression
MUL(rhs IntegerExpression) IntegerExpression
DIV(rhs IntegerExpression) IntegerExpression
MOD(rhs IntegerExpression) IntegerExpression
POW(rhs IntegerExpression) IntegerExpression
BIT_AND(rhs IntegerExpression) IntegerExpression
BIT_OR(rhs IntegerExpression) IntegerExpression
BIT_XOR(rhs IntegerExpression) IntegerExpression
BIT_SHIFT_LEFT(shift IntegerExpression) IntegerExpression
BIT_SHIFT_RIGHT(shift IntegerExpression) IntegerExpression
// contains filtered or unexported methods
}
IntegerExpression interface
func ABSi ¶
func ABSi(integerExpression IntegerExpression) IntegerExpression
ABSi calculates absolute value from int expression
func BIT_LENGTH ¶
func BIT_LENGTH(stringExpression StringExpression) IntegerExpression
BIT_LENGTH returns number of bits in string expression
func BIT_NOT ¶
func BIT_NOT(expr IntegerExpression) IntegerExpression
BIT_NOT inverts every bit in integer expression result
func CHAR_LENGTH ¶
func CHAR_LENGTH(stringExpression StringExpression) IntegerExpression
CHAR_LENGTH returns number of characters in string expression
func Int16 ¶ added in v2.5.0
func Int16(value int16) IntegerExpression
Int16 creates a new 16 bit signed integer literal
func Int32 ¶ added in v2.5.0
func Int32(value int32) IntegerExpression
Int32 creates a new 32 bit signed integer literal
func Int8 ¶ added in v2.5.0
func Int8(value int8) IntegerExpression
Int8 creates a new 8 bit signed integer literal
func IntExp ¶
func IntExp(expression Expression) IntegerExpression
IntExp is int expression wrapper around arbitrary expression. Allows go compiler to see any expression as int expression. Does not add sql cast to generated sql builder output.
func OCTET_LENGTH ¶
func OCTET_LENGTH(stringExpression StringExpression) IntegerExpression
OCTET_LENGTH returns number of bytes in string expression
func RawInt ¶ added in v2.5.0
func RawInt(raw string, namedArgs ...map[string]interface{}) IntegerExpression
RawInt helper that for integer expressions
func STRPOS ¶
func STRPOS(str, substring StringExpression) IntegerExpression
STRPOS returns location of specified substring (same as position(substring in string), but note the reversed argument order)
func Uint16 ¶ added in v2.5.0
func Uint16(value uint16) IntegerExpression
Uint16 creates a new 16 bit unsigned integer literal
func Uint32 ¶ added in v2.5.0
func Uint32(value uint32) IntegerExpression
Uint32 creates a new 32 bit unsigned integer literal
func Uint64 ¶ added in v2.5.0
func Uint64(value uint64) IntegerExpression
Uint64 creates a new 64 bit unsigned integer literal
func Uint8 ¶ added in v2.5.0
func Uint8(value uint8) IntegerExpression
Uint8 creates a new 8 bit unsigned integer literal
type Interval ¶
type Interval interface {
Serializer
IsInterval
}
Interval is internal common representation of sql interval
type IntervalImpl ¶
type IntervalImpl struct {
Value Serializer
IsIntervalImpl
}
IntervalImpl is implementation of Interval type
func NewInterval ¶
func NewInterval(s Serializer) *IntervalImpl
NewInterval creates new interval from serializer
type IsInterval ¶
type IsInterval interface {
// contains filtered or unexported methods
}
IsInterval interface
type IsIntervalImpl ¶
type IsIntervalImpl struct{}
IsIntervalImpl is implementation of IsInterval interface
type JoinTable ¶
type JoinTable SerializerTable
JoinTable interface
func NewJoinTable ¶
func NewJoinTable(lhs Serializer, rhs Serializer, joinType JoinType, onCondition BoolExpression) JoinTable
NewJoinTable creates new join table
type Keyword ¶
type Keyword string
Keyword type
const ( // DEFAULT is jet equivalent of SQL DEFAULT DEFAULT Keyword = "DEFAULT" )
type KeywordClause ¶
type KeywordClause struct {
Keyword
}
KeywordClause type
func (KeywordClause) Serialize ¶
func (k KeywordClause) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize for KeywordClause
type ListSerializer ¶
type ListSerializer struct {
Serializers []Serializer
Separator string
}
ListSerializer serializes list of serializers with separator
type LiteralExpression ¶
type LiteralExpression interface {
Expression
Value() interface{}
SetConstant(constant bool)
}
LiteralExpression is representation of an escaped literal
type LoggerFunc ¶
type LoggerFunc func(ctx context.Context, statement PrintableStatement)
LoggerFunc is a function user can implement to support automatic statement logging.
type NumericExpression ¶
type NumericExpression interface {
Expression
// contains filtered or unexported methods
}
NumericExpression is common interface for all integer and float expressions
type OrderByClause ¶
type OrderByClause interface {
// contains filtered or unexported methods
}
OrderByClause interface
type OrderSetAggregateFunc ¶ added in v2.7.0
type OrderSetAggregateFunc struct {
// contains filtered or unexported fields
}
OrderSetAggregateFunc implementation of order set aggregate function
func MODE ¶ added in v2.7.0
func MODE() *OrderSetAggregateFunc
MODE computes the most frequent value of the aggregated argument
func PERCENTILE_CONT ¶ added in v2.7.0
func PERCENTILE_CONT(fraction FloatExpression) *OrderSetAggregateFunc
PERCENTILE_CONT computes a value corresponding to the specified fraction within the ordered set of aggregated argument values. This will interpolate between adjacent input items if needed.
func PERCENTILE_DISC ¶ added in v2.7.0
func PERCENTILE_DISC(fraction FloatExpression) *OrderSetAggregateFunc
PERCENTILE_DISC computes the first value within the ordered set of aggregated argument values whose position in the ordering equals or exceeds the specified fraction. The aggregated argument must be of a sortable type.
func (*OrderSetAggregateFunc) WITHIN_GROUP_ORDER_BY ¶ added in v2.7.0
func (p *OrderSetAggregateFunc) WITHIN_GROUP_ORDER_BY(orderBy OrderByClause) Expression
WITHIN_GROUP_ORDER_BY specifies ordered set of aggregated argument values
type PrintableStatement ¶
type PrintableStatement interface {
Sql() (query string, args []interface{})
DebugSql() (query string)
}
PrintableStatement is a statement which sql query can be logged
type Projection ¶
type Projection interface {
// contains filtered or unexported methods
}
Projection is interface for all projection types. Types that can be part of, for instance SELECT clause.
func ColumnListToProjectionList ¶
func ColumnListToProjectionList(columns []ColumnExpression) []Projection
ColumnListToProjectionList func
type ProjectionList ¶
type ProjectionList []Projection
ProjectionList is a redefined type, so that ProjectionList can be used as a Projection.
func (ProjectionList) As ¶ added in v2.7.0
func (pl ProjectionList) As(tableAlias string) ProjectionList
As will create new projection list where each column is wrapped with a new table alias. tableAlias should be in the form 'name' or 'name.*'. For instance: If projection list has a column 'Artist.Name', and tableAlias is 'Musician.*', returned projection list will have a column wrapped in alias 'Musician.Name'.
func (ProjectionList) Except ¶ added in v2.7.0
func (pl ProjectionList) Except(toExclude ...Column) ProjectionList
Except will create new projection list in which columns contained in excluded column names are removed
type QueryInfo ¶ added in v2.7.0
type QueryInfo struct {
Statement PrintableStatement
// Depending on how the statement is executed, RowsProcessed is:
// - Number of rows returned for Query() and QueryContext() methods
// - RowsAffected() for Exec() and ExecContext() methods
// - Always 0 for Rows() method.
RowsProcessed int64
Duration time.Duration
Err error
}
QueryInfo contains information about executed query
type QueryLoggerFunc ¶ added in v2.7.0
QueryLoggerFunc is a function user can implement to retrieve more information about statement executed.
type QueryPlaceholderFunc ¶
QueryPlaceholderFunc func
type RowLock ¶
type RowLock interface {
Serializer
NOWAIT() RowLock
SKIP_LOCKED() RowLock
}
RowLock is interface for SELECT statement row lock types
type SQLBuilder ¶
type SQLBuilder struct {
Dialect Dialect
Buff bytes.Buffer
Args []interface{}
Debug bool
// contains filtered or unexported fields
}
SQLBuilder generates output SQL
func (*SQLBuilder) DecreaseIdent ¶
func (s *SQLBuilder) DecreaseIdent(ident ...int)
DecreaseIdent removes ident or defaultIdent number of spaces for each new line
func (*SQLBuilder) IncreaseIdent ¶
func (s *SQLBuilder) IncreaseIdent(ident ...int)
IncreaseIdent adds ident or defaultIdent number of spaces to each new line
func (*SQLBuilder) WriteAlias ¶
func (s *SQLBuilder) WriteAlias(str string)
WriteAlias is used to add alias to output SQL
func (*SQLBuilder) WriteByte ¶
func (s *SQLBuilder) WriteByte(b byte)
WriteByte writes byte to output SQL
func (*SQLBuilder) WriteIdentifier ¶
func (s *SQLBuilder) WriteIdentifier(name string, alwaysQuote ...bool)
WriteIdentifier adds identifier to output SQL
func (*SQLBuilder) WriteProjections ¶
func (s *SQLBuilder) WriteProjections(statement StatementType, projections []Projection)
WriteProjections func
func (*SQLBuilder) WriteString ¶
func (s *SQLBuilder) WriteString(str string)
WriteString writes sting to output SQL
type SelectTable ¶
type SelectTable interface {
SerializerHasProjections
Alias() string
AllColumns() ProjectionList
}
SelectTable is interface for SELECT sub-queries
func NewLateral ¶ added in v2.5.0
func NewLateral(selectStmt SerializerStatement, alias string) SelectTable
NewLateral creates new lateral expression from select statement with alias
type SerializeOption ¶
type SerializeOption int
SerializeOption type
const ( NoWrap SerializeOption = iota SkipNewLine Ident ShortName )
Serialize options
func FallTrough ¶
func FallTrough(options []SerializeOption) []SerializeOption
FallTrough filters fall-trough options from the list
func (SerializeOption) WithFallTrough ¶
func (s SerializeOption) WithFallTrough(options []SerializeOption) []SerializeOption
WithFallTrough extends existing serialize options with additional
type SerializeOverride ¶
type SerializeOverride func(expressions ...Serializer) SerializerFunc
SerializeOverride func
type Serializer ¶
type Serializer interface {
// contains filtered or unexported methods
}
Serializer interface
func ExpressionListToSerializerList ¶
func ExpressionListToSerializerList(expressions []Expression) []Serializer
ExpressionListToSerializerList converts list of expressions to list of serializers
func NewSerializerClauseImpl ¶
func NewSerializerClauseImpl(clauses ...Clause) Serializer
NewSerializerClauseImpl is constructor for Seralizer with list of clauses
func ToSerializerValue ¶
func ToSerializerValue(value interface{}) Serializer
ToSerializerValue creates Serializer type from the value
func UnwindRowFromModel ¶
func UnwindRowFromModel(columns []Column, data interface{}) []Serializer
UnwindRowFromModel func
func UnwindRowFromValues ¶
func UnwindRowFromValues(value interface{}, values []interface{}) []Serializer
UnwindRowFromValues func
type SerializerFunc ¶
type SerializerFunc func(statement StatementType, out *SQLBuilder, options ...SerializeOption)
SerializerFunc func
type SerializerHasProjections ¶ added in v2.7.0
type SerializerHasProjections interface {
Serializer
HasProjections
}
SerializerHasProjections interface is combination of Serializer and HasProjections interface
type SerializerStatement ¶
type SerializerStatement interface {
Serializer
Statement
HasProjections
}
SerializerStatement interface
func NewStatementImpl ¶
func NewStatementImpl(Dialect Dialect, statementType StatementType, parent SerializerStatement, clauses ...Clause) SerializerStatement
NewStatementImpl creates new statementImpl
type SerializerTable ¶
type SerializerTable interface {
Serializer
Table
}
SerializerTable interface
func NewTable ¶
func NewTable(schemaName, name, alias string, columns ...ColumnExpression) SerializerTable
NewTable creates new table with schema Name, table Name and list of columns
type SetClause ¶
type SetClause struct {
Columns []Column
Values []Serializer
}
SetClause struct
func (*SetClause) Serialize ¶
func (s *SetClause) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize serializes clause into SQLBuilder
type SetClauseNew ¶
type SetClauseNew []ColumnAssigment
SetClauseNew clause
func (SetClauseNew) Serialize ¶
func (s SetClauseNew) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)
Serialize for SetClauseNew
type Statement ¶
type Statement interface {
// Sql returns parametrized sql query with list of arguments.
Sql() (query string, args []interface{})
// DebugSql returns debug query where every parametrized placeholder is replaced with its argument.
// Do not use it in production. Use it only for debug purposes.
DebugSql() (query string)
// Query executes statement over database connection/transaction db and stores row result in destination.
// Destination can be either pointer to struct or pointer to a slice.
// If destination is pointer to struct and query result set is empty, method returns qrm.ErrNoRows.
Query(db qrm.DB, destination interface{}) error
// QueryContext executes statement with a context over database connection/transaction db and stores row result in destination.
// Destination can be either pointer to struct or pointer to a slice.
// If destination is pointer to struct and query result set is empty, method returns qrm.ErrNoRows.
QueryContext(ctx context.Context, db qrm.DB, destination interface{}) error
// Exec executes statement over db connection/transaction without returning any rows.
Exec(db qrm.DB) (sql.Result, error)
// ExecContext executes statement with context over db connection/transaction without returning any rows.
ExecContext(ctx context.Context, db qrm.DB) (sql.Result, error)
// Rows executes statements over db connection/transaction and returns rows
Rows(ctx context.Context, db qrm.DB) (*Rows, error)
}
Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK)
type StatementType ¶
type StatementType string
StatementType is type of the SQL statement
const ( SelectStatementType StatementType = "SELECT" InsertStatementType StatementType = "INSERT" UpdateStatementType StatementType = "UPDATE" DeleteStatementType StatementType = "DELETE" SetStatementType StatementType = "SET" LockStatementType StatementType = "LOCK" UnLockStatementType StatementType = "UNLOCK" WithStatementType StatementType = "WITH" )
Statement types
type StringExpression ¶
type StringExpression interface {
Expression
EQ(rhs StringExpression) BoolExpression
NOT_EQ(rhs StringExpression) BoolExpression
IS_DISTINCT_FROM(rhs StringExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs StringExpression) BoolExpression
LT(rhs StringExpression) BoolExpression
LT_EQ(rhs StringExpression) BoolExpression
GT(rhs StringExpression) BoolExpression
GT_EQ(rhs StringExpression) BoolExpression
BETWEEN(min, max StringExpression) BoolExpression
NOT_BETWEEN(min, max StringExpression) BoolExpression
CONCAT(rhs Expression) StringExpression
LIKE(pattern StringExpression) BoolExpression
NOT_LIKE(pattern StringExpression) BoolExpression
REGEXP_LIKE(pattern StringExpression, caseSensitive ...bool) BoolExpression
NOT_REGEXP_LIKE(pattern StringExpression, caseSensitive ...bool) BoolExpression
}
StringExpression interface
func BTRIM ¶
func BTRIM(stringExpression StringExpression, trimChars ...StringExpression) StringExpression
BTRIM removes the longest string consisting only of characters in characters (a space by default) from the start and end of string
func CHR ¶
func CHR(integerExpression IntegerExpression) StringExpression
CHR returns character with the given code.
func CONCAT ¶
func CONCAT(expressions ...Expression) StringExpression
CONCAT adds two or more expressions together
func CONCAT_WS ¶
func CONCAT_WS(separator Expression, expressions ...Expression) StringExpression
CONCAT_WS adds two or more expressions together with a separator.
func CONVERT ¶
func CONVERT(str StringExpression, srcEncoding StringExpression, destEncoding StringExpression) StringExpression
CONVERT converts string to dest_encoding. The original encoding is specified by src_encoding. The string must be valid in this encoding.
func CONVERT_FROM ¶
func CONVERT_FROM(str StringExpression, srcEncoding StringExpression) StringExpression
CONVERT_FROM converts string to the database encoding. The original encoding is specified by src_encoding. The string must be valid in this encoding.
func CONVERT_TO ¶
func CONVERT_TO(str StringExpression, toEncoding StringExpression) StringExpression
CONVERT_TO converts string to dest_encoding.
func DECODE ¶
func DECODE(data StringExpression, format StringExpression) StringExpression
DECODE decodes binary data from textual representation in string. Options for format are same as in encode.
func ENCODE ¶
func ENCODE(data StringExpression, format StringExpression) StringExpression
ENCODE encodes binary data into a textual representation. Supported formats are: base64, hex, escape. escape converts zero bytes and high-bit-set bytes to octal sequences (\nnn) and doubles backslashes.
func FORMAT ¶
func FORMAT(formatStr StringExpression, formatArgs ...Expression) StringExpression
FORMAT formats a number to a format like "#,###,###.##", rounded to a specified number of decimal places, then it returns the result as a string.
func INITCAP ¶
func INITCAP(str StringExpression) StringExpression
INITCAP converts the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters.
func LEFT ¶
func LEFT(str StringExpression, n IntegerExpression) StringExpression
LEFT returns first n characters in the string. When n is negative, return all but last |n| characters.
func LENGTH ¶
func LENGTH(str StringExpression, encoding ...StringExpression) StringExpression
LENGTH returns number of characters in string with a given encoding
func LOWER ¶
func LOWER(stringExpression StringExpression) StringExpression
LOWER returns string expression in lower case
func LPAD ¶
func LPAD(str StringExpression, length IntegerExpression, text ...StringExpression) StringExpression
LPAD fills up the string to length length by prepending the characters fill (a space by default). If the string is already longer than length then it is truncated (on the right).
func LTRIM ¶
func LTRIM(str StringExpression, trimChars ...StringExpression) StringExpression
LTRIM removes the longest string containing only characters from characters (a space by default) from the start of string
func MD5 ¶
func MD5(stringExpression StringExpression) StringExpression
MD5 calculates the MD5 hash of string, returning the result in hexadecimal
func NewEnumValue ¶
func NewEnumValue(name string) StringExpression
NewEnumValue creates new named enum value
func NewStringFunc ¶ added in v2.6.0
func NewStringFunc(name string, expressions ...Expression) StringExpression
NewStringFunc creates new string function with name and expression parameters
func REPEAT ¶
func REPEAT(str StringExpression, n IntegerExpression) StringExpression
REPEAT repeats string the specified number of times
func REPLACE ¶
func REPLACE(text, from, to StringExpression) StringExpression
REPLACE replaces all occurrences in string of substring from with substring to
func REVERSE ¶
func REVERSE(stringExpression StringExpression) StringExpression
REVERSE returns reversed string.
func RIGHT ¶
func RIGHT(str StringExpression, n IntegerExpression) StringExpression
RIGHT returns last n characters in the string. When n is negative, return all but first |n| characters.
func RPAD ¶
func RPAD(str StringExpression, length IntegerExpression, text ...StringExpression) StringExpression
RPAD fills up the string to length length by appending the characters fill (a space by default). If the string is already longer than length then it is truncated.
func RTRIM ¶
func RTRIM(str StringExpression, trimChars ...StringExpression) StringExpression
RTRIM removes the longest string containing only characters from characters (a space by default) from the end of string
func RawString ¶ added in v2.5.0
func RawString(raw string, namedArgs ...map[string]interface{}) StringExpression
RawString helper that for string expressions
func SUBSTR ¶
func SUBSTR(str StringExpression, from IntegerExpression, count ...IntegerExpression) StringExpression
SUBSTR extracts substring
func String ¶
func String(value string) StringExpression
String creates new string literal expression
func StringExp ¶
func StringExp(expression Expression) StringExpression
StringExp is string expression wrapper around arbitrary expression. Allows go compiler to see any expression as string expression. Does not add sql cast to generated sql builder output.
func TO_ASCII ¶
func TO_ASCII(str StringExpression, encoding ...StringExpression) StringExpression
TO_ASCII convert string to ASCII from another encoding
func TO_CHAR ¶
func TO_CHAR(expression Expression, format StringExpression) StringExpression
TO_CHAR converts expression to string with format
func TO_HEX ¶
func TO_HEX(number IntegerExpression) StringExpression
TO_HEX converts number to its equivalent hexadecimal representation
func UPPER ¶
func UPPER(stringExpression StringExpression) StringExpression
UPPER returns string expression in upper case
func UUID ¶ added in v2.5.0
func UUID(value fmt.Stringer) StringExpression
UUID is a helper function to create string literal expression from uuid object value can be any uuid type with a String method
type Table ¶
type Table interface {
SchemaName() string
TableName() string
Alias() string
// contains filtered or unexported methods
}
Table interface
type TimeExpression ¶
type TimeExpression interface {
Expression
EQ(rhs TimeExpression) BoolExpression
NOT_EQ(rhs TimeExpression) BoolExpression
IS_DISTINCT_FROM(rhs TimeExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs TimeExpression) BoolExpression
LT(rhs TimeExpression) BoolExpression
LT_EQ(rhs TimeExpression) BoolExpression
GT(rhs TimeExpression) BoolExpression
GT_EQ(rhs TimeExpression) BoolExpression
BETWEEN(min, max TimeExpression) BoolExpression
NOT_BETWEEN(min, max TimeExpression) BoolExpression
ADD(rhs Interval) TimeExpression
SUB(rhs Interval) TimeExpression
}
TimeExpression interface
func LOCALTIME ¶
func LOCALTIME(precision ...int) TimeExpression
LOCALTIME returns local time of day using optional precision
func RawTime ¶ added in v2.5.0
func RawTime(raw string, namedArgs ...map[string]interface{}) TimeExpression
RawTime helper that for time expressions
func Time ¶
func Time(hour, minute, second int, nanoseconds ...time.Duration) TimeExpression
Time creates new time literal expression
func TimeExp ¶
func TimeExp(expression Expression) TimeExpression
TimeExp is time expression wrapper around arbitrary expression. Allows go compiler to see any expression as time expression. Does not add sql cast to generated sql builder output.
func TimeT ¶
func TimeT(t time.Time) TimeExpression
TimeT creates new time literal expression from time.Time object
type TimestampExpression ¶
type TimestampExpression interface {
Expression
EQ(rhs TimestampExpression) BoolExpression
NOT_EQ(rhs TimestampExpression) BoolExpression
IS_DISTINCT_FROM(rhs TimestampExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs TimestampExpression) BoolExpression
LT(rhs TimestampExpression) BoolExpression
LT_EQ(rhs TimestampExpression) BoolExpression
GT(rhs TimestampExpression) BoolExpression
GT_EQ(rhs TimestampExpression) BoolExpression
BETWEEN(min, max TimestampExpression) BoolExpression
NOT_BETWEEN(min, max TimestampExpression) BoolExpression
ADD(rhs Interval) TimestampExpression
SUB(rhs Interval) TimestampExpression
}
TimestampExpression interface
func LOCALTIMESTAMP ¶
func LOCALTIMESTAMP(precision ...int) TimestampExpression
LOCALTIMESTAMP returns current date and time using optional precision
func RawTimestamp ¶ added in v2.5.0
func RawTimestamp(raw string, namedArgs ...map[string]interface{}) TimestampExpression
RawTimestamp helper that for timestamp expressions
func Timestamp ¶
func Timestamp(year int, month time.Month, day, hour, minute, second int, nanoseconds ...time.Duration) TimestampExpression
Timestamp creates new timestamp literal expression
func TimestampExp ¶
func TimestampExp(expression Expression) TimestampExpression
TimestampExp is timestamp expression wrapper around arbitrary expression. Allows go compiler to see any expression as timestamp expression. Does not add sql cast to generated sql builder output.
func TimestampT ¶
func TimestampT(t time.Time) TimestampExpression
TimestampT creates new timestamp literal expression from time.Time object
type TimestampzExpression ¶
type TimestampzExpression interface {
Expression
EQ(rhs TimestampzExpression) BoolExpression
NOT_EQ(rhs TimestampzExpression) BoolExpression
IS_DISTINCT_FROM(rhs TimestampzExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs TimestampzExpression) BoolExpression
LT(rhs TimestampzExpression) BoolExpression
LT_EQ(rhs TimestampzExpression) BoolExpression
GT(rhs TimestampzExpression) BoolExpression
GT_EQ(rhs TimestampzExpression) BoolExpression
BETWEEN(min, max TimestampzExpression) BoolExpression
NOT_BETWEEN(min, max TimestampzExpression) BoolExpression
ADD(rhs Interval) TimestampzExpression
SUB(rhs Interval) TimestampzExpression
}
TimestampzExpression interface
func CURRENT_TIMESTAMP ¶
func CURRENT_TIMESTAMP(precision ...int) TimestampzExpression
CURRENT_TIMESTAMP returns current timestamp with time zone
func RawTimestampz ¶ added in v2.5.0
func RawTimestampz(raw string, namedArgs ...map[string]interface{}) TimestampzExpression
RawTimestampz helper that for timestamp with time zone expressions
func TO_TIMESTAMP ¶
func TO_TIMESTAMP(timestampzStr, format StringExpression) TimestampzExpression
TO_TIMESTAMP converts string to time stamp with time zone using format
func Timestampz ¶
func Timestampz(year int, month time.Month, day, hour, minute, second int, nanoseconds time.Duration, timezone string) TimestampzExpression
Timestampz creates new timestamp with time zone literal expression
func TimestampzExp ¶
func TimestampzExp(expression Expression) TimestampzExpression
TimestampzExp is timestamp with time zone expression wrapper around arbitrary expression. Allows go compiler to see any expression as timestamp with time zone expression. Does not add sql cast to generated sql builder output.
func TimestampzT ¶
func TimestampzT(t time.Time) TimestampzExpression
TimestampzT creates new timestamp literal expression from time.Time object
type TimezExpression ¶
type TimezExpression interface {
Expression
EQ(rhs TimezExpression) BoolExpression
NOT_EQ(rhs TimezExpression) BoolExpression
IS_DISTINCT_FROM(rhs TimezExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs TimezExpression) BoolExpression
LT(rhs TimezExpression) BoolExpression
LT_EQ(rhs TimezExpression) BoolExpression
GT(rhs TimezExpression) BoolExpression
GT_EQ(rhs TimezExpression) BoolExpression
BETWEEN(min, max TimezExpression) BoolExpression
NOT_BETWEEN(min, max TimezExpression) BoolExpression
ADD(rhs Interval) TimezExpression
SUB(rhs Interval) TimezExpression
}
TimezExpression interface for 'time with time zone' types
func CURRENT_TIME ¶
func CURRENT_TIME(precision ...int) TimezExpression
CURRENT_TIME returns current time with time zone
func RawTimez ¶ added in v2.5.0
func RawTimez(raw string, namedArgs ...map[string]interface{}) TimezExpression
RawTimez helper that for time with time zone expressions
func Timez ¶
func Timez(hour, minute, second int, nanoseconds time.Duration, timezone string) TimezExpression
Timez creates new time with time zone literal expression
func TimezExp ¶
func TimezExp(expression Expression) TimezExpression
TimezExp is time with time zone expression wrapper around arbitrary expression. Allows go compiler to see any expression as time with time zone expression. Does not add sql cast to generated sql builder output.
func TimezT ¶
func TimezT(t time.Time) TimezExpression
TimezT creates new time with time zone literal expression from time.Time object
type Window ¶
type Window interface {
Serializer
ORDER_BY(expr ...OrderByClause) Window
ROWS(start FrameExtent, end ...FrameExtent) Window
RANGE(start FrameExtent, end ...FrameExtent) Window
GROUPS(start FrameExtent, end ...FrameExtent) Window
}
Window interface
func PARTITION_BY ¶
func PARTITION_BY(exp Expression, exprs ...Expression) Window
PARTITION_BY window function constructor
func WindowName ¶
WindowName is used to specify window reference from WINDOW clause
type WindowDefinition ¶
WindowDefinition struct
Source Files
¶
- alias.go
- bool_expression.go
- cast.go
- clause.go
- column.go
- column_assigment.go
- column_list.go
- column_types.go
- date_expression.go
- dialect.go
- enum_value.go
- expression.go
- float_expression.go
- func_expression.go
- group_by_clause.go
- integer_expression.go
- interval.go
- keyword.go
- literal_expression.go
- logger.go
- numeric_expression.go
- operators.go
- order_by_clause.go
- order_set_aggregate_functions.go
- projection.go
- raw_statement.go
- select_lock.go
- select_table.go
- serializer.go
- sql_builder.go
- statement.go
- string_expression.go
- table.go
- testutils.go
- time_expression.go
- timestamp_expression.go
- timestampz_expression.go
- timez_expression.go
- utils.go
- window_expression.go
- window_func.go
- with_statement.go