jet

package
v2.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0, BSD-3-Clause, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StringConcatOperator        = "||"
	StringRegexpLikeOperator    = "REGEXP"
	StringNotRegexpLikeOperator = "NOT REGEXP"
)

Operators

Variables

View Source
var (
	// NULL is jet equivalent of SQL NULL
	NULL = newNullLiteral()
	// STAR is jet equivalent of SQL *
	STAR = newStarLiteral()
)
View Source
var (
	UNBOUNDED   = Keyword("UNBOUNDED")
	CURRENT_ROW = frameExtentKeyword{"CURRENT ROW"}
)

Window function keywords

Functions

func AVG

func AVG(numericExpression NumericExpression) 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 NewBinaryOperatorExpression

func NewBinaryOperatorExpression(lhs, rhs Serializer, operator string, additionalParam ...Expression) *binaryOperatorExpression

NewBinaryOperatorExpression creates new binaryOperatorExpression

func NewFloatWindowFunc

func NewFloatWindowFunc(name string, expressions ...Expression) floatWindowExpression

NewFloatWindowFunc creates new float function with name and expressions

func NewRowLock

func NewRowLock(name string) func() RowLock

NewRowLock creates new RowLock

func NewTimestampFunc

func NewTimestampFunc(name string, expressions ...Expression) *timestampFunc

NewTimestampFunc creates new timestamp function with name and expressions

func OptionalOrDefaultString

func OptionalOrDefaultString(defaultStr string, str ...string) string

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, statementType StatementType,
	out *SQLBuilder, options ...SerializeOption)

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

func WITH

func WITH(dialect Dialect, cte ...CommonTableExpressionDefinition) func(statement Statement) Statement

WITH function creates new with statement from list of common table expressions for specified dialect

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 Bool

func Bool(value bool) BoolExpression

Bool creates new bool literal expression

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 Eq

func Eq(lhs, rhs Expression) BoolExpression

Eq returns a representation of "a=b"

func Gt

func Gt(lhs, rhs Expression) BoolExpression

Gt returns a representation of "a>b"

func GtEq

func GtEq(lhs, rhs Expression) BoolExpression

GtEq returns a representation of "a>=b"

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

Lt returns a representation of "a<b"

func LtEq

func LtEq(lhs, rhs Expression) BoolExpression

LtEq returns a representation of "a<=b"

func NOT

NOT returns negation of bool expression result

func NotEq

func NotEq(lhs, rhs Expression) BoolExpression

NotEq returns a representation of "a!=b"

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

type ClauseOptional struct {
	Name      string
	Show      bool
	InNewLine bool
}

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
}

ClauseQuery struct

func (*ClauseQuery) Serialize

func (v *ClauseQuery) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption)

Serialize serializes clause into SQLBuilder

type ClauseSelect

type ClauseSelect struct {
	Distinct       bool
	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
}

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 UnwidColumnList

func UnwidColumnList(columns []Column) []Column

UnwidColumnList func

func UnwindColumns

func UnwindColumns(column1 Column, columns ...Column) []Column

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.

func BoolColumn

func BoolColumn(name string) ColumnBool

BoolColumn creates named bool column.

type ColumnDate

type ColumnDate interface {
	DateExpression
	Column

	From(subQuery SelectTable) ColumnDate
	SET(dateExp DateExpression) ColumnAssigment
}

ColumnDate is interface of SQL date columns.

func DateColumn

func DateColumn(name string) ColumnDate

DateColumn creates named date column.

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

func TimeColumn

func TimeColumn(name string) ColumnTime

TimeColumn creates named 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 {
	// contains filtered or unexported fields
}

CommonTableExpression contains information about a CTE.

func CTE

func CTE(name string) CommonTableExpression

CTE creates new named CommonTableExpression

func (*CommonTableExpression) AS

AS returns sets definition for a CTE

func (CommonTableExpression) Alias

func (s CommonTableExpression) Alias() string

func (CommonTableExpression) AllColumns

func (s CommonTableExpression) AllColumns() ProjectionList

type CommonTableExpressionDefinition

type CommonTableExpressionDefinition struct {
	// contains filtered or unexported fields
}

CommonTableExpressionDefinition contains implementation details of CTE

type DateExpression

DateExpression is interface for date types

func CURRENT_DATE

func CURRENT_DATE() DateExpression

CURRENT_DATE returns current date

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 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 ascending order
	DESC() OrderByClause
}

Expression is common interface for all expressions. Can be Bool, Int, Float, String, Date, Time, Timez, Timestamp or Timestampz expressions.

func Add

func Add(lhs, rhs Serializer) Expression

Add notEq returns a representation of "a + b"

func COALESCE

func COALESCE(value Expression, values ...Expression) Expression

COALESCE function returns the first of its arguments that is not null.

func Div

func Div(lhs, rhs Serializer) Expression

Div returns a representation of "a / b"

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 Mod

func Mod(lhs, rhs Serializer) Expression

Mod returns a representation of "a % b"

func Mul

func Mul(lhs, rhs Serializer) Expression

Mul returns a representation of "a * b"

func NULLIF

func NULLIF(value1, value2 Expression) Expression

NULLIF function returns a null value if value1 equals value2; otherwise it returns value1.

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, parent ...Expression) Expression

Raw can be used for any unsupported functions, operators or expressions. For example: Raw("current_database()")

func SUM

func SUM(expression Expression) Expression

SUM is aggregate function. Returns sum of all expressions

func Sub

func Sub(lhs, rhs Serializer) Expression

Sub notEq returns a representation of "a - b"

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

AS the temporary alias name to assign to the expression

func (*ExpressionInterfaceImpl) ASC

ASC expression will be used to sort query result in ascending order

func (*ExpressionInterfaceImpl) DESC

DESC expression will be used to sort query result in ascending 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

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

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 FLOOR

func FLOOR(floatExpression FloatExpression) FloatExpression

FLOOR calculates floor of float expression

func Float

func Float(value float64) FloatExpression

Float creates new float literal

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

func FOLLOWING

func FOLLOWING(offset Serializer) FrameExtent

FOLLOWING window frame clause

func PRECEDING

func PRECEDING(offset Serializer) FrameExtent

PRECEDING window frame clause

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

	// Check if expression is equal to rhs
	EQ(rhs IntegerExpression) BoolExpression
	// Check if expression is not equal to rhs
	NOT_EQ(rhs IntegerExpression) BoolExpression
	// Check if expression is distinct from rhs
	IS_DISTINCT_FROM(rhs IntegerExpression) BoolExpression
	// Check if expression is not distinct from rhs
	IS_NOT_DISTINCT_FROM(rhs IntegerExpression) BoolExpression

	// Check if expression is less then rhs
	LT(rhs IntegerExpression) BoolExpression
	// Check if expression is less then equal rhs
	LT_EQ(rhs IntegerExpression) BoolExpression
	// Check if expression is greater then rhs
	GT(rhs IntegerExpression) BoolExpression
	// Check if expression is greater then equal rhs
	GT_EQ(rhs IntegerExpression) BoolExpression

	// expression + rhs
	ADD(rhs IntegerExpression) IntegerExpression
	// expression - rhs
	SUB(rhs IntegerExpression) IntegerExpression
	// expression * rhs
	MUL(rhs IntegerExpression) IntegerExpression
	// expression / rhs
	DIV(rhs IntegerExpression) IntegerExpression
	// expression % rhs
	MOD(rhs IntegerExpression) IntegerExpression
	// expression ^ rhs
	POW(rhs IntegerExpression) IntegerExpression

	// expression & rhs
	BIT_AND(rhs IntegerExpression) IntegerExpression
	// expression | rhs
	BIT_OR(rhs IntegerExpression) IntegerExpression
	// expression # rhs
	BIT_XOR(rhs IntegerExpression) IntegerExpression
	// expression << rhs
	BIT_SHIFT_LEFT(shift IntegerExpression) IntegerExpression
	// expression >> rhs
	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

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 Int

func Int(value int64) IntegerExpression

Int creates new 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 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)

type Interval

type Interval interface {
	Serializer
	IsInterval
}

Interval is internal common representation of sql interval

type IntervalImpl

type IntervalImpl struct {
	IsIntervalImpl
	// contains filtered or unexported fields
}

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 JoinType

type JoinType int

JoinType is type of table join

const (
	InnerJoin JoinType = iota
	LeftJoin
	RightJoin
	FullJoin
	CrossJoin
)

Table join types

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 definition of 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 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.

type QueryPlaceholderFunc

type QueryPlaceholderFunc func(ord int) string

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

func (s *SQLBuilder) NewLine()

NewLine adds new line to output SQL

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 {
	Serializer
	Alias() string
	AllColumns() ProjectionList
}

SelectTable is interface for SELECT sub-queries

func NewSelectTable

func NewSelectTable(selectStmt SerializerStatement, alias string) SelectTable

NewSelectTable func

type SerializeOption

type SerializeOption int

SerializeOption type

const (
	NoWrap SerializeOption = iota
	SkipNewLine

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

type SetPair struct {
	Column ColumnSerializer
	Value  Serializer
}

SetPair clause

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 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 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 without returning any rows.
	Exec(db qrm.DB) (sql.Result, error)
	//Exec executes statement with context over db connection without returning any rows.
	ExecContext(ctx context.Context, db qrm.DB) (sql.Result, 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

	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

DECODE decodes binary data from textual representation in string. Options for format are same as in encode.

func ENCODE

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

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

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

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 REPEAT

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.

RIGHT returns last n characters in the string. When n is negative, return all but first |n| characters.

func RPAD

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 SUBSTR

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

type Table

type Table interface {
	SchemaName() string
	TableName() string
	AS(alias string)
	// contains filtered or unexported methods
}

Table interface

type TimeExpression

TimeExpression interface

func LOCALTIME

func LOCALTIME(precision ...int) TimeExpression

LOCALTIME returns local time of day using optional precision

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

TimestampExpression interface

func LOCALTIMESTAMP

func LOCALTIMESTAMP(precision ...int) TimestampExpression

LOCALTIMESTAMP returns current date and time using optional precision

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

TimestampzExpression interface

func CURRENT_TIMESTAMP

func CURRENT_TIMESTAMP(precision ...int) TimestampzExpression

CURRENT_TIMESTAMP returns current timestamp with time zone

func NOW

NOW returns current date and time

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

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

func ORDER_BY(expr ...OrderByClause) Window

ORDER_BY window function constructor

func PARTITION_BY

func PARTITION_BY(exp Expression, exprs ...Expression) Window

PARTITION_BY window function constructor

func WindowName

func WindowName(name string) Window

WindowName is used to specify window reference from WINDOW clause

type WindowDefinition

type WindowDefinition struct {
	Name   string
	Window Window
}

WindowDefinition struct

Jump to

Keyboard shortcuts

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