postgres

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 63

Documentation

Index

Constants

View Source
const (
	DOW unit = MILLENNIUM + 1 + iota
	DOY
	EPOCH
	ISODOW
	ISOYEAR
	JULIAN
	QUARTER
	TIMEZONE
	TIMEZONE_HOUR
	TIMEZONE_MINUTE
)

Additional time unit types for EXTRACT function

View Source
const (
	YEAR unit = 123456789 + iota
	MONTH
	WEEK
	DAY
	HOUR
	MINUTE
	SECOND
	MILLISECOND
	MICROSECOND
	DECADE
	CENTURY
	MILLENNIUM
)

Interval unit types

View Source
const (
	// DEFAULT is jet equivalent of SQL DEFAULT
	DEFAULT = jet.DEFAULT
)

Variables

View Source
var (
	Int4RangeExp = jet.Int4RangeExp
	Int8RangeExp = jet.Int8RangeExp
	NumRangeExp  = jet.NumRangeExp
	DateRangeExp = jet.DateRangeExp
	TsRangeExp   = jet.TsRangeExp
	TstzRangeExp = jet.TstzRangeExp
)

RangeExp is range expression wrapper around arbitrary expression. Allows go compiler to see any expression as range expression. Does not add sql cast to generated sql builder output.

View Source
var (
	Raw = jet.Raw

	RawBool            = jet.RawBool
	RawInt             = jet.RawInt
	RawFloat           = jet.RawFloat
	RawString          = jet.RawString
	RawTime            = jet.RawTime
	RawTimez           = jet.RawTimez
	RawTimestamp       = jet.RawTimestamp
	RawTimestampz      = jet.RawTimestampz
	RawDate            = jet.RawDate
	RawNumRange        = jet.RawRange[jet.NumericExpression]
	RawInt4Range       = jet.RawRange[jet.Int4Expression]
	RawInt8Range       = jet.RawRange[jet.Int8Expression]
	RawTimestampRange  = jet.RawRange[jet.TimestampExpression]
	RawTimestampzRange = jet.RawRange[jet.TimestampzExpression]
	RawDateRange       = jet.RawRange[jet.DateExpression]
)

Raw can be used for any unsupported functions, operators or expressions. For example: Raw("current_database()") Raw helper methods for each of the postgres types

View Source
var (
	// AND function adds AND operator between expressions.
	AND = jet.AND
	// OR function adds OR operator between expressions.
	OR = jet.OR
)

This functions can be used, instead of its method counterparts, to have a better indentation of a complex condition in the Go code and in the generated SQL.

View Source
var (
	// DATE_RANGE constructor function to create a date range
	DATE_RANGE = jet.DateRange
	// NUM_RANGE constructor function to create a numeric range
	NUM_RANGE = jet.NumRange
	// TS_RANGE constructor function to create a timestamp range
	TS_RANGE = jet.TsRange
	// TSTZ_RANGE constructor function to create a timestampz range
	TSTZ_RANGE = jet.TstzRange
	// INT4_RANGE constructor function to create a int4 range
	INT4_RANGE = jet.Int4Range
	// INT8_RANGE constructor function to create a int8 range
	INT8_RANGE = jet.Int8Range
)

range constructor functions

View Source
var (
	// NULL is jet equivalent of SQL NULL
	NULL = jet.NULL
	// STAR is jet equivalent of SQL *
	STAR = jet.STAR
	// PLUS_INFINITY is jet equivalent for sql infinity
	PLUS_INFINITY = jet.PLUS_INFINITY
	// MINUS_INFINITY is jet equivalent for sql -infinity
	MINUS_INFINITY = jet.MINUS_INFINITY
)
View Source
var (
	UPDATE        = jet.NewRowLock("UPDATE")
	NO_KEY_UPDATE = jet.NewRowLock("NO KEY UPDATE")
	SHARE         = jet.NewRowLock("SHARE")
	KEY_SHARE     = jet.NewRowLock("KEY SHARE")
)

Row lock types

View Source
var (
	PARTITION_BY = jet.PARTITION_BY
	ORDER_BY     = jet.ORDER_BY
	UNBOUNDED    = int64(math.MaxInt64)
	CURRENT_ROW  = jet.CURRENT_ROW
)

Window function clauses

View Source
var ABSf = jet.ABSf

ABSf calculates absolute value from float expression

View Source
var ABSi = jet.ABSi

ABSi calculates absolute value from int expression

View Source
var AVG = jet.AVG

AVG is aggregate function used to calculate avg value from numeric expression

View Source
var BIT_AND = jet.BIT_AND

BIT_AND is aggregate function used to calculates the bitwise AND of all non-null input values, or null if none.

View Source
var BIT_LENGTH = jet.BIT_LENGTH

BIT_LENGTH returns number of bits in string expression

View Source
var BIT_NOT = jet.BIT_NOT

BIT_NOT inverts every bit in integer expression result

View Source
var BIT_OR = jet.BIT_OR

BIT_OR is aggregate function used to calculates the bitwise OR of all non-null input values, or null if none.

View Source
var BOOL_AND = jet.BOOL_AND

BOOL_AND is aggregate function. Returns true if all input values are true, otherwise false

View Source
var BOOL_OR = jet.BOOL_OR

BOOL_OR is aggregate function. Returns true if at least one input value is true, otherwise false

View Source
var BTRIM = jet.BTRIM

BTRIM removes the longest string consisting only of characters in characters (a space by default) from the start and end of string

View Source
var BoolColumn = jet.BoolColumn

BoolColumn creates named bool column.

View Source
var BoolExp = jet.BoolExp

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.

View Source
var CASE = jet.CASE

CASE create CASE operator with optional list of expressions

View Source
var CBRT = jet.CBRT

CBRT calculates cube root of numeric expression

View Source
var CEIL = jet.CEIL

CEIL calculates ceil of float expression

View Source
var CHAR_LENGTH = jet.CHAR_LENGTH

CHAR_LENGTH returns number of characters in string expression

View Source
var CHR = jet.CHR

CHR returns character with the given code.

View Source
var COALESCE = jet.COALESCE

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

View Source
var CONCAT = func(expressions ...Expression) StringExpression {
	return jet.CONCAT(explicitLiteralCasts(expressions...)...)
}

CONCAT adds two or more expressions together

View Source
var CONVERT = jet.CONVERT

CONVERT converts string to dest_encoding. The original encoding is specified by src_encoding. The string must be valid in this encoding.

View Source
var CONVERT_FROM = jet.CONVERT_FROM

CONVERT_FROM converts string to the database encoding. The original encoding is specified by src_encoding. The string must be valid in this encoding.

View Source
var CONVERT_TO = jet.CONVERT_TO

CONVERT_TO converts string to dest_encoding.

View Source
var COUNT = jet.COUNT

COUNT is aggregate function. Returns number of input rows for which the value of expression is not null.

View Source
var CUBE = jet.CUBE

CUBE operator is used with the GROUP BY clause to generate subtotals for all possible combinations of a group of columns. It creates extra rows in the result set that represent the subtotal values for each combination of columns.

View Source
var CUME_DIST = jet.CUME_DIST

CUME_DIST calculates cumulative distribution: (number of partition rows preceding or peer with current row) / total partition rows

View Source
var CURRENT_DATE = jet.CURRENT_DATE

CURRENT_DATE returns current date

View Source
var CURRENT_TIME = jet.CURRENT_TIME

CURRENT_TIME returns current time with time zone

View Source
var CURRENT_TIMESTAMP = jet.CURRENT_TIMESTAMP

CURRENT_TIMESTAMP returns current timestamp with time zone

View Source
var DECODE = jet.DECODE

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

View Source
var DENSE_RANK = jet.DENSE_RANK

DENSE_RANK returns rank of the current row without gaps; this function counts peer groups

View Source
var DISTINCT = jet.DISTINCT

DISTINCT operator can be used to return distinct values of expr

View Source
var DateColumn = jet.DateColumn

DateColumn creates named date column.

View Source
var DateExp = jet.DateExp

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.

View Source
var DateRangeColumn = jet.RangeColumn[DateExpression]

DateRangeColumn creates named range with range column

View Source
var Decimal = jet.Decimal

Decimal creates new float literal expression

View Source
var Dialect = newDialect()

Dialect is implementation of postgres dialect for SQL Builder serialisation.

View Source
var ENCODE = jet.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.

View Source
var EVERY = jet.EVERY

EVERY is aggregate function. Returns true if all input values are true, otherwise false

View Source
var EXISTS = jet.EXISTS

EXISTS checks for existence of the rows in subQuery

View Source
var FIRST_VALUE = jet.FIRST_VALUE

FIRST_VALUE returns value evaluated at the row that is the first row of the window frame

View Source
var FLOOR = jet.FLOOR

FLOOR calculates floor of float expression

View Source
var Float = jet.Float

Float creates new float literal expression

View Source
var FloatColumn = jet.FloatColumn

FloatColumn creates named float column.

View Source
var FloatExp = jet.FloatExp

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.

View Source
var Func = jet.Func

Func can be used to call custom or unsupported database functions.

View Source
var GREATEST = jet.GREATEST

GREATEST selects the largest value from a list of expressions

View Source
var GROUPING = jet.GROUPING

GROUPING function is used to identify which columns are included in a grouping set or a subtotal row. It takes as input the name of a column and returns 1 if the column is not included in the current grouping set, and 0 otherwise. It can be also used with multiple parameters to check if a set of columns is included in the current grouping set. The result of the GROUPING function would then be an integer bit mask having 1’s for the arguments which have GROUPING(argument) as 1.

View Source
var GROUPING_SETS = jet.GROUPING_SETS

GROUPING_SETS operator allows grouping of the rows in a table by multiple sets of columns(or expressions) in a single query. This can be useful when we want to analyze data by different combinations of columns, without having to write separate queries for each combination. GROUPING_SETS sets of columns are constructed with WRAP method.

GROUPING_SETS(
	WRAP(Inventory.FilmID, Inventory.StoreID),
	WRAP(),
),
View Source
var INITCAP = jet.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.

View Source
var Int = jet.Int

Int is constructor for 64 bit signed integer expressions literals.

View Source
var Int4RangeColumn = jet.RangeColumn[jet.Int4Expression]

Int4RangeColumn creates named range with range column

View Source
var Int8RangeColumn = jet.RangeColumn[jet.Int8Expression]

Int8RangeColumn creates named range with range column

View Source
var IntExp = jet.IntExp

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.

View Source
var IntegerColumn = jet.IntegerColumn

IntegerColumn creates named integer column.

View Source
var LAG = jet.LAG

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

View Source
var LAST_VALUE = jet.LAST_VALUE

LAST_VALUE returns value evaluated at the row that is the last row of the window frame

View Source
var LEAD = jet.LEAD

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

View Source
var LEAST = jet.LEAST

LEAST selects the smallest value from a list of expressions

View Source
var LEFT = jet.LEFT

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

View Source
var LENGTH = jet.LENGTH

LENGTH returns number of characters in string with a given encoding

View Source
var LN = jet.LN

LN calculates natural algorithm of float expression

View Source
var LOCALTIME = jet.LOCALTIME

LOCALTIME returns local time of day using optional precision

View Source
var LOCALTIMESTAMP = jet.LOCALTIMESTAMP

LOCALTIMESTAMP returns current date and time using optional precision

View Source
var LOG = jet.LOG

LOG calculates logarithm of float expression

View Source
var LOWER = jet.LOWER

LOWER returns string expression in lower case

View Source
var LPAD = jet.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).

View Source
var LTRIM = jet.LTRIM

LTRIM removes the longest string containing only characters from characters (a space by default) from the start of string

View Source
var MAX = jet.MAX

MAX is aggregate function. Returns maximum value of expression across all input values

View Source
var MAXf = jet.MAXf

MAXf is aggregate function. Returns maximum value of float expression across all input values

View Source
var MAXi = jet.MAXi

MAXi is aggregate function. Returns maximum value of int expression across all input values

View Source
var MD5 = jet.MD5

MD5 calculates the MD5 hash of string, returning the result in hexadecimal

View Source
var MIN = jet.MIN

MIN is aggregate function. Returns minimum value of expression across all input values.

View Source
var MINf = jet.MINf

MINf is aggregate function. Returns minimum value of float expression across all input values

View Source
var MINi = jet.MINi

MINi is aggregate function. Returns minimum value of int expression across all input values

View Source
var MODE = jet.MODE

MODE computes the most frequent value of the aggregated argument

View Source
var NOT = jet.NOT

NOT returns negation of bool expression result

View Source
var NOW = jet.NOW

NOW returns current date and time

View Source
var NTH_VALUE = jet.NTH_VALUE

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

View Source
var NTILE = jet.NTILE

NTILE returns integer ranging from 1 to the argument value, dividing the partition as equally as possible

View Source
var NULLIF = jet.NULLIF

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

View Source
var NewEnumValue = jet.NewEnumValue

NewEnumValue creates new named enum value

View Source
var NumericRangeColumn = jet.RangeColumn[NumericExpression]

NumericRangeColumn creates named range with range column

View Source
var OCTET_LENGTH = jet.OCTET_LENGTH

OCTET_LENGTH returns number of bytes in string expression

View Source
var PERCENT_RANK = jet.PERCENT_RANK

PERCENT_RANK calculates relative rank of the current row: (rank - 1) / (total partition rows - 1)

View Source
var POW = jet.POW

POW calculates power of base with exponent

View Source
var POWER = jet.POWER

POWER calculates power of base with exponent

View Source
var RANK = jet.RANK

RANK of the current row with gaps; same as row_number of its first peer

View Source
var REPEAT = jet.REPEAT

REPEAT repeats string the specified number of times

View Source
var REPLACE = jet.REPLACE

REPLACE replaces all occurrences in string of substring from with substring to

View Source
var REVERSE = jet.REVERSE

REVERSE returns reversed string.

View Source
var RIGHT = jet.RIGHT

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

View Source
var ROLLUP = jet.ROLLUP

ROLLUP operator is used with the GROUP BY clause to generate all prefixes of a group of columns including the empty list. It creates extra rows in the result set that represent the subtotal values for each combination of columns.

View Source
var ROUND = jet.ROUND

ROUND calculates round of a float expressions with optional precision

View Source
var ROW = jet.ROW

ROW function is used to create a tuple value that consists of a set of expressions or column values.

View Source
var ROW_NUMBER = jet.ROW_NUMBER

ROW_NUMBER returns number of the current row within its partition, counting from 1

View Source
var RPAD = jet.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.

View Source
var RTRIM = jet.RTRIM

RTRIM removes the longest string containing only characters from characters (a space by default) from the end of string

View Source
var SIGN = jet.SIGN

SIGN returns sign of float expression

View Source
var SQRT = jet.SQRT

SQRT calculates square root of numeric expression

View Source
var STRPOS = jet.STRPOS

STRPOS returns location of specified substring (same as position(substring in string), but note the reversed argument order)

View Source
var SUBSTR = jet.SUBSTR

SUBSTR extracts substring

View Source
var SUM = jet.SUM

SUM is aggregate function. Returns sum of all expressions

View Source
var SUMf = jet.SUMf

SUMf is aggregate function. Returns sum of expression across all float expressions

View Source
var SUMi = jet.SUMi

SUMi is aggregate function. Returns sum of expression across all integer expression.

View Source
var SetLogger = jet.SetLoggerFunc

SetLogger sets automatic statement logging function Deprecated: use SetQueryLogger instead.

View Source
var SetQueryLogger = jet.SetQueryLogger

SetQueryLogger sets automatic query logging function.

View Source
var StringColumn = jet.StringColumn

StringColumn creates named string column.

View Source
var StringExp = jet.StringExp

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.

View Source
var TO_ASCII = jet.TO_ASCII

TO_ASCII convert string to ASCII from another encoding

View Source
var TO_CHAR = jet.TO_CHAR

TO_CHAR converts expression to string with format

View Source
var TO_DATE = jet.TO_DATE

TO_DATE converts string to date using format

View Source
var TO_HEX = jet.TO_HEX

TO_HEX converts number to its equivalent hexadecimal representation

View Source
var TO_NUMBER = jet.TO_NUMBER

TO_NUMBER converts string to numeric using format

View Source
var TO_TIMESTAMP = jet.TO_TIMESTAMP

TO_TIMESTAMP converts string to time stamp with time zone using format

View Source
var TRUNC = jet.TRUNC

TRUNC calculates trunc of float expression with optional precision

View Source
var TimeColumn = jet.TimeColumn

TimeColumn creates named time column

View Source
var TimeExp = jet.TimeExp

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.

View Source
var TimestampColumn = jet.TimestampColumn

TimestampColumn creates named timestamp column

View Source
var TimestampExp = jet.TimestampExp

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.

View Source
var TimestampRangeColumn = jet.RangeColumn[TimestampExpression]

TimestampRangeColumn creates named range with range column

View Source
var TimestampzColumn = jet.TimestampzColumn

TimestampzColumn creates named timestamp with time zone column.

View Source
var TimestampzExp = jet.TimestampzExp

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.

View Source
var TimestampzRangeColumn = jet.RangeColumn[TimestampzExpression]

TimestampzRangeColumn creates named range with range column

View Source
var TimezColumn = jet.TimezColumn

TimezColumn creates named time with time zone column.

View Source
var TimezExp = jet.TimezExp

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.

View Source
var UPPER = jet.UPPER

UPPER returns string expression in upper case

View Source
var UUID = jet.UUID

UUID is a helper function to create string literal expression from uuid object value can be any uuid type with a String method

View Source
var WRAP = jet.WRAP

WRAP wraps list of expressions with brackets - ( expression1, expression2, ... ) The construct (a, b) is normally recognized in expressions as a row constructor. WRAP and ROW method behave exactly the same, except when used in GROUPING_SETS. For top level GROUPING SETS expression lists WRAP has to be used.

View Source
var Window = jet.WindowName

Window definition reference

Functions

func CAST

func CAST(expr Expression) cast

CAST function converts a expr (of any type) into latter specified datatype.

func EXCEPT

func EXCEPT(lhs, rhs jet.SerializerStatement) setStatement

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 jet.SerializerStatement) setStatement

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 FOLLOWING

func FOLLOWING(offset int64) jet.FrameExtent

FOLLOWING window frame clause

func INTERSECT

func INTERSECT(lhs, rhs jet.SerializerStatement, selects ...jet.SerializerStatement) setStatement

INTERSECT returns all rows that are in query results. It eliminates duplicate rows from its result.

func INTERSECT_ALL

func INTERSECT_ALL(lhs, rhs jet.SerializerStatement, selects ...jet.SerializerStatement) setStatement

INTERSECT_ALL returns all rows that are in query results. It does not eliminates duplicate rows from its result.

func LATERAL added in v2.5.0

func LATERAL(selectStmt SelectStatement) lateralImpl

LATERAL derived tables constructor from select statement

func LOWER_BOUND added in v2.11.0

func LOWER_BOUND[T Expression](expression jet.Range[T]) T

LOWER_BOUND returns range expressions lower bound

func PERCENTILE_CONT added in v2.7.0

func PERCENTILE_CONT(fraction FloatExpression) *jet.OrderSetAggregateFunc

PERCENTILE_CONT computes a value corresponding to the specified fraction within the ordered set of aggregated argument values. This will interpolate between adjacent input items if needed.

func PERCENTILE_DISC added in v2.7.0

func PERCENTILE_DISC(fraction FloatExpression) *jet.OrderSetAggregateFunc

PERCENTILE_DISC computes the first value within the ordered set of aggregated argument values whose position in the ordering equals or exceeds the specified fraction. The aggregated argument must be of a sortable type.

func PRECEDING

func PRECEDING(offset int64) jet.FrameExtent

PRECEDING window frame clause

func SET

func SET(assigments ...ColumnAssigment) conflictAction

SET creates conflict action for ON_CONFLICT clause

func UNION

func UNION(lhs, rhs jet.SerializerStatement, selects ...jet.SerializerStatement) setStatement

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 jet.SerializerStatement, selects ...jet.SerializerStatement) setStatement

UNION_ALL effectively appends the result of sub-queries(select statements) into single query. It does not eliminates duplicate rows from its result.

func UPPER_BOUND added in v2.11.0

func UPPER_BOUND[T Expression](expression jet.Range[T]) T

UPPER_BOUND returns range expressions upper bound

func WITH

func WITH(cte ...CommonTableExpression) func(statement jet.Statement) Statement

WITH function creates new WITH statement from list of common table expressions

func WITH_RECURSIVE added in v2.7.0

func WITH_RECURSIVE(cte ...CommonTableExpression) func(statement jet.Statement) Statement

WITH_RECURSIVE function creates new WITH RECURSIVE statement from list of common table expressions

Types

type BoolExpression

type BoolExpression = jet.BoolExpression

BoolExpression interface

func Bool

func Bool(value bool) BoolExpression

Bool is boolean literal constructor

type Column

type Column = jet.ColumnExpression

Column is common column interface for all types of columns.

type ColumnAssigment

type ColumnAssigment = jet.ColumnAssigment

ColumnAssigment is interface wrapper around column assigment

type ColumnBool

type ColumnBool = jet.ColumnBool

ColumnBool is interface for SQL boolean columns.

type ColumnDate

type ColumnDate = jet.ColumnDate

ColumnDate is interface of SQL date columns.

type ColumnDateRange added in v2.11.0

type ColumnDateRange = jet.ColumnRange[DateExpression]

ColumnDateRange is interface of SQL date range column

type ColumnFloat

type ColumnFloat = jet.ColumnFloat

ColumnFloat is interface for SQL real, numeric, decimal or double precision column.

type ColumnInt4Range added in v2.11.0

type ColumnInt4Range jet.ColumnRange[jet.Int4Expression]

ColumnInt4Range is interface of SQL int4 range column

type ColumnInt8Range added in v2.11.0

type ColumnInt8Range jet.ColumnRange[jet.Int8Expression]

ColumnInt8Range is interface of SQL int8 range column

type ColumnInteger

type ColumnInteger = jet.ColumnInteger

ColumnInteger is interface for SQL smallint, integer, bigint columns.

type ColumnInterval

type ColumnInterval interface {
	IntervalExpression
	jet.Column

	From(subQuery SelectTable) ColumnInterval
}

ColumnInterval is interface of PostgreSQL interval columns.

func IntervalColumn

func IntervalColumn(name string) ColumnInterval

IntervalColumn creates named interval column.

type ColumnList

type ColumnList = jet.ColumnList

ColumnList function returns list of columns that be used as projection or column list for UPDATE and INSERT statement.

type ColumnNumericRange added in v2.11.0

type ColumnNumericRange = jet.ColumnRange[NumericExpression]

ColumnNumericRange is interface of SQL numeric range column

type ColumnString

type ColumnString = jet.ColumnString

ColumnString is interface for SQL text, character, character varying bytea, uuid columns and enums types.

type ColumnTime

type ColumnTime = jet.ColumnTime

ColumnTime is interface for SQL time column.

type ColumnTimestamp

type ColumnTimestamp = jet.ColumnTimestamp

ColumnTimestamp is interface of SQL timestamp columns.

type ColumnTimestampRange added in v2.11.0

type ColumnTimestampRange = jet.ColumnRange[TimestampExpression]

ColumnTimestampRange is interface of SQL timestamp range column

type ColumnTimestampz

type ColumnTimestampz = jet.ColumnTimestampz

ColumnTimestampz is interface of SQL timestamp with timezone columns.

type ColumnTimestampzRange added in v2.11.0

type ColumnTimestampzRange = jet.ColumnRange[TimestampzExpression]

ColumnTimestampzRange is interface of SQL timestamp range column

type ColumnTimez

type ColumnTimez = jet.ColumnTimez

ColumnTimez is interface of SQL time with time zone columns.

type CommonTableExpression

type CommonTableExpression interface {
	SelectTable

	AS(statement jet.SerializerStatement) CommonTableExpression
	AS_NOT_MATERIALIZED(statement jet.SerializerStatement) CommonTableExpression
	// ALIAS is used to create another alias of the CTE, if a CTE needs to appear multiple times in the main query.
	ALIAS(alias string) SelectTable
	// contains filtered or unexported methods
}

CommonTableExpression defines set of interface methods for postgres CTEs

func CTE

func CTE(name string, columns ...jet.ColumnExpression) CommonTableExpression

CTE creates new named commonTableExpression

type DateExpression

type DateExpression = jet.DateExpression

DateExpression is interface for date types

func Date

func Date(year int, month time.Month, day int) DateExpression

Date creates new date literal expression

func DateT

func DateT(t time.Time) DateExpression

DateT creates new date literal expression from time.Time object

type DateRange added in v2.11.0

type DateRange = jet.Range[DateExpression]

DateRange Expression interface

type DeleteStatement

type DeleteStatement interface {
	jet.SerializerStatement

	USING(tables ...ReadableTable) DeleteStatement
	WHERE(expression BoolExpression) DeleteStatement
	RETURNING(projections ...jet.Projection) DeleteStatement
}

DeleteStatement is interface for PostgreSQL DELETE statement

type Expression

type Expression = jet.Expression

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

type FloatExpression

type FloatExpression = jet.FloatExpression

FloatExpression is interface

func EXTRACT added in v2.8.0

func EXTRACT(field unit, from Expression) FloatExpression

EXTRACT function retrieves subfields such as year or hour from date/time values

EXTRACT(DAY, User.CreatedAt)

type GroupByClause added in v2.6.0

type GroupByClause = jet.GroupByClause

GroupByClause interface to use as input for GROUP_BY

type InsertStatement

type InsertStatement interface {
	jet.SerializerStatement

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

	ON_CONFLICT(indexExpressions ...jet.ColumnExpression) onConflict

	RETURNING(projections ...Projection) InsertStatement
}

InsertStatement is interface for SQL INSERT statements

type Int4Range added in v2.11.0

type Int4Range = jet.Range[IntegerExpression]

Int4Range Expression interface

type Int8Range added in v2.11.0

type Int8Range = jet.Range[IntegerExpression]

Int8Range Expression interface

type IntegerExpression

type IntegerExpression = jet.IntegerExpression

IntegerExpression interface

func Int16 added in v2.5.0

func Int16(value int16) IntegerExpression

Int16 is constructor for 16 bit signed integer expressions literals.

func Int32 added in v2.5.0

func Int32(value int32) IntegerExpression

Int32 is constructor for 32 bit signed integer expressions literals.

func Int64 added in v2.5.0

func Int64(value int64) IntegerExpression

Int64 is constructor for 64 bit signed integer expressions literals.

func Int8 added in v2.5.0

func Int8(value int8) IntegerExpression

Int8 is constructor for 8 bit signed integer expressions literals.

func Uint16 added in v2.5.0

func Uint16(value uint16) IntegerExpression

Uint16 is constructor for 16 bit unsigned integer expressions literals.

func Uint32 added in v2.5.0

func Uint32(value uint32) IntegerExpression

Uint32 is constructor for 32 bit unsigned integer expressions literals.

func Uint64 added in v2.5.0

func Uint64(value uint64) IntegerExpression

Uint64 is constructor for 64 bit unsigned integer expressions literals.

func Uint8 added in v2.5.0

func Uint8(value uint8) IntegerExpression

Uint8 is constructor for 8 bit unsigned integer expressions literals.

type IntervalExpression

IntervalExpression is representation of postgres INTERVAL

func INTERVAL

func INTERVAL(quantityAndUnit ...quantityAndUnit) IntervalExpression

INTERVAL creates new interval expression from the list of quantity-unit pairs.

INTERVAL(1, DAY, 3, MINUTE)

func INTERVALd

func INTERVALd(duration time.Duration) IntervalExpression

INTERVALd creates interval expression from time.Duration

func IntervalExp

func IntervalExp(expression Expression) IntervalExpression

IntervalExp is interval expression wrapper around arbitrary expression. Allows go compiler to see any expression as interval expression. Does not add sql cast to generated sql builder output.

type LockStatement

type LockStatement interface {
	Statement

	IN(lockMode TableLockMode) LockStatement
	NOWAIT() LockStatement
}

LockStatement is interface for MySQL LOCK tables

func LOCK

func LOCK(tables ...jet.SerializerTable) LockStatement

LOCK creates LockStatement from list of tables

type NumericExpression

type NumericExpression = jet.NumericExpression

NumericExpression interface

type NumericRange added in v2.11.0

type NumericRange = jet.Range[NumericExpression]

NumericRange Expression interface

type OrderByClause added in v2.5.0

type OrderByClause = jet.OrderByClause

OrderByClause is the combination of an expression and the wanted ordering to use as input for ORDER BY.

type PrintableStatement

type PrintableStatement = jet.PrintableStatement

PrintableStatement is a statement which sql query can be logged

type Projection

type Projection = jet.Projection

Projection is interface for all projection types. Types that can be part of, for instance SELECT clause.

type ProjectionList

type ProjectionList = jet.ProjectionList

ProjectionList can be used to create conditional constructed projection list.

type QueryInfo added in v2.7.0

type QueryInfo = jet.QueryInfo

QueryInfo contains information about executed query

type RawArgs added in v2.5.0

type RawArgs = map[string]interface{}

RawArgs is type used to pass optional arguments to Raw method

type ReadableTable

type ReadableTable interface {
	jet.Serializer
	// contains filtered or unexported methods
}

ReadableTable interface

type RowLock

type RowLock = jet.RowLock

RowLock is interface for SELECT statement row lock types

type Rows added in v2.10.1

type Rows = jet.Rows

Rows wraps sql.Rows type with a support for query result mapping

type SelectStatement

type SelectStatement interface {
	Statement
	jet.HasProjections
	Expression

	DISTINCT(on ...jet.ColumnExpression) SelectStatement
	FROM(tables ...ReadableTable) SelectStatement
	WHERE(expression BoolExpression) SelectStatement
	GROUP_BY(groupByClauses ...GroupByClause) SelectStatement
	HAVING(boolExpression BoolExpression) SelectStatement
	WINDOW(name string) windowExpand
	ORDER_BY(orderByClauses ...OrderByClause) SelectStatement
	LIMIT(limit int64) SelectStatement
	OFFSET(offset int64) SelectStatement
	// OFFSET_e can be used when an integer expression is needed as offset, otherwise OFFSET can be used
	OFFSET_e(offset IntegerExpression) SelectStatement
	FETCH_FIRST(count IntegerExpression) fetchExpand
	FOR(lock RowLock) SelectStatement

	UNION(rhs SelectStatement) setStatement
	UNION_ALL(rhs SelectStatement) setStatement
	INTERSECT(rhs SelectStatement) setStatement
	INTERSECT_ALL(rhs SelectStatement) setStatement
	EXCEPT(rhs SelectStatement) setStatement
	EXCEPT_ALL(rhs SelectStatement) setStatement

	AsTable(alias string) SelectTable
}

SelectStatement is interface for PostgreSQL SELECT statement

func SELECT

func SELECT(projection Projection, projections ...Projection) SelectStatement

SELECT creates new SelectStatement with list of projections

type SelectTable

type SelectTable interface {
	jet.SelectTable
	// contains filtered or unexported methods
}

SelectTable is interface for postgres sub-queries

type Statement

type Statement = jet.Statement

Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK)

func RawStatement added in v2.5.0

func RawStatement(rawQuery string, namedArguments ...RawArgs) Statement

RawStatement creates new sql statements from raw query and optional map of named arguments

type StringExpression

type StringExpression = jet.StringExpression

StringExpression interface

func Bytea

func Bytea(value interface{}) StringExpression

Bytea creates new bytea literal expression

func CONCAT_WS

func CONCAT_WS(separator Expression, expressions ...Expression) StringExpression

CONCAT_WS adds two or more expressions together with a separator.

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 Json added in v2.9.0

func Json(value interface{}) StringExpression

Json creates new json literal expression

func String

func String(value string) StringExpression

String creates new string literal expression

type Table

type Table interface {
	jet.SerializerTable
	// contains filtered or unexported methods
}

Table is interface for MySQL tables

func NewTable

func NewTable(schemaName, name, alias string, columns ...jet.ColumnExpression) Table

NewTable creates new table with schema Name, table Name and list of columns

type TableLockMode

type TableLockMode string

TableLockMode is a type of possible SQL table lock

const (
	LOCK_ACCESS_SHARE           TableLockMode = "ACCESS SHARE"
	LOCK_ROW_SHARE              TableLockMode = "ROW SHARE"
	LOCK_ROW_EXCLUSIVE          TableLockMode = "ROW EXCLUSIVE"
	LOCK_SHARE_UPDATE_EXCLUSIVE TableLockMode = "SHARE UPDATE EXCLUSIVE"
	LOCK_SHARE                  TableLockMode = "SHARE"
	LOCK_SHARE_ROW_EXCLUSIVE    TableLockMode = "SHARE ROW EXCLUSIVE"
	LOCK_EXCLUSIVE              TableLockMode = "EXCLUSIVE"
	LOCK_ACCESS_EXCLUSIVE       TableLockMode = "ACCESS EXCLUSIVE"
)

Lock types for LockStatement.

type TimeExpression

type TimeExpression = jet.TimeExpression

TimeExpression interface

func Time

func Time(hour, minute, second int, nanoseconds ...time.Duration) TimeExpression

Time creates new time literal expression

func TimeT

func TimeT(t time.Time) TimeExpression

TimeT creates new time literal expression from time.Time object

type TimestampExpression

type TimestampExpression = jet.TimestampExpression

TimestampExpression interface

func Timestamp

func Timestamp(year int, month time.Month, day, hour, minute, second int, milliseconds ...time.Duration) TimestampExpression

Timestamp creates new timestamp literal expression

func TimestampT

func TimestampT(t time.Time) TimestampExpression

TimestampT creates new timestamp literal expression from time.Time object

type TimestampRange added in v2.11.0

type TimestampRange = jet.Range[TimestampExpression]

TimestampRange Expression interface

type TimestampzExpression

type TimestampzExpression = jet.TimestampzExpression

TimestampzExpression interface

func Timestampz

func Timestampz(year int, month time.Month, day, hour, minute, second int, milliseconds time.Duration, timezone string) TimestampzExpression

Timestampz creates new timestamp with time zone literal expression

func TimestampzT

func TimestampzT(t time.Time) TimestampzExpression

TimestampzT creates new timestamp literal expression from time.Time object

type TimestampzRange added in v2.11.0

type TimestampzRange = jet.Range[TimestampzExpression]

TimestampzRange Expression interface

type TimezExpression

type TimezExpression = jet.TimezExpression

TimezExpression interface for 'time with time zone' types

func Timez

func Timez(hour, minute, second int, milliseconds time.Duration, timezone string) TimezExpression

Timez creates new time with time zone literal expression

func TimezT

func TimezT(t time.Time) TimezExpression

TimezT creates new time with time zone literal expression from time.Time object

type UpdateStatement

type UpdateStatement interface {
	jet.SerializerStatement

	SET(value interface{}, values ...interface{}) UpdateStatement
	MODEL(data interface{}) UpdateStatement

	FROM(tables ...ReadableTable) UpdateStatement
	WHERE(expression BoolExpression) UpdateStatement
	RETURNING(projections ...Projection) UpdateStatement
}

UpdateStatement is interface of SQL UPDATE statement

type WritableTable

type WritableTable interface {
	jet.Table

	jet.Serializer
	// contains filtered or unexported methods
}

WritableTable interface

Jump to

Keyboard shortcuts

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