mysql

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: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MICROSECOND        unitType = "MICROSECOND"
	SECOND                      = "SECOND"
	MINUTE                      = "MINUTE"
	HOUR                        = "HOUR"
	DAY                         = "DAY"
	WEEK                        = "WEEK"
	MONTH                       = "MONTH"
	QUARTER                     = "QUARTER"
	YEAR                        = "YEAR"
	SECOND_MICROSECOND          = "SECOND_MICROSECOND"
	MINUTE_MICROSECOND          = "MINUTE_MICROSECOND"
	MINUTE_SECOND               = "MINUTE_SECOND"
	HOUR_MICROSECOND            = "HOUR_MICROSECOND"
	HOUR_SECOND                 = "HOUR_SECOND"
	HOUR_MINUTE                 = "HOUR_MINUTE"
	DAY_MICROSECOND             = "DAY_MICROSECOND"
	DAY_SECOND                  = "DAY_SECOND"
	DAY_MINUTE                  = "DAY_MINUTE"
	DAY_HOUR                    = "DAY_HOUR"
	YEAR_MONTH                  = "YEAR_MONTH"
)

List of interval unit types for MySQL

Variables

View Source
var (
	STAR    = jet.STAR
	NULL    = jet.NULL
	DEFAULT = jet.DEFAULT
)

Keywords

View Source
var (
	UPDATE = jet.NewRowLock("UPDATE")
	SHARE  = jet.NewRowLock("SHARE")
)

Row lock types

View Source
var (
	PARTITION_BY = jet.PARTITION_BY
	ORDER_BY     = jet.ORDER_BY
	UNBOUNDED    = jet.UNBOUNDED
	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

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 = jet.Bool

Bool creates new bool literal expression

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 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 CONCAT = jet.CONCAT

CONCAT adds two or more expressions together

View Source
var CONCAT_WS = jet.CONCAT_WS

CONCAT_WS adds two or more expressions together with a separator.

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 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 DENSE_RANK = jet.DENSE_RANK

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

View Source
var Date = func(year int, month time.Month, day int) DateExpression {
	return CAST(jet.Date(year, month, day)).AS_DATE()
}

Date creates new date literal

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 DateT = func(t time.Time) DateExpression {
	return CAST(jet.DateT(t)).AS_DATE()
}

DateT creates new date literal from time.Time

View Source
var DateTime = func(year int, month time.Month, day, hour, minute, second int, nanoseconds ...time.Duration) DateTimeExpression {
	return CAST(jet.Timestamp(year, month, day, hour, minute, second, nanoseconds...)).AS_DATETIME()
}

DateTime creates new datetime literal

View Source
var DateTimeColumn = jet.TimestampColumn

DateTimeColumn creates named timestamp column

View Source
var DateTimeExp = jet.TimestampExp

DateTimeExp 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 DateTimeT = func(t time.Time) DateTimeExpression {
	return CAST(jet.TimestampT(t)).AS_DATETIME()
}

DateTimeT creates new datetime literal from time.Time

View Source
var Dialect = newDialect()

Dialect is implementation of MySQL dialect for SQL Builder serialisation.

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 FORMAT = jet.FORMAT

FORMAT formats a number to a format like "#,###,###.##", rounded to a specified number of decimal places, then it returns the result as a string.

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 Int = jet.Int

Int is constructor for integer expressions literals.

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 LEFT = jet.LEFT

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

View Source
var LN = jet.LN

LN calculates natural algorithm of float expression

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 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 int 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 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 NewEnumValue = jet.NewEnumValue

NewEnumValue creates new named enum value

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 REGEXP_LIKE = jet.REGEXP_LIKE

REGEXP_LIKE Returns 1 if the string expr matches the regular expression specified by the pattern pat, 0 otherwise.

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 ROUND = jet.ROUND

ROUND calculates round of a float expressions with optional precision

View Source
var ROW = jet.ROW

ROW is construct one table row from list of expressions.

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 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 Raw = jet.Raw

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

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 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 float expression.

View Source
var SUMi = jet.SUMi

SUMi is aggregate function. Returns sum of integer expression.

View Source
var SetLogger = jet.SetLoggerFunc

SetLogger sets automatic statement logging

View Source
var String = jet.String

String creates new string literal expression

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 TRUNC = TRUNCATE

TRUNC calculates trunc of float expression with precision

View Source
var TRUNCATE = func(floatExpression jet.FloatExpression, precision jet.IntegerExpression) jet.FloatExpression {
	return jet.NewFloatFunc("TRUNCATE", floatExpression, precision)
}

TRUNCATE calculates trunc of float expression with precision

View Source
var Time = func(hour, minute, second int, nanoseconds ...time.Duration) TimeExpression {
	return CAST(jet.Time(hour, minute, second, nanoseconds...)).AS_TIME()
}

Time creates new time literal

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 TimeT = func(t time.Time) TimeExpression {
	return CAST(jet.TimeT(t)).AS_TIME()
}

TimeT creates new time literal from time.Time

View Source
var Timestamp = func(year int, month time.Month, day, hour, minute, second int, nanoseconds ...time.Duration) TimestampExpression {
	return TIMESTAMP(StringExp(jet.Timestamp(year, month, day, hour, minute, second, nanoseconds...)))
}

Timestamp creates new timestamp literal

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 TimestampT = func(t time.Time) TimestampExpression {
	return TIMESTAMP(StringExp(jet.TimestampT(t)))
}

TimestampT creates new timestamp literal from time.Time

View Source
var UPPER = jet.UPPER

UPPER returns string expression in upper case

View Source
var Window = jet.WindowName

Window is used to specify window reference from WINDOW clause

Functions

func CAST

func CAST(expr Expression) cast

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

func CBRT

CBRT calculates cube root of numeric expression

func FOLLOWING

func FOLLOWING(offset interface{}) jet.FrameExtent

FOLLOWING window frame clause

func LENGTH

LENGTH returns number of characters in string with a given encoding

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 PRECEDING

func PRECEDING(offset interface{}) jet.FrameExtent

PRECEDING window frame clause

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

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

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

Types

type BoolExpression

type BoolExpression = jet.BoolExpression

BoolExpression interface

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 ColumnDateTime

type ColumnDateTime = jet.ColumnTimestamp

ColumnDateTime is interface of SQL timestamp columns.

type ColumnFloat

type ColumnFloat = jet.ColumnFloat

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

type ColumnInteger

type ColumnInteger = jet.ColumnInteger

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

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

type CommonTableExpression struct {
	jet.CommonTableExpression
	// 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) CROSS_JOIN

func (r CommonTableExpression) CROSS_JOIN(table ReadableTable) joinSelectUpdateTable

func (CommonTableExpression) FULL_JOIN

func (r CommonTableExpression) FULL_JOIN(table ReadableTable, onCondition BoolExpression) joinSelectUpdateTable

func (CommonTableExpression) INNER_JOIN

func (r CommonTableExpression) INNER_JOIN(table ReadableTable, onCondition BoolExpression) joinSelectUpdateTable

Creates a inner join tableName Expression using onCondition.

func (CommonTableExpression) LEFT_JOIN

func (r CommonTableExpression) LEFT_JOIN(table ReadableTable, onCondition BoolExpression) joinSelectUpdateTable

Creates a left join tableName Expression using onCondition.

func (CommonTableExpression) RIGHT_JOIN

func (r CommonTableExpression) RIGHT_JOIN(table ReadableTable, onCondition BoolExpression) joinSelectUpdateTable

Creates a right join tableName Expression using onCondition.

func (CommonTableExpression) SELECT

func (r CommonTableExpression) SELECT(projection1 Projection, projections ...Projection) SelectStatement

Generates a select query on the current tableName.

type DateExpression

type DateExpression = jet.DateExpression

DateExpression interface

type DateTimeExpression

type DateTimeExpression = jet.TimestampExpression

DateTimeExpression interface

func NOW

func NOW(fsp ...int) DateTimeExpression

NOW returns current datetime

type DeleteStatement

type DeleteStatement interface {
	Statement

	WHERE(expression BoolExpression) DeleteStatement
	ORDER_BY(orderByClauses ...jet.OrderByClause) DeleteStatement
	LIMIT(limit int64) DeleteStatement
}

DeleteStatement is interface for MySQL 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 interface

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

	ON_DUPLICATE_KEY_UPDATE(assigments ...ColumnAssigment) InsertStatement

	QUERY(selectStatement SelectStatement) InsertStatement
}

InsertStatement is interface for SQL INSERT statements

type IntegerExpression

type IntegerExpression = jet.IntegerExpression

IntegerExpression interface

type Interval

type Interval = jet.Interval

Interval is representation of MySQL interval

func INTERVAL

func INTERVAL(value interface{}, unitType unitType) Interval

INTERVAL creates new temporal interval. In a case of MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR unit type value parameter should be number. For example: INTERVAL(1, DAY) In a case of other unit types, value should be string with appropriate format. For example: INTERVAL("10:08:50", HOUR_SECOND)

func INTERVALd

func INTERVALd(duration time.Duration) Interval

INTERVALd temoral interval from time.Duration

func INTERVALe

func INTERVALe(expr Expression, unitType unitType) Interval

INTERVALe creates new temporal interval from expresion and unit type.

type LockStatement

type LockStatement interface {
	Statement
	READ() Statement
	WRITE() Statement
}

LockStatement is interface for MySQL LOCK tables

func LOCK

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

LOCK creates LockStatement from list of tables

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

type SelectStatement interface {
	Statement
	jet.HasProjections
	Expression

	DISTINCT() SelectStatement
	FROM(table ReadableTable) SelectStatement
	WHERE(expression BoolExpression) SelectStatement
	GROUP_BY(groupByClauses ...jet.GroupByClause) SelectStatement
	HAVING(boolExpression BoolExpression) SelectStatement
	WINDOW(name string) windowExpand
	ORDER_BY(orderByClauses ...jet.OrderByClause) SelectStatement
	LIMIT(limit int64) SelectStatement
	OFFSET(offset int64) SelectStatement
	FOR(lock RowLock) SelectStatement
	LOCK_IN_SHARE_MODE() SelectStatement

	UNION(rhs SelectStatement) setStatement
	UNION_ALL(rhs SelectStatement) setStatement

	AsTable(alias string) SelectTable
}

SelectStatement is interface for MySQL 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 MySQL sub-queries

type Statement

type Statement = jet.Statement

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

func UNLOCK_TABLES

func UNLOCK_TABLES() Statement

UNLOCK_TABLES explicitly releases any table locks held by the current session

type StringExpression

type StringExpression = jet.StringExpression

StringExpression interface

type Table

type Table interface {
	jet.SerializerTable

	INSERT(columns ...jet.Column) InsertStatement
	UPDATE(columns ...jet.Column) UpdateStatement
	DELETE() DeleteStatement
	LOCK() LockStatement
	// contains filtered or unexported methods
}

Table is interface for MySQL tables

func NewTable

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

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

type TimeExpression

type TimeExpression = jet.TimeExpression

TimeExpression interface

func CURRENT_TIME

func CURRENT_TIME(precision ...int) TimeExpression

CURRENT_TIME returns current time with time zone

type TimestampExpression

type TimestampExpression = jet.TimestampExpression

TimestampExpression interface

func CURRENT_TIMESTAMP

func CURRENT_TIMESTAMP(precision ...int) TimestampExpression

CURRENT_TIMESTAMP returns current timestamp with time zone

func TIMESTAMP

TIMESTAMP return a datetime value based on the arguments:

func UNIX_TIMESTAMP

func UNIX_TIMESTAMP(str StringExpression) TimestampExpression

UNIX_TIMESTAMP returns unix timestamp

type UpdateStatement

type UpdateStatement interface {
	jet.Statement

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

	WHERE(expression BoolExpression) UpdateStatement
}

UpdateStatement is interface of SQL UPDATE statement

Jump to

Keyboard shortcuts

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