Documentation ¶
Overview ¶
Package jet is a framework for writing type-safe SQL queries for PostgreSQL in Go, with ability to easily convert database query result to desired arbitrary structure.
Index ¶
- Constants
- Variables
- func CAST(expression Expression) cast
- type BoolExpression
- func BOOL_AND(boolExpression BoolExpression) BoolExpression
- func BOOL_OR(boolExpression BoolExpression) BoolExpression
- func Bool(value bool) BoolExpression
- func BoolExp(expression Expression) BoolExpression
- func EVERY(boolExpression BoolExpression) BoolExpression
- func EXISTS(subQuery SelectStatement) BoolExpression
- func NOT(exp BoolExpression) BoolExpression
- type CaseOperator
- type Column
- type ColumnBool
- type ColumnDate
- type ColumnFloat
- type ColumnInteger
- type ColumnList
- type ColumnString
- type ColumnTime
- type ColumnTimestamp
- type ColumnTimestampz
- type ColumnTimez
- type DateExpression
- type DeleteStatement
- type Expression
- func COALESCE(value Expression, values ...Expression) Expression
- func GREATEST(value Expression, values ...Expression) Expression
- func LEAST(value Expression, values ...Expression) Expression
- func NULLIF(value1, value2 Expression) Expression
- func RAW(raw string) Expression
- func ROW(expressions ...Expression) Expression
- func WRAP(expression ...Expression) Expression
- type FloatExpression
- func ABSf(floatExpression FloatExpression) FloatExpression
- func AVG(numericExpression NumericExpression) FloatExpression
- func CBRT(numericExpression NumericExpression) FloatExpression
- func CEIL(floatExpression FloatExpression) 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 MAXf(floatExpression FloatExpression) FloatExpression
- func MINf(floatExpression FloatExpression) FloatExpression
- func ROUND(floatExpression FloatExpression, precision ...IntegerExpression) FloatExpression
- func SIGN(floatExpression FloatExpression) FloatExpression
- func SQRT(numericExpression NumericExpression) FloatExpression
- func SUMf(floatExpression FloatExpression) FloatExpression
- func TO_NUMBER(floatStr, format StringExpression) FloatExpression
- func TRUNC(floatExpression FloatExpression, precision ...IntegerExpression) FloatExpression
- type InsertStatement
- type IntegerExpression
- func ABSi(integerExpression IntegerExpression) IntegerExpression
- func BIT_AND(integerExpression IntegerExpression) IntegerExpression
- func BIT_LENGTH(stringExpression StringExpression) IntegerExpression
- func BIT_NOT(expr IntegerExpression) IntegerExpression
- func BIT_OR(integerExpression IntegerExpression) IntegerExpression
- func CHAR_LENGTH(stringExpression StringExpression) IntegerExpression
- func COUNT(expression Expression) IntegerExpression
- func Int(value int64) IntegerExpression
- func IntExp(expression Expression) IntegerExpression
- func MAXi(integerExpression IntegerExpression) IntegerExpression
- func MINi(integerExpression IntegerExpression) IntegerExpression
- func OCTET_LENGTH(stringExpression StringExpression) IntegerExpression
- func STRPOS(str, substring StringExpression) IntegerExpression
- func SUMi(integerExpression IntegerExpression) IntegerExpression
- type LockStatement
- type NumericExpression
- type ProjectionList
- type ReadableTable
- type SelectLock
- type SelectStatement
- func EXCEPT(lhs, rhs SelectStatement) SelectStatement
- func EXCEPT_ALL(lhs, rhs SelectStatement) SelectStatement
- func INTERSECT(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
- func INTERSECT_ALL(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
- func SELECT(projection1 projection, projections ...projection) SelectStatement
- func UNION(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
- func UNION_ALL(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
- type SelectTable
- type Statement
- type StringExpression
- func BTRIM(stringExpression StringExpression, trimChars ...StringExpression) StringExpression
- func CHR(integerExpression IntegerExpression) 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 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 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 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
- type Table
- type TableLockMode
- type TimeExpression
- type TimestampExpression
- type TimestampzExpression
- func CURRENT_TIMESTAMP(precision ...int) TimestampzExpression
- func NOW() TimestampzExpression
- func TO_TIMESTAMP(timestampzStr, format StringExpression) TimestampzExpression
- func Timestampz(year, month, day, hour, minute, second, milliseconds, timezone int) TimestampzExpression
- func TimestampzExp(expression Expression) TimestampzExpression
- type TimezExpression
- type UpdateStatement
- type WritableTable
Constants ¶
const ( LOCK_ACCESS_SHARE = "ACCESS SHARE" LOCK_ROW_SHARE = "ROW SHARE" LOCK_ROW_EXCLUSIVE = "ROW EXCLUSIVE" LOCK_SHARE_UPDATE_EXCLUSIVE = "SHARE UPDATE EXCLUSIVE" LOCK_SHARE = "SHARE" LOCK_SHARE_ROW_EXCLUSIVE = "SHARE ROW EXCLUSIVE" LOCK_EXCLUSIVE = "EXCLUSIVE" LOCK_ACCESS_EXCLUSIVE = "ACCESS EXCLUSIVE" )
Lock types for LockStatement.
const (
// DEFAULT is jet equivalent of SQL DEFAULT
DEFAULT keywordClause = "DEFAULT"
)
Variables ¶
var ( // NULL is jet equivalent of SQL NULL NULL = newNullLiteral() // STAR is jet equivalent of SQL * STAR = newStarLiteral() )
var ( UPDATE = newLock("UPDATE") NO_KEY_UPDATE = newLock("NO KEY UPDATE") SHARE = newLock("SHARE") KEY_SHARE = newLock("KEY SHARE") )
Select statements lock types
Functions ¶
func CAST ¶
func CAST(expression Expression) cast
CAST wraps expression for casting. For instance: CAST(table.column).AS_BOOL()
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_AND ¶
func BOOL_AND(boolExpression BoolExpression) BoolExpression
BOOL_AND is aggregate function. Returns true if all input values are true, otherwise false
func BOOL_OR ¶
func BOOL_OR(boolExpression BoolExpression) BoolExpression
BOOL_OR is aggregate function. Returns true if at least one input value is true, otherwise false
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 EVERY ¶
func EVERY(boolExpression BoolExpression) BoolExpression
EVERY is aggregate function. Returns true if all input values are true, otherwise false
func EXISTS ¶
func EXISTS(subQuery SelectStatement) BoolExpression
EXISTS checks for existence of the rows in subQuery
func NOT ¶
func NOT(exp BoolExpression) BoolExpression
NOT returns negation of bool expression result
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 Column ¶
type Column interface { Expression // contains filtered or unexported methods }
Column is common column interface for all types of columns.
type ColumnBool ¶
type ColumnBool interface { BoolExpression From(subQuery SelectTable) ColumnBool // contains filtered or unexported methods }
ColumnBool is interface for SQL boolean columns.
type ColumnDate ¶
type ColumnDate interface { DateExpression From(subQuery SelectTable) ColumnDate // contains filtered or unexported methods }
ColumnDate is interface of SQL date columns.
type ColumnFloat ¶
type ColumnFloat interface { FloatExpression From(subQuery SelectTable) ColumnFloat // contains filtered or unexported methods }
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 From(subQuery SelectTable) ColumnInteger // contains filtered or unexported methods }
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 []Column
ColumnList is redefined 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) TableName ¶
func (cl ColumnList) TableName() string
TableName is placeholder for ColumnList to implement Column interface
type ColumnString ¶
type ColumnString interface { StringExpression From(subQuery SelectTable) ColumnString // contains filtered or unexported methods }
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 From(subQuery SelectTable) ColumnTime // contains filtered or unexported methods }
ColumnTime is interface for SQL time column.
type ColumnTimestamp ¶
type ColumnTimestamp interface { TimestampExpression From(subQuery SelectTable) ColumnTimestamp // contains filtered or unexported methods }
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 From(subQuery SelectTable) ColumnTimestampz // contains filtered or unexported methods }
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 From(subQuery SelectTable) ColumnTimez // contains filtered or unexported methods }
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 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 }
DateExpression is interface for all SQL date expressions.
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 TO_DATE ¶
func TO_DATE(dateStr, format StringExpression) DateExpression
TO_DATE converts string to date using format
type DeleteStatement ¶
type DeleteStatement interface { Statement WHERE(expression BoolExpression) DeleteStatement RETURNING(projections ...projection) DeleteStatement }
DeleteStatement is interface for SQL DELETE statement
type Expression ¶
type Expression interface { // Test expression whether it is a NULL value. IS_NULL() BoolExpression // Test expression whether it is a non-NULL value. IS_NOT_NULL() BoolExpression // Check if this expressions matches any in expressions list IN(expressions ...Expression) BoolExpression // Check if this expressions is different of all expressions in expressions list NOT_IN(expressions ...Expression) BoolExpression // The temporary alias name to assign to the expression AS(alias string) projection // Expression will be used to sort query result in ascending order ASC() orderByClause // Expression will be used to sort query result in ascending order DESC() orderByClause // contains filtered or unexported methods }
Expression is common interface for all expressions. Can be Bool, Int, Float, String, Date, Time, Timez, Timestamp or Timestampz expressions.
func COALESCE ¶
func COALESCE(value Expression, values ...Expression) Expression
COALESCE function returns the first of its arguments that is not null.
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 NULLIF ¶
func NULLIF(value1, value2 Expression) Expression
NULLIF function returns a null value if value1 equals value2; otherwise it returns value1.
func RAW ¶
func RAW(raw string) Expression
RAW can be used for any unsupported functions, operators or expressions. For example: RAW("current_database()")
func ROW ¶
func ROW(expressions ...Expression) Expression
ROW is construct one table row from list of expressions.
func WRAP ¶
func WRAP(expression ...Expression) Expression
WRAP wraps list of expressions with brackets '(' and ')'
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 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 AVG ¶
func AVG(numericExpression NumericExpression) FloatExpression
AVG is aggregate function used to calculate avg value from numeric 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 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 MAXf ¶
func MAXf(floatExpression FloatExpression) FloatExpression
MAXf is aggregate function. Returns maximum value of float expression across all input values
func MINf ¶
func MINf(floatExpression FloatExpression) FloatExpression
MINf is aggregate function. Returns minimum value of float expression across all input values
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 SUMf ¶
func SUMf(floatExpression FloatExpression) FloatExpression
SUMf is aggregate function. Returns sum of expression across all float expressions
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 InsertStatement ¶
type InsertStatement interface { Statement // Insert row of values VALUES(value interface{}, values ...interface{}) InsertStatement // Insert row of values, where value for each column is extracted from filed of structure data. // If data is not struct or there is no field for every column selected, this method will panic. MODEL(data interface{}) InsertStatement MODELS(data interface{}) InsertStatement QUERY(selectStatement SelectStatement) InsertStatement RETURNING(projections ...projection) InsertStatement }
InsertStatement is interface for SQL INSERT statements
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_AND ¶
func BIT_AND(integerExpression IntegerExpression) IntegerExpression
BIT_AND is aggregate function used to calculates the bitwise AND of all non-null input values, or null if none.
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 BIT_OR ¶
func BIT_OR(integerExpression IntegerExpression) IntegerExpression
BIT_OR is aggregate function used to calculates the bitwise OR of all non-null input values, or null if none.
func CHAR_LENGTH ¶
func CHAR_LENGTH(stringExpression StringExpression) IntegerExpression
CHAR_LENGTH returns number of characters in string expression
func COUNT ¶
func COUNT(expression Expression) IntegerExpression
COUNT is aggregate function. Returns number of input rows for which the value of expression is not null.
func Int ¶
func Int(value int64) IntegerExpression
Int is constructor for integer expressions literals.
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 MAXi ¶
func MAXi(integerExpression IntegerExpression) IntegerExpression
MAXi is aggregate function. Returns maximum value of int expression across all input values
func MINi ¶
func MINi(integerExpression IntegerExpression) IntegerExpression
MINi is aggregate function. Returns minimum value of int expression across all input values
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)
func SUMi ¶
func SUMi(integerExpression IntegerExpression) IntegerExpression
SUMi is aggregate function. Returns sum of expression across all integer expression.
type LockStatement ¶
type LockStatement interface { Statement IN(lockMode TableLockMode) LockStatement NOWAIT() LockStatement }
LockStatement interface for SQL LOCK statement
func LOCK ¶
func LOCK(tables ...WritableTable) LockStatement
LOCK creates lock statement for list of tables.
type NumericExpression ¶
type NumericExpression interface { Expression // contains filtered or unexported methods }
NumericExpression is common interface for all integer and float expressions
type ProjectionList ¶
type ProjectionList []projection
ProjectionList is a redefined type, so that ProjectionList can be used as a projection.
type ReadableTable ¶
type ReadableTable interface {
// contains filtered or unexported methods
}
ReadableTable interface
type SelectLock ¶
type SelectLock interface { NOWAIT() SelectLock SKIP_LOCKED() SelectLock // contains filtered or unexported methods }
SelectLock is interface for SELECT statement locks
type SelectStatement ¶
type SelectStatement interface { Statement Expression DISTINCT() SelectStatement FROM(table ReadableTable) SelectStatement WHERE(expression BoolExpression) SelectStatement GROUP_BY(groupByClauses ...groupByClause) SelectStatement HAVING(boolExpression BoolExpression) SelectStatement ORDER_BY(orderByClauses ...orderByClause) SelectStatement LIMIT(limit int64) SelectStatement OFFSET(offset int64) SelectStatement FOR(lock SelectLock) SelectStatement UNION(rhs SelectStatement) SelectStatement UNION_ALL(rhs SelectStatement) SelectStatement INTERSECT(rhs SelectStatement) SelectStatement INTERSECT_ALL(rhs SelectStatement) SelectStatement EXCEPT(rhs SelectStatement) SelectStatement EXCEPT_ALL(rhs SelectStatement) SelectStatement AsTable(alias string) SelectTable // contains filtered or unexported methods }
SelectStatement is interface for SQL SELECT statements
func EXCEPT ¶
func EXCEPT(lhs, rhs SelectStatement) SelectStatement
EXCEPT returns all rows that are in the result of query lhs but not in the result of query rhs. It eliminates duplicate rows from its result.
func EXCEPT_ALL ¶
func EXCEPT_ALL(lhs, rhs SelectStatement) SelectStatement
EXCEPT_ALL returns all rows that are in the result of query lhs but not in the result of query rhs. It does not eliminates duplicate rows from its result.
func INTERSECT ¶
func INTERSECT(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
INTERSECT returns all rows that are in query results. It eliminates duplicate rows from its result.
func INTERSECT_ALL ¶
func INTERSECT_ALL(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
INTERSECT_ALL returns all rows that are in query results. It does not eliminates duplicate rows from its result.
func SELECT ¶
func SELECT(projection1 projection, projections ...projection) SelectStatement
SELECT creates new SelectStatement with list of projections
func UNION ¶
func UNION(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
UNION effectively appends the result of sub-queries(select statements) into single query. It eliminates duplicate rows from its result.
func UNION_ALL ¶
func UNION_ALL(lhs, rhs SelectStatement, selects ...SelectStatement) SelectStatement
UNION_ALL effectively appends the result of sub-queries(select statements) into single query. It does not eliminates duplicate rows from its result.
type SelectTable ¶
type SelectTable interface { ReadableTable Alias() string AllColumns() ProjectionList }
SelectTable is interface for SELECT sub-queries
type Statement ¶
type Statement interface { // Sql returns parametrized sql query with list of arguments. // err is returned if statement is not composed correctly Sql() (query string, args []interface{}, err error) // 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. // err is returned if statement is not composed correctly DebugSql() (query string, err error) // Query executes statement over database connection db and stores row result in destination. // Destination can be arbitrary structure Query(db execution.DB, destination interface{}) error // QueryContext executes statement with a context over database connection db and stores row result in destination. // Destination can be of arbitrary structure QueryContext(context context.Context, db execution.DB, destination interface{}) error //Exec executes statement over db connection without returning any rows. Exec(db execution.DB) (sql.Result, error) //Exec executes statement with context over db connection without returning any rows. ExecContext(context context.Context, db execution.DB) (sql.Result, error) }
Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK)
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 SIMILAR_TO(pattern StringExpression) BoolExpression NOT_SIMILAR_TO(pattern StringExpression) 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 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 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 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 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
type Table ¶
type Table interface { SchemaName() string TableName() string AS(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 }
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, milliseconds int) 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.
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 }
TimestampExpression interface
func LOCALTIMESTAMP ¶
func LOCALTIMESTAMP(precision ...int) TimestampExpression
LOCALTIMESTAMP returns current date and time using optional precision
func Timestamp ¶
func Timestamp(year, month, day, hour, minute, second, milliseconds int) 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.
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 }
TimestampzExpression interface
func CURRENT_TIMESTAMP ¶
func CURRENT_TIMESTAMP(precision ...int) TimestampzExpression
CURRENT_TIMESTAMP returns current timestamp with time zone
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, month, day, hour, minute, second, milliseconds, timezone int) 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.
type TimezExpression ¶
type TimezExpression interface { Expression //EQ EQ(rhs TimezExpression) BoolExpression //NOT_EQ NOT_EQ(rhs TimezExpression) BoolExpression //IS_DISTINCT_FROM IS_DISTINCT_FROM(rhs TimezExpression) BoolExpression //IS_NOT_DISTINCT_FROM IS_NOT_DISTINCT_FROM(rhs TimezExpression) BoolExpression //LT LT(rhs TimezExpression) BoolExpression //LT_EQ LT_EQ(rhs TimezExpression) BoolExpression //GT GT(rhs TimezExpression) BoolExpression //GT_EQ GT_EQ(rhs TimezExpression) BoolExpression }
TimezExpression interface 'time with time zone'
func CURRENT_TIME ¶
func CURRENT_TIME(precision ...int) TimezExpression
CURRENT_TIME returns current time with time zone
func Timez ¶
func Timez(hour, minute, second, milliseconds, timezone int) 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.
type UpdateStatement ¶
type UpdateStatement interface { Statement SET(value interface{}, values ...interface{}) UpdateStatement MODEL(data interface{}) UpdateStatement WHERE(expression BoolExpression) UpdateStatement RETURNING(projections ...projection) UpdateStatement }
UpdateStatement is interface of SQL UPDATE statement
type WritableTable ¶
type WritableTable interface {
// contains filtered or unexported methods
}
WritableTable interface
Source Files ¶
- alias.go
- bool_expression.go
- cast.go
- clause.go
- column.go
- column_types.go
- date_expression.go
- delete_statement.go
- doc.go
- enum_value.go
- expression.go
- float_expression.go
- func_expression.go
- group_by_clause.go
- insert_statement.go
- integer_expression.go
- keyword.go
- literal_expression.go
- lock_statement.go
- numeric_expression.go
- operators.go
- order_by_clause.go
- projection.go
- select_statement.go
- select_table.go
- set_statement.go
- statement.go
- string_expression.go
- table.go
- time_expression.go
- timestamp_expression.go
- timestampz_expression.go
- timez_expression.go
- update_statement.go
- utils.go