Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayValue(value any) driver.Valuer
- func EnumValue(value Enumeration) driver.Valuer
- func EscapeQuote(str string, quote byte) string
- func FetchAll[T any](db DB, query Query, rowmapper func(*Row) T) ([]T, error)
- func FetchAllContext[T any](ctx context.Context, db DB, query Query, rowmapper func(*Row) T) ([]T, error)
- func FetchExists(db DB, query Query) (exists bool, err error)
- func FetchExistsContext(ctx context.Context, db DB, query Query) (exists bool, err error)
- func FetchOne[T any](db DB, query Query, rowmapper func(*Row) T) (T, error)
- func FetchOneContext[T any](ctx context.Context, db DB, query Query, rowmapper func(*Row) T) (T, error)
- func JSONValue(value any) driver.Valuer
- func Log(db DB) interface{ ... }
- func New[T Table](alias string) T
- func QuoteIdentifier(dialect string, identifier string) string
- func SetDefaultLogQuery(logQuery func(context.Context, QueryStats))
- func SetDefaultLogSettings(logSettings func(context.Context, *LogSettings))
- func Sprint(dialect string, v any) (string, error)
- func Sprintf(dialect string, query string, args []any) (string, error)
- func ToSQL(dialect string, w SQLWriter, params map[string][]int) (query string, args []any, err error)
- func ToSQLContext(ctx context.Context, dialect string, w SQLWriter, params map[string][]int) (query string, args []any, err error)
- func UUIDValue(value any) driver.Valuer
- func VerboseLog(db DB) interface{ ... }
- func WriteValue(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- func Writef(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type Any
- type AnyField
- func (field AnyField) As(alias string) AnyField
- func (field AnyField) Asc() AnyField
- func (field AnyField) Desc() AnyField
- func (field AnyField) Eq(value any) Predicate
- func (field AnyField) Expr(format string, values ...any) Expression
- func (field AnyField) Ge(value any) Predicate
- func (field AnyField) GetAlias() string
- func (field AnyField) Gt(value any) Predicate
- func (field AnyField) In(value any) Predicate
- func (field AnyField) IsArray()
- func (field AnyField) IsBinary()
- func (field AnyField) IsBoolean()
- func (field AnyField) IsEnum()
- func (field AnyField) IsField()
- func (field AnyField) IsJSON()
- func (field AnyField) IsNotNull() Predicate
- func (field AnyField) IsNull() Predicate
- func (field AnyField) IsNumber()
- func (field AnyField) IsString()
- func (field AnyField) IsTime()
- func (field AnyField) IsUUID()
- func (field AnyField) Le(value any) Predicate
- func (field AnyField) Lt(value any) Predicate
- func (field AnyField) Ne(value any) Predicate
- func (field AnyField) NotIn(value any) Predicate
- func (field AnyField) NullsFirst() AnyField
- func (field AnyField) NullsLast() AnyField
- func (field AnyField) Set(value any) Assignment
- func (field AnyField) Setf(format string, values ...any) Assignment
- func (field AnyField) WithPrefix(prefix string) Field
- func (field AnyField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type Array
- type ArrayField
- func (field ArrayField) As(alias string) ArrayField
- func (field ArrayField) GetAlias() string
- func (field ArrayField) IsArray()
- func (field ArrayField) IsField()
- func (field ArrayField) IsNotNull() Predicate
- func (field ArrayField) IsNull() Predicate
- func (field ArrayField) Set(value any) Assignment
- func (field ArrayField) SetArray(value any) Assignment
- func (field ArrayField) Setf(format string, values ...any) Assignment
- func (field ArrayField) WithPrefix(prefix string) Field
- func (field ArrayField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type ArrayParameter
- type Assignment
- type Assignments
- type Binary
- type BinaryField
- func (field BinaryField) As(alias string) BinaryField
- func (field BinaryField) Asc() BinaryField
- func (field BinaryField) Desc() BinaryField
- func (field BinaryField) Eq(value Binary) Predicate
- func (field BinaryField) EqBytes(b []byte) Predicate
- func (field BinaryField) GetAlias() string
- func (field BinaryField) IsBinary()
- func (field BinaryField) IsField()
- func (field BinaryField) IsNotNull() Predicate
- func (field BinaryField) IsNull() Predicate
- func (field BinaryField) Ne(value Binary) Predicate
- func (field BinaryField) NeBytes(b []byte) Predicate
- func (field BinaryField) NullsFirst() BinaryField
- func (field BinaryField) NullsLast() BinaryField
- func (field BinaryField) Set(value any) Assignment
- func (field BinaryField) SetBytes(b []byte) Assignment
- func (field BinaryField) Setf(format string, values ...any) Assignment
- func (field BinaryField) WithPrefix(prefix string) Field
- func (field BinaryField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type BinaryParameter
- type Boolean
- type BooleanField
- func (field BooleanField) As(alias string) BooleanField
- func (field BooleanField) Asc() BooleanField
- func (f BooleanField) Desc() BooleanField
- func (field BooleanField) Eq(value Boolean) Predicate
- func (field BooleanField) EqBool(b bool) Predicate
- func (field BooleanField) GetAlias() string
- func (field BooleanField) IsBoolean()
- func (field BooleanField) IsField()
- func (field BooleanField) IsNotNull() Predicate
- func (field BooleanField) IsNull() Predicate
- func (field BooleanField) Ne(value Boolean) Predicate
- func (field BooleanField) NeBool(b bool) Predicate
- func (field BooleanField) NullsFirst() BooleanField
- func (field BooleanField) NullsLast() BooleanField
- func (field BooleanField) Set(value any) Assignment
- func (field BooleanField) SetBool(b bool) Assignment
- func (field BooleanField) Setf(format string, values ...any) Assignment
- func (field BooleanField) WithPrefix(prefix string) Field
- func (field BooleanField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type BooleanParameter
- type CTE
- func (cte CTE) As(alias string) CTE
- func (cte CTE) Field(name string) AnyField
- func (cte CTE) GetAlias() string
- func (cte CTE) IsTable()
- func (cte CTE) Materialized() CTE
- func (cte CTE) NotMaterialized() CTE
- func (cte CTE) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type CaseExpression
- func (e CaseExpression) As(alias string) CaseExpression
- func (e CaseExpression) Else(fallback any) CaseExpression
- func (e CaseExpression) GetAlias() string
- func (e CaseExpression) IsArray()
- func (e CaseExpression) IsBinary()
- func (e CaseExpression) IsBoolean()
- func (e CaseExpression) IsEnum()
- func (e CaseExpression) IsField()
- func (e CaseExpression) IsJSON()
- func (e CaseExpression) IsNumber()
- func (e CaseExpression) IsString()
- func (e CaseExpression) IsTime()
- func (e CaseExpression) IsUUID()
- func (e CaseExpression) When(predicate Predicate, result any) CaseExpression
- func (e CaseExpression) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type Column
- func (col *Column) Set(field Field, value any)
- func (col *Column) SetArray(field Array, value any)
- func (col *Column) SetBool(field Boolean, value bool)
- func (col *Column) SetBytes(field Binary, value []byte)
- func (col *Column) SetEnum(field Enum, value Enumeration)
- func (col *Column) SetFloat64(field Number, value float64)
- func (col *Column) SetInt(field Number, value int)
- func (col *Column) SetInt64(field Number, value int64)
- func (col *Column) SetJSON(field JSON, value any)
- func (col *Column) SetString(field String, value string)
- func (col *Column) SetTime(field Time, value time.Time)
- func (col *Column) SetUUID(field UUID, value any)
- type CompiledExec
- func (compiledExec *CompiledExec) Exec(db DB, params Params) (Result, error)
- func (compiledExec *CompiledExec) ExecContext(ctx context.Context, db DB, params Params) (Result, error)
- func (compiledExec *CompiledExec) GetSQL() (dialect string, query string, args []any, params map[string][]int)
- func (compiledExec *CompiledExec) Prepare(db DB) (*PreparedExec, error)
- func (compiledExec *CompiledExec) PrepareContext(ctx context.Context, db DB) (*PreparedExec, error)
- type CompiledFetch
- func CompileFetch[T any](q Query, rowmapper func(*Row) T) (*CompiledFetch[T], error)
- func CompileFetchContext[T any](ctx context.Context, query Query, rowmapper func(*Row) T) (compiledFetch *CompiledFetch[T], err error)
- func NewCompiledFetch[T any](dialect string, query string, args []any, params map[string][]int, ...) *CompiledFetch[T]
- func (compiledFetch *CompiledFetch[T]) FetchAll(db DB, params Params) ([]T, error)
- func (compiledFetch *CompiledFetch[T]) FetchAllContext(ctx context.Context, db DB, params Params) ([]T, error)
- func (compiledFetch *CompiledFetch[T]) FetchCursor(db DB, params Params) (*Cursor[T], error)
- func (compiledFetch *CompiledFetch[T]) FetchCursorContext(ctx context.Context, db DB, params Params) (*Cursor[T], error)
- func (compiledFetch *CompiledFetch[T]) FetchOne(db DB, params Params) (T, error)
- func (compiledFetch *CompiledFetch[T]) FetchOneContext(ctx context.Context, db DB, params Params) (T, error)
- func (compiledFetch *CompiledFetch[T]) GetSQL() (dialect string, query string, args []any, params map[string][]int, ...)
- func (compiledFetch *CompiledFetch[T]) Prepare(db DB) (*PreparedFetch[T], error)
- func (compiledFetch *CompiledFetch[T]) PrepareContext(ctx context.Context, db DB) (*PreparedFetch[T], error)
- type ConflictClause
- type Cursor
- type CustomQuery
- func (q CustomQuery) Append(format string, values ...any) CustomQuery
- func (q CustomQuery) GetDialect() string
- func (q CustomQuery) GetFetchableFields() []Field
- func (q CustomQuery) SetDialect(dialect string) CustomQuery
- func (q CustomQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q CustomQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type DB
- type DeleteQuery
- func (q DeleteQuery) GetDialect() string
- func (q DeleteQuery) GetFetchableFields() []Field
- func (q DeleteQuery) SetDialect(dialect string) DeleteQuery
- func (q DeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q DeleteQuery) Where(predicates ...Predicate) DeleteQuery
- func (q DeleteQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type DialectCase
- type DialectCases
- type DialectExpression
- func (e DialectExpression) DialectExpr(dialect string, format string, values ...any) DialectExpression
- func (e DialectExpression) DialectValue(dialect string, value any) DialectExpression
- func (e DialectExpression) IsArray()
- func (e DialectExpression) IsBinary()
- func (e DialectExpression) IsBoolean()
- func (e DialectExpression) IsEnum()
- func (e DialectExpression) IsField()
- func (e DialectExpression) IsJSON()
- func (e DialectExpression) IsNumber()
- func (e DialectExpression) IsString()
- func (e DialectExpression) IsTable()
- func (e DialectExpression) IsTime()
- func (e DialectExpression) IsUUID()
- func (e DialectExpression) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type DialectValuer
- type Enum
- type EnumField
- func (field EnumField) As(alias string) EnumField
- func (field EnumField) Eq(value any) Predicate
- func (field EnumField) EqEnum(value Enumeration) Predicate
- func (field EnumField) GetAlias() string
- func (field EnumField) In(value any) Predicate
- func (field EnumField) IsEnum()
- func (field EnumField) IsField()
- func (field EnumField) IsNotNull() Predicate
- func (field EnumField) IsNull() Predicate
- func (field EnumField) Ne(value any) Predicate
- func (field EnumField) NeEnum(value Enumeration) Predicate
- func (field EnumField) NotIn(value any) Predicate
- func (field EnumField) Set(value any) Assignment
- func (field EnumField) SetEnum(value Enumeration) Assignment
- func (field EnumField) Setf(format string, values ...any) Assignment
- func (field EnumField) WithPrefix(prefix string) Field
- func (field EnumField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type EnumParameter
- type Enumeration
- type Expression
- func Avg(num Number) Expression
- func AvgOver(num Number, window Window) Expression
- func Count(field Field) Expression
- func CountOver(field Field, window Window) Expression
- func CountStar() Expression
- func CountStarOver(window Window) Expression
- func CumeDistOver(window Window) Expression
- func DenseRankOver(window Window) Expression
- func Expr(format string, values ...any) Expression
- func FirstValueOver(field Field, window Window) Expression
- func LastValueOver(field Field, window Window) Expression
- func Max(field Field) Expression
- func MaxOver(field Field, window Window) Expression
- func Min(field Field) Expression
- func MinOver(field Field, window Window) Expression
- func RankOver(window Window) Expression
- func RowNumberOver(window Window) Expression
- func Sum(num Number) Expression
- func SumOver(num Number, window Window) Expression
- func (expr Expression) As(alias string) Expression
- func (expr Expression) Eq(value any) Predicate
- func (expr Expression) Ge(value any) Predicate
- func (expr Expression) GetAlias() string
- func (expr Expression) Gt(value any) Predicate
- func (expr Expression) In(value any) Predicate
- func (expr Expression) IsArray()
- func (e Expression) IsAssignment()
- func (expr Expression) IsBinary()
- func (expr Expression) IsBoolean()
- func (expr Expression) IsEnum()
- func (expr Expression) IsField()
- func (expr Expression) IsJSON()
- func (expr Expression) IsNumber()
- func (expr Expression) IsString()
- func (expr Expression) IsTable()
- func (expr Expression) IsTime()
- func (expr Expression) IsUUID()
- func (expr Expression) Le(value any) Predicate
- func (expr Expression) Lt(value any) Predicate
- func (expr Expression) Ne(value any) Predicate
- func (expr Expression) NotIn(value any) Predicate
- func (expr Expression) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type Field
- type Fields
- type Identifier
- type InsertQuery
- func (q InsertQuery) ColumnValues(colmapper func(*Column)) InsertQuery
- func (q InsertQuery) Columns(fields ...Field) InsertQuery
- func (q InsertQuery) GetDialect() string
- func (q InsertQuery) GetFetchableFields() []Field
- func (q InsertQuery) Select(query Query) InsertQuery
- func (q InsertQuery) SetDialect(dialect string) InsertQuery
- func (q InsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q InsertQuery) Values(values ...any) InsertQuery
- func (q InsertQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) (err error)
- type JSON
- type JSONField
- func (field JSONField) As(alias string) JSONField
- func (field JSONField) GetAlias() string
- func (field JSONField) IsBinary()
- func (field JSONField) IsField()
- func (field JSONField) IsJSON()
- func (field JSONField) IsNotNull() Predicate
- func (field JSONField) IsNull() Predicate
- func (field JSONField) IsString()
- func (field JSONField) Set(value any) Assignment
- func (field JSONField) SetJSON(value any) Assignment
- func (field JSONField) Setf(format string, values ...any) Assignment
- func (field JSONField) WithPrefix(prefix string) Field
- func (field JSONField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type JSONParameter
- type JoinTable
- func CrossJoin(table Table) JoinTable
- func CustomJoin(joinOperator string, table Table, predicates ...Predicate) JoinTable
- func FullJoin(table Table, predicates ...Predicate) JoinTable
- func Join(table Table, predicates ...Predicate) JoinTable
- func JoinUsing(table Table, fields ...Field) JoinTable
- func LeftJoin(table Table, predicates ...Predicate) JoinTable
- type LiteralValue
- func (v LiteralValue) As(alias string) LiteralValue
- func (v LiteralValue) Eq(val any) Predicate
- func (v LiteralValue) Ge(val any) Predicate
- func (v LiteralValue) GetAlias() string
- func (v LiteralValue) Gt(val any) Predicate
- func (v LiteralValue) In(val any) Predicate
- func (v LiteralValue) IsBinary()
- func (v LiteralValue) IsBoolean()
- func (v LiteralValue) IsField()
- func (v LiteralValue) IsNumber()
- func (v LiteralValue) IsString()
- func (v LiteralValue) IsTime()
- func (v LiteralValue) Le(val any) Predicate
- func (v LiteralValue) Lt(val any) Predicate
- func (v LiteralValue) Ne(val any) Predicate
- func (v LiteralValue) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type LogSettings
- type LoggerConfig
- type MySQLDeleteQuery
- func (q MySQLDeleteQuery) CrossJoin(table Table) MySQLDeleteQuery
- func (q MySQLDeleteQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) MySQLDeleteQuery
- func (q MySQLDeleteQuery) From(table Table) MySQLDeleteQuery
- func (q MySQLDeleteQuery) FullJoin(table Table, predicates ...Predicate) MySQLDeleteQuery
- func (q MySQLDeleteQuery) GetDialect() string
- func (q MySQLDeleteQuery) GetFetchableFields() []Field
- func (q MySQLDeleteQuery) Join(table Table, predicates ...Predicate) MySQLDeleteQuery
- func (q MySQLDeleteQuery) JoinUsing(table Table, fields ...Field) MySQLDeleteQuery
- func (q MySQLDeleteQuery) LeftJoin(table Table, predicates ...Predicate) MySQLDeleteQuery
- func (q MySQLDeleteQuery) Limit(limit any) MySQLDeleteQuery
- func (q MySQLDeleteQuery) OrderBy(fields ...Field) MySQLDeleteQuery
- func (q MySQLDeleteQuery) Returning(fields ...Field) MySQLDeleteQuery
- func (q MySQLDeleteQuery) SetDialect(dialect string) MySQLDeleteQuery
- func (q MySQLDeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q MySQLDeleteQuery) Where(predicates ...Predicate) MySQLDeleteQuery
- func (q MySQLDeleteQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type MySQLInsertQuery
- func (q MySQLInsertQuery) As(rowAlias string) MySQLInsertQuery
- func (q MySQLInsertQuery) ColumnValues(colmapper func(*Column)) MySQLInsertQuery
- func (q MySQLInsertQuery) Columns(fields ...Field) MySQLInsertQuery
- func (q MySQLInsertQuery) GetDialect() string
- func (q MySQLInsertQuery) GetFetchableFields() []Field
- func (q MySQLInsertQuery) OnDuplicateKeyUpdate(assignments ...Assignment) MySQLInsertQuery
- func (q MySQLInsertQuery) Returning(fields ...Field) MySQLInsertQuery
- func (q MySQLInsertQuery) Select(query Query) MySQLInsertQuery
- func (q MySQLInsertQuery) SetDialect(dialect string) MySQLInsertQuery
- func (q MySQLInsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q MySQLInsertQuery) Values(values ...any) MySQLInsertQuery
- func (q MySQLInsertQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type MySQLSelectQuery
- func (q MySQLSelectQuery) As(alias string, columns ...string) MySQLSelectQuery
- func (q MySQLSelectQuery) CrossJoin(table Table) MySQLSelectQuery
- func (q MySQLSelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) MySQLSelectQuery
- func (q MySQLSelectQuery) Field(name string) AnyField
- func (q MySQLSelectQuery) From(table Table) MySQLSelectQuery
- func (q MySQLSelectQuery) FullJoin(table Table, predicates ...Predicate) MySQLSelectQuery
- func (q MySQLSelectQuery) GetAlias() string
- func (q MySQLSelectQuery) GetDialect() string
- func (q MySQLSelectQuery) GetFetchableFields() []Field
- func (q MySQLSelectQuery) GroupBy(fields ...Field) MySQLSelectQuery
- func (q MySQLSelectQuery) Having(predicates ...Predicate) MySQLSelectQuery
- func (q MySQLSelectQuery) IsArray()
- func (q MySQLSelectQuery) IsBinary()
- func (q MySQLSelectQuery) IsBoolean()
- func (q MySQLSelectQuery) IsEnum()
- func (q MySQLSelectQuery) IsField()
- func (q MySQLSelectQuery) IsJSON()
- func (q MySQLSelectQuery) IsNumber()
- func (q MySQLSelectQuery) IsString()
- func (q MySQLSelectQuery) IsTable()
- func (q MySQLSelectQuery) IsTime()
- func (q MySQLSelectQuery) IsUUID()
- func (q MySQLSelectQuery) Join(table Table, predicates ...Predicate) MySQLSelectQuery
- func (q MySQLSelectQuery) JoinUsing(table Table, fields ...Field) MySQLSelectQuery
- func (q MySQLSelectQuery) LeftJoin(table Table, predicates ...Predicate) MySQLSelectQuery
- func (q MySQLSelectQuery) Limit(limit any) MySQLSelectQuery
- func (q MySQLSelectQuery) LockRows(lockClause string, lockValues ...any) MySQLSelectQuery
- func (q MySQLSelectQuery) Offset(offset any) MySQLSelectQuery
- func (q MySQLSelectQuery) OrderBy(fields ...Field) MySQLSelectQuery
- func (q MySQLSelectQuery) Select(fields ...Field) MySQLSelectQuery
- func (q MySQLSelectQuery) SelectDistinct(fields ...Field) MySQLSelectQuery
- func (q MySQLSelectQuery) SelectOne(fields ...Field) MySQLSelectQuery
- func (q MySQLSelectQuery) SetDialect(dialect string) MySQLSelectQuery
- func (q MySQLSelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q MySQLSelectQuery) Where(predicates ...Predicate) MySQLSelectQuery
- func (q MySQLSelectQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type MySQLUpdateQuery
- func (q MySQLUpdateQuery) CrossJoin(table Table) MySQLUpdateQuery
- func (q MySQLUpdateQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) MySQLUpdateQuery
- func (q MySQLUpdateQuery) FullJoin(table Table, predicates ...Predicate) MySQLUpdateQuery
- func (q MySQLUpdateQuery) GetDialect() string
- func (q MySQLUpdateQuery) GetFetchableFields() []Field
- func (q MySQLUpdateQuery) Join(table Table, predicates ...Predicate) MySQLUpdateQuery
- func (q MySQLUpdateQuery) JoinUsing(table Table, fields ...Field) MySQLUpdateQuery
- func (q MySQLUpdateQuery) LeftJoin(table Table, predicates ...Predicate) MySQLUpdateQuery
- func (q MySQLUpdateQuery) Limit(limit any) MySQLUpdateQuery
- func (q MySQLUpdateQuery) OrderBy(fields ...Field) MySQLUpdateQuery
- func (q MySQLUpdateQuery) Set(assignments ...Assignment) MySQLUpdateQuery
- func (q MySQLUpdateQuery) SetDialect(dialect string) MySQLUpdateQuery
- func (q MySQLUpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q MySQLUpdateQuery) SetFunc(colmapper func(*Column)) MySQLUpdateQuery
- func (q MySQLUpdateQuery) Where(predicates ...Predicate) MySQLUpdateQuery
- func (q MySQLUpdateQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type NamedWindow
- type NamedWindows
- type Number
- type NumberField
- func (field NumberField) As(alias string) NumberField
- func (field NumberField) Asc() NumberField
- func (field NumberField) Desc() NumberField
- func (field NumberField) Eq(value Number) Predicate
- func (field NumberField) EqFloat64(num float64) Predicate
- func (field NumberField) EqInt(num int) Predicate
- func (field NumberField) EqInt64(num int64) Predicate
- func (field NumberField) Ge(value Number) Predicate
- func (field NumberField) GeFloat64(num float64) Predicate
- func (field NumberField) GeInt(num int) Predicate
- func (field NumberField) GeInt64(num int64) Predicate
- func (field NumberField) GetAlias() string
- func (field NumberField) Gt(value Number) Predicate
- func (field NumberField) GtFloat64(num float64) Predicate
- func (field NumberField) GtInt(num int) Predicate
- func (field NumberField) GtInt64(num int64) Predicate
- func (field NumberField) In(value any) Predicate
- func (field NumberField) IsField()
- func (field NumberField) IsNotNull() Predicate
- func (field NumberField) IsNull() Predicate
- func (field NumberField) IsNumber()
- func (field NumberField) Le(value Number) Predicate
- func (field NumberField) LeFloat64(num float64) Predicate
- func (field NumberField) LeInt(num int) Predicate
- func (field NumberField) LeInt64(num int64) Predicate
- func (field NumberField) Lt(value Number) Predicate
- func (field NumberField) LtFloat64(num float64) Predicate
- func (field NumberField) LtInt(num int) Predicate
- func (field NumberField) LtInt64(num int64) Predicate
- func (field NumberField) Ne(value Number) Predicate
- func (field NumberField) NeFloat64(num float64) Predicate
- func (field NumberField) NeInt(num int) Predicate
- func (field NumberField) NeInt64(num int64) Predicate
- func (field NumberField) NotIn(value any) Predicate
- func (field NumberField) NullsFirst() NumberField
- func (field NumberField) NullsLast() NumberField
- func (field NumberField) Set(value any) Assignment
- func (field NumberField) SetFloat64(num float64) Assignment
- func (field NumberField) SetInt(num int) Assignment
- func (field NumberField) SetInt64(num int64) Assignment
- func (field NumberField) Setf(format string, values ...any) Assignment
- func (field NumberField) WithPrefix(prefix string) Field
- func (field NumberField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type NumberParameter
- type Parameter
- type Params
- type PolicyTable
- type PostgresDeleteQuery
- func (q PostgresDeleteQuery) CrossJoin(table Table) PostgresDeleteQuery
- func (q PostgresDeleteQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) PostgresDeleteQuery
- func (q PostgresDeleteQuery) FullJoin(table Table, predicates ...Predicate) PostgresDeleteQuery
- func (q PostgresDeleteQuery) GetDialect() string
- func (q PostgresDeleteQuery) GetFetchableFields() []Field
- func (q PostgresDeleteQuery) Join(table Table, predicates ...Predicate) PostgresDeleteQuery
- func (q PostgresDeleteQuery) JoinUsing(table Table, fields ...Field) PostgresDeleteQuery
- func (q PostgresDeleteQuery) LeftJoin(table Table, predicates ...Predicate) PostgresDeleteQuery
- func (q PostgresDeleteQuery) Returning(fields ...Field) PostgresDeleteQuery
- func (q PostgresDeleteQuery) SetDialect(dialect string) PostgresDeleteQuery
- func (q PostgresDeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q PostgresDeleteQuery) Using(table Table) PostgresDeleteQuery
- func (q PostgresDeleteQuery) Where(predicates ...Predicate) PostgresDeleteQuery
- func (q PostgresDeleteQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type PostgresInsertQuery
- func (q PostgresInsertQuery) ColumnValues(colmapper func(*Column)) PostgresInsertQuery
- func (q PostgresInsertQuery) Columns(fields ...Field) PostgresInsertQuery
- func (q PostgresInsertQuery) GetDialect() string
- func (q PostgresInsertQuery) GetFetchableFields() []Field
- func (q PostgresInsertQuery) OnConflict(fields ...Field) postgresInsertConflict
- func (q PostgresInsertQuery) OnConflictOnConstraint(constraintName string) postgresInsertConflict
- func (q PostgresInsertQuery) Returning(fields ...Field) PostgresInsertQuery
- func (q PostgresInsertQuery) Select(query Query) PostgresInsertQuery
- func (q PostgresInsertQuery) SetDialect(dialect string) PostgresInsertQuery
- func (q PostgresInsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q PostgresInsertQuery) Values(values ...any) PostgresInsertQuery
- func (q PostgresInsertQuery) Where(predicates ...Predicate) PostgresInsertQuery
- func (q PostgresInsertQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type PostgresSelectQuery
- func (q PostgresSelectQuery) As(alias string, columns ...string) PostgresSelectQuery
- func (q PostgresSelectQuery) CrossJoin(table Table) PostgresSelectQuery
- func (q PostgresSelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) PostgresSelectQuery
- func (q PostgresSelectQuery) DistinctOn(fields ...Field) PostgresSelectQuery
- func (q PostgresSelectQuery) FetchNext(n any) PostgresSelectQuery
- func (q PostgresSelectQuery) Field(name string) AnyField
- func (q PostgresSelectQuery) From(table Table) PostgresSelectQuery
- func (q PostgresSelectQuery) FullJoin(table Table, predicates ...Predicate) PostgresSelectQuery
- func (q PostgresSelectQuery) GetAlias() string
- func (q PostgresSelectQuery) GetDialect() string
- func (q PostgresSelectQuery) GetFetchableFields() []Field
- func (q PostgresSelectQuery) GroupBy(fields ...Field) PostgresSelectQuery
- func (q PostgresSelectQuery) Having(predicates ...Predicate) PostgresSelectQuery
- func (q PostgresSelectQuery) IsArray()
- func (q PostgresSelectQuery) IsBinary()
- func (q PostgresSelectQuery) IsBoolean()
- func (q PostgresSelectQuery) IsEnum()
- func (q PostgresSelectQuery) IsField()
- func (q PostgresSelectQuery) IsJSON()
- func (q PostgresSelectQuery) IsNumber()
- func (q PostgresSelectQuery) IsString()
- func (q PostgresSelectQuery) IsTable()
- func (q PostgresSelectQuery) IsTime()
- func (q PostgresSelectQuery) IsUUID()
- func (q PostgresSelectQuery) Join(table Table, predicates ...Predicate) PostgresSelectQuery
- func (q PostgresSelectQuery) JoinUsing(table Table, fields ...Field) PostgresSelectQuery
- func (q PostgresSelectQuery) LeftJoin(table Table, predicates ...Predicate) PostgresSelectQuery
- func (q PostgresSelectQuery) Limit(limit any) PostgresSelectQuery
- func (q PostgresSelectQuery) LockRows(lockClause string, lockValues ...any) PostgresSelectQuery
- func (q PostgresSelectQuery) Offset(offset any) PostgresSelectQuery
- func (q PostgresSelectQuery) OrderBy(fields ...Field) PostgresSelectQuery
- func (q PostgresSelectQuery) Select(fields ...Field) PostgresSelectQuery
- func (q PostgresSelectQuery) SelectDistinct(fields ...Field) PostgresSelectQuery
- func (q PostgresSelectQuery) SelectOne(fields ...Field) PostgresSelectQuery
- func (q PostgresSelectQuery) SetDialect(dialect string) PostgresSelectQuery
- func (q PostgresSelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q PostgresSelectQuery) Where(predicates ...Predicate) PostgresSelectQuery
- func (q PostgresSelectQuery) WithTies() PostgresSelectQuery
- func (q PostgresSelectQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type PostgresUpdateQuery
- func (q PostgresUpdateQuery) CrossJoin(table Table) PostgresUpdateQuery
- func (q PostgresUpdateQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) PostgresUpdateQuery
- func (q PostgresUpdateQuery) From(table Table) PostgresUpdateQuery
- func (q PostgresUpdateQuery) FullJoin(table Table, predicates ...Predicate) PostgresUpdateQuery
- func (q PostgresUpdateQuery) GetDialect() string
- func (q PostgresUpdateQuery) GetFetchableFields() []Field
- func (q PostgresUpdateQuery) Join(table Table, predicates ...Predicate) PostgresUpdateQuery
- func (q PostgresUpdateQuery) JoinUsing(table Table, fields ...Field) PostgresUpdateQuery
- func (q PostgresUpdateQuery) LeftJoin(table Table, predicates ...Predicate) PostgresUpdateQuery
- func (q PostgresUpdateQuery) Returning(fields ...Field) PostgresUpdateQuery
- func (q PostgresUpdateQuery) Set(assignments ...Assignment) PostgresUpdateQuery
- func (q PostgresUpdateQuery) SetDialect(dialect string) PostgresUpdateQuery
- func (q PostgresUpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q PostgresUpdateQuery) SetFunc(colmapper func(*Column)) PostgresUpdateQuery
- func (q PostgresUpdateQuery) Where(predicates ...Predicate) PostgresUpdateQuery
- func (q PostgresUpdateQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type Predicate
- type PredicateCase
- type PredicateCases
- type PreparedExec
- type PreparedFetch
- func (preparedFetch *PreparedFetch[T]) Close() error
- func (preparedFetch *PreparedFetch[T]) FetchAll(params Params) ([]T, error)
- func (preparedFetch *PreparedFetch[T]) FetchAllContext(ctx context.Context, params Params) ([]T, error)
- func (preparedFetch PreparedFetch[T]) FetchCursor(params Params) (*Cursor[T], error)
- func (preparedFetch PreparedFetch[T]) FetchCursorContext(ctx context.Context, params Params) (*Cursor[T], error)
- func (preparedFetch *PreparedFetch[T]) FetchOne(params Params) (T, error)
- func (preparedFetch *PreparedFetch[T]) FetchOneContext(ctx context.Context, params Params) (T, error)
- func (preparedFetch *PreparedFetch[T]) GetCompiled() *CompiledFetch[T]
- type Query
- type QueryStats
- type Result
- type Row
- func (row *Row) Array(destPtr any, format string, values ...any)
- func (row *Row) ArrayField(destPtr any, field Array)
- func (row *Row) Bool(format string, values ...any) bool
- func (row *Row) BoolField(field Boolean) bool
- func (row *Row) Bytes(format string, values ...any) []byte
- func (row *Row) BytesField(field Binary) []byte
- func (row *Row) ColumnTypes() []*sql.ColumnType
- func (row *Row) Columns() []string
- func (row *Row) Enum(destPtr Enumeration, format string, values ...any)
- func (row *Row) EnumField(destPtr Enumeration, field Enum)
- func (row *Row) Float64(format string, values ...any) float64
- func (row *Row) Float64Field(field Number) float64
- func (row *Row) Int(format string, values ...any) int
- func (row *Row) Int64(format string, values ...any) int64
- func (row *Row) Int64Field(field Number) int64
- func (row *Row) IntField(field Number) int
- func (row *Row) JSON(destPtr any, format string, values ...any)
- func (row *Row) JSONField(destPtr any, field JSON)
- func (row *Row) NullBool(format string, values ...any) sql.NullBool
- func (row *Row) NullBoolField(field Boolean) sql.NullBool
- func (row *Row) NullFloat64(format string, values ...any) sql.NullFloat64
- func (row *Row) NullFloat64Field(field Number) sql.NullFloat64
- func (row *Row) NullInt64(format string, values ...any) sql.NullInt64
- func (row *Row) NullInt64Field(field Number) sql.NullInt64
- func (row *Row) NullString(format string, values ...any) sql.NullString
- func (row *Row) NullStringField(field String) sql.NullString
- func (row *Row) NullTime(format string, values ...any) sql.NullTime
- func (row *Row) NullTimeField(field Time) sql.NullTime
- func (row *Row) Scan(destPtr any, format string, values ...any)
- func (row *Row) ScanField(destPtr any, field Field)
- func (row *Row) String(format string, values ...any) string
- func (row *Row) StringField(field String) string
- func (row *Row) Time(format string, values ...any) time.Time
- func (row *Row) TimeField(field Time) time.Time
- func (row *Row) UUID(destPtr any, format string, values ...any)
- func (row *Row) UUIDField(destPtr any, field UUID)
- func (row *Row) Value(format string, values ...any) any
- func (row *Row) Values() []any
- type RowValue
- type RowValues
- type SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) CrossJoin(table Table) SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) From(table Table) SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) FullJoin(table Table, predicates ...Predicate) SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) GetDialect() string
- func (q SQLServerDeleteQuery) GetFetchableFields() []Field
- func (q SQLServerDeleteQuery) Join(table Table, predicates ...Predicate) SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) LeftJoin(table Table, predicates ...Predicate) SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) SetDialect(dialect string) SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SQLServerDeleteQuery) Where(predicates ...Predicate) SQLServerDeleteQuery
- func (q SQLServerDeleteQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SQLServerInsertQuery
- func (q SQLServerInsertQuery) ColumnValues(colmapper func(*Column)) SQLServerInsertQuery
- func (q SQLServerInsertQuery) Columns(fields ...Field) SQLServerInsertQuery
- func (q SQLServerInsertQuery) GetDialect() string
- func (q SQLServerInsertQuery) GetFetchableFields() []Field
- func (q SQLServerInsertQuery) Select(query Query) SQLServerInsertQuery
- func (q SQLServerInsertQuery) SetDialect(dialect string) SQLServerInsertQuery
- func (q SQLServerInsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SQLServerInsertQuery) Values(values ...any) SQLServerInsertQuery
- func (q SQLServerInsertQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SQLServerSelectQuery
- func (q SQLServerSelectQuery) As(alias string, columns ...string) SQLServerSelectQuery
- func (q SQLServerSelectQuery) CrossJoin(table Table) SQLServerSelectQuery
- func (q SQLServerSelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLServerSelectQuery
- func (q SQLServerSelectQuery) FetchNext(n any) SQLServerSelectQuery
- func (q SQLServerSelectQuery) Field(name string) AnyField
- func (q SQLServerSelectQuery) From(table Table) SQLServerSelectQuery
- func (q SQLServerSelectQuery) FullJoin(table Table, predicates ...Predicate) SQLServerSelectQuery
- func (q SQLServerSelectQuery) GetAlias() string
- func (q SQLServerSelectQuery) GetDialect() string
- func (q SQLServerSelectQuery) GetFetchableFields() []Field
- func (q SQLServerSelectQuery) GroupBy(fields ...Field) SQLServerSelectQuery
- func (q SQLServerSelectQuery) Having(predicates ...Predicate) SQLServerSelectQuery
- func (q SQLServerSelectQuery) IsArray()
- func (q SQLServerSelectQuery) IsBinary()
- func (q SQLServerSelectQuery) IsBoolean()
- func (q SQLServerSelectQuery) IsEnum()
- func (q SQLServerSelectQuery) IsField()
- func (q SQLServerSelectQuery) IsJSON()
- func (q SQLServerSelectQuery) IsNumber()
- func (q SQLServerSelectQuery) IsString()
- func (q SQLServerSelectQuery) IsTable()
- func (q SQLServerSelectQuery) IsTime()
- func (q SQLServerSelectQuery) IsUUID()
- func (q SQLServerSelectQuery) Join(table Table, predicates ...Predicate) SQLServerSelectQuery
- func (q SQLServerSelectQuery) LeftJoin(table Table, predicates ...Predicate) SQLServerSelectQuery
- func (q SQLServerSelectQuery) Offset(offset any) SQLServerSelectQuery
- func (q SQLServerSelectQuery) OrderBy(fields ...Field) SQLServerSelectQuery
- func (q SQLServerSelectQuery) Select(fields ...Field) SQLServerSelectQuery
- func (q SQLServerSelectQuery) SelectDistinct(fields ...Field) SQLServerSelectQuery
- func (q SQLServerSelectQuery) SelectOne(fields ...Field) SQLServerSelectQuery
- func (q SQLServerSelectQuery) SetDialect(dialect string) SQLServerSelectQuery
- func (q SQLServerSelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SQLServerSelectQuery) Top(limit any) SQLServerSelectQuery
- func (q SQLServerSelectQuery) TopPercent(percentLimit any) SQLServerSelectQuery
- func (q SQLServerSelectQuery) Where(predicates ...Predicate) SQLServerSelectQuery
- func (q SQLServerSelectQuery) WithTies() SQLServerSelectQuery
- func (q SQLServerSelectQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) CrossJoin(table Table) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) From(table Table) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) FullJoin(table Table, predicates ...Predicate) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) GetDialect() string
- func (q SQLServerUpdateQuery) GetFetchableFields() []Field
- func (q SQLServerUpdateQuery) Join(table Table, predicates ...Predicate) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) LeftJoin(table Table, predicates ...Predicate) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) Set(assignments ...Assignment) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) SetDialect(dialect string) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SQLServerUpdateQuery) SetFunc(colmapper func(*Column)) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) Where(predicates ...Predicate) SQLServerUpdateQuery
- func (q SQLServerUpdateQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SQLWriter
- type SQLiteDeleteQuery
- func (q SQLiteDeleteQuery) GetDialect() string
- func (q SQLiteDeleteQuery) GetFetchableFields() []Field
- func (q SQLiteDeleteQuery) Returning(fields ...Field) SQLiteDeleteQuery
- func (q SQLiteDeleteQuery) SetDialect(dialect string) SQLiteDeleteQuery
- func (q SQLiteDeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SQLiteDeleteQuery) Where(predicates ...Predicate) SQLiteDeleteQuery
- func (q SQLiteDeleteQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SQLiteInsertQuery
- func (q SQLiteInsertQuery) ColumnValues(colmapper func(*Column)) SQLiteInsertQuery
- func (q SQLiteInsertQuery) Columns(fields ...Field) SQLiteInsertQuery
- func (q SQLiteInsertQuery) GetDialect() string
- func (q SQLiteInsertQuery) GetFetchableFields() []Field
- func (q SQLiteInsertQuery) OnConflict(fields ...Field) sqliteInsertConflict
- func (q SQLiteInsertQuery) Returning(fields ...Field) SQLiteInsertQuery
- func (q SQLiteInsertQuery) Select(query Query) SQLiteInsertQuery
- func (q SQLiteInsertQuery) SetDialect(dialect string) SQLiteInsertQuery
- func (q SQLiteInsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SQLiteInsertQuery) Values(values ...any) SQLiteInsertQuery
- func (q SQLiteInsertQuery) Where(predicates ...Predicate) SQLiteInsertQuery
- func (q SQLiteInsertQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SQLiteSelectQuery
- func (q SQLiteSelectQuery) As(alias string, columns ...string) SQLiteSelectQuery
- func (q SQLiteSelectQuery) CrossJoin(table Table) SQLiteSelectQuery
- func (q SQLiteSelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLiteSelectQuery
- func (q SQLiteSelectQuery) Field(name string) AnyField
- func (q SQLiteSelectQuery) From(table Table) SQLiteSelectQuery
- func (q SQLiteSelectQuery) GetAlias() string
- func (q SQLiteSelectQuery) GetDialect() string
- func (q SQLiteSelectQuery) GetFetchableFields() []Field
- func (q SQLiteSelectQuery) GroupBy(fields ...Field) SQLiteSelectQuery
- func (q SQLiteSelectQuery) Having(predicates ...Predicate) SQLiteSelectQuery
- func (q SQLiteSelectQuery) IsArray()
- func (q SQLiteSelectQuery) IsBinary()
- func (q SQLiteSelectQuery) IsBoolean()
- func (q SQLiteSelectQuery) IsEnum()
- func (q SQLiteSelectQuery) IsField()
- func (q SQLiteSelectQuery) IsJSON()
- func (q SQLiteSelectQuery) IsNumber()
- func (q SQLiteSelectQuery) IsString()
- func (q SQLiteSelectQuery) IsTable()
- func (q SQLiteSelectQuery) IsTime()
- func (q SQLiteSelectQuery) IsUUID()
- func (q SQLiteSelectQuery) Join(table Table, predicates ...Predicate) SQLiteSelectQuery
- func (q SQLiteSelectQuery) JoinUsing(table Table, fields ...Field) SQLiteSelectQuery
- func (q SQLiteSelectQuery) LeftJoin(table Table, predicates ...Predicate) SQLiteSelectQuery
- func (q SQLiteSelectQuery) Limit(limit any) SQLiteSelectQuery
- func (q SQLiteSelectQuery) Offset(offset any) SQLiteSelectQuery
- func (q SQLiteSelectQuery) OrderBy(fields ...Field) SQLiteSelectQuery
- func (q SQLiteSelectQuery) Select(fields ...Field) SQLiteSelectQuery
- func (q SQLiteSelectQuery) SelectDistinct(fields ...Field) SQLiteSelectQuery
- func (q SQLiteSelectQuery) SelectOne(fields ...Field) SQLiteSelectQuery
- func (q SQLiteSelectQuery) SetDialect(dialect string) SQLiteSelectQuery
- func (q SQLiteSelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SQLiteSelectQuery) Where(predicates ...Predicate) SQLiteSelectQuery
- func (q SQLiteSelectQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) CrossJoin(table Table) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) From(table Table) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) GetDialect() string
- func (q SQLiteUpdateQuery) GetFetchableFields() []Field
- func (q SQLiteUpdateQuery) Join(table Table, predicates ...Predicate) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) JoinUsing(table Table, fields ...Field) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) LeftJoin(table Table, predicates ...Predicate) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) Returning(fields ...Field) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) Set(assignments ...Assignment) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) SetDialect(dialect string) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SQLiteUpdateQuery) SetFunc(colmapper func(*Column)) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) Where(predicates ...Predicate) SQLiteUpdateQuery
- func (q SQLiteUpdateQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SelectQuery
- func (q SelectQuery) As(alias string, columns ...string) SelectQuery
- func (q SelectQuery) CrossJoin(table Table) SelectQuery
- func (q SelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SelectQuery
- func (q SelectQuery) Field(name string) AnyField
- func (q SelectQuery) From(table Table) SelectQuery
- func (q SelectQuery) GetAlias() string
- func (q SelectQuery) GetColumns() []string
- func (q SelectQuery) GetDialect() string
- func (q SelectQuery) GetFetchableFields() []Field
- func (q SelectQuery) GroupBy(fields ...Field) SelectQuery
- func (q SelectQuery) Having(predicates ...Predicate) SelectQuery
- func (q SelectQuery) IsArray()
- func (q SelectQuery) IsBinary()
- func (q SelectQuery) IsBoolean()
- func (q SelectQuery) IsEnum()
- func (q SelectQuery) IsField()
- func (q SelectQuery) IsJSON()
- func (q SelectQuery) IsNumber()
- func (q SelectQuery) IsString()
- func (q SelectQuery) IsTable()
- func (q SelectQuery) IsTime()
- func (q SelectQuery) IsUUID()
- func (q SelectQuery) Join(table Table, predicates ...Predicate) SelectQuery
- func (q SelectQuery) JoinUsing(table Table, fields ...Field) SelectQuery
- func (q SelectQuery) LeftJoin(table Table, predicates ...Predicate) SelectQuery
- func (q SelectQuery) Limit(limit any) SelectQuery
- func (q SelectQuery) Offset(offset any) SelectQuery
- func (q SelectQuery) OrderBy(fields ...Field) SelectQuery
- func (q SelectQuery) Select(fields ...Field) SelectQuery
- func (q SelectQuery) SelectDistinct(fields ...Field) SelectQuery
- func (q SelectQuery) SelectOne(fields ...Field) SelectQuery
- func (q SelectQuery) SetDialect(dialect string) SelectQuery
- func (q SelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q SelectQuery) Where(predicates ...Predicate) SelectQuery
- func (q SelectQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SelectValues
- func (vs SelectValues) Field(name string) AnyField
- func (vs SelectValues) GetAlias() string
- func (vs SelectValues) GetDialect() string
- func (vs SelectValues) IsTable()
- func (vs SelectValues) SetFetchableFields([]Field) (query Query, ok bool)
- func (vs SelectValues) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SimpleCase
- type SimpleCaseExpression
- func (e SimpleCaseExpression) As(alias string) SimpleCaseExpression
- func (e SimpleCaseExpression) Else(fallback any) SimpleCaseExpression
- func (e SimpleCaseExpression) GetAlias() string
- func (e SimpleCaseExpression) IsArray()
- func (e SimpleCaseExpression) IsBinary()
- func (e SimpleCaseExpression) IsBoolean()
- func (e SimpleCaseExpression) IsEnum()
- func (e SimpleCaseExpression) IsField()
- func (e SimpleCaseExpression) IsJSON()
- func (e SimpleCaseExpression) IsNumber()
- func (e SimpleCaseExpression) IsString()
- func (e SimpleCaseExpression) IsTime()
- func (e SimpleCaseExpression) IsUUID()
- func (e SimpleCaseExpression) When(value any, result any) SimpleCaseExpression
- func (e SimpleCaseExpression) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type SimpleCases
- type SqLogger
- type String
- type StringField
- func (field StringField) As(alias string) StringField
- func (field StringField) Asc() StringField
- func (field StringField) Collate(collation string) StringField
- func (field StringField) Desc() StringField
- func (field StringField) Eq(value String) Predicate
- func (field StringField) EqString(str string) Predicate
- func (field StringField) Ge(value String) Predicate
- func (field StringField) GeString(str string) Predicate
- func (field StringField) GetAlias() string
- func (field StringField) Gt(value String) Predicate
- func (field StringField) GtString(str string) Predicate
- func (field StringField) ILikeString(str string) Predicate
- func (field StringField) In(value any) Predicate
- func (field StringField) IsField()
- func (field StringField) IsNotNull() Predicate
- func (field StringField) IsNull() Predicate
- func (field StringField) IsString()
- func (field StringField) Le(value String) Predicate
- func (field StringField) LeString(str string) Predicate
- func (field StringField) LikeString(str string) Predicate
- func (field StringField) Lt(value String) Predicate
- func (field StringField) LtString(str string) Predicate
- func (field StringField) Ne(value String) Predicate
- func (field StringField) NeString(str string) Predicate
- func (field StringField) NotILikeString(str string) Predicate
- func (field StringField) NotIn(value any) Predicate
- func (field StringField) NotLikeString(str string) Predicate
- func (field StringField) NullsFirst() StringField
- func (field StringField) NullsLast() StringField
- func (field StringField) Set(value any) Assignment
- func (field StringField) SetString(str string) Assignment
- func (field StringField) Setf(format string, values ...any) Assignment
- func (field StringField) WithPrefix(prefix string) Field
- func (field StringField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type StringParameter
- type Table
- type TableStruct
- type TableValues
- func (vs TableValues) Field(name string) AnyField
- func (vs TableValues) GetAlias() string
- func (vs TableValues) GetColumns() []string
- func (vs TableValues) GetDialect() string
- func (vs TableValues) IsTable()
- func (vs TableValues) SetFetchableFields([]Field) (query Query, ok bool)
- func (vs TableValues) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type Time
- type TimeField
- func (field TimeField) As(alias string) TimeField
- func (field TimeField) Asc() TimeField
- func (field TimeField) Desc() TimeField
- func (field TimeField) Eq(value Time) Predicate
- func (field TimeField) EqTime(t time.Time) Predicate
- func (field TimeField) Ge(value Time) Predicate
- func (field TimeField) GeTime(t time.Time) Predicate
- func (field TimeField) GetAlias() string
- func (field TimeField) Gt(value Time) Predicate
- func (field TimeField) GtTime(t time.Time) Predicate
- func (field TimeField) In(value any) Predicate
- func (field TimeField) IsField()
- func (field TimeField) IsNotNull() Predicate
- func (field TimeField) IsNull() Predicate
- func (field TimeField) IsTime()
- func (field TimeField) Le(value Time) Predicate
- func (field TimeField) LeTime(t time.Time) Predicate
- func (field TimeField) Lt(value Time) Predicate
- func (field TimeField) LtTime(t time.Time) Predicate
- func (field TimeField) Ne(value Time) Predicate
- func (field TimeField) NeTime(t time.Time) Predicate
- func (field TimeField) NotIn(value any) Predicate
- func (field TimeField) NullsFirst() TimeField
- func (field TimeField) NullsLast() TimeField
- func (field TimeField) Set(value any) Assignment
- func (field TimeField) SetTime(t time.Time) Assignment
- func (field TimeField) Setf(format string, values ...any) Assignment
- func (field TimeField) WithPrefix(prefix string) Field
- func (field TimeField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type TimeParameter
- type Timestamp
- type UUID
- type UUIDField
- func (field UUIDField) As(alias string) UUIDField
- func (field UUIDField) Asc() UUIDField
- func (field UUIDField) Desc() UUIDField
- func (field UUIDField) Eq(value any) Predicate
- func (field UUIDField) EqUUID(value any) Predicate
- func (field UUIDField) GetAlias() string
- func (field UUIDField) In(value any) Predicate
- func (field UUIDField) IsField()
- func (field UUIDField) IsNotNull() Predicate
- func (field UUIDField) IsNull() Predicate
- func (field UUIDField) IsUUID()
- func (field UUIDField) Ne(value any) Predicate
- func (field UUIDField) NeUUID(value any) Predicate
- func (field UUIDField) NotIn(value any) Predicate
- func (field UUIDField) NullsFirst() UUIDField
- func (field UUIDField) NullsLast() UUIDField
- func (field UUIDField) Set(value any) Assignment
- func (field UUIDField) SetUUID(value any) Assignment
- func (field UUIDField) Setf(format string, values ...any) Assignment
- func (field UUIDField) WithPrefix(prefix string) Field
- func (field UUIDField) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type UUIDParameter
- type UpdateQuery
- func (q UpdateQuery) GetDialect() string
- func (q UpdateQuery) GetFetchableFields() []Field
- func (q UpdateQuery) Set(assignments ...Assignment) UpdateQuery
- func (q UpdateQuery) SetDialect(dialect string) UpdateQuery
- func (q UpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
- func (q UpdateQuery) SetFunc(colmapper func(*Column)) UpdateQuery
- func (q UpdateQuery) Where(predicates ...Predicate) UpdateQuery
- func (q UpdateQuery) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) (err error)
- type ValueExpression
- func (e ValueExpression) As(alias string) ValueExpression
- func (e ValueExpression) Eq(val any) Predicate
- func (e ValueExpression) Ge(val any) Predicate
- func (e ValueExpression) GetAlias() string
- func (e ValueExpression) Gt(val any) Predicate
- func (e ValueExpression) In(val any) Predicate
- func (e ValueExpression) IsArray()
- func (e ValueExpression) IsBinary()
- func (e ValueExpression) IsBoolean()
- func (e ValueExpression) IsEnum()
- func (e ValueExpression) IsField()
- func (e ValueExpression) IsJSON()
- func (e ValueExpression) IsNumber()
- func (e ValueExpression) IsString()
- func (e ValueExpression) IsTime()
- func (e ValueExpression) IsUUID()
- func (e ValueExpression) Le(val any) Predicate
- func (e ValueExpression) Lt(val any) Predicate
- func (e ValueExpression) Ne(val any) Predicate
- func (e ValueExpression) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
- type VariadicPredicate
- type VariadicQuery
- type VariadicQueryOperator
- type ViewStruct
- type Window
- type WindowDefinition
- func (w WindowDefinition) Frame(frameSpec string, frameValues ...any) WindowDefinition
- func (w WindowDefinition) IsWindow()
- func (w WindowDefinition) OrderBy(fields ...Field) WindowDefinition
- func (w WindowDefinition) PartitionBy(fields ...Field) WindowDefinition
- func (w WindowDefinition) WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, ...) error
Constants ¶
const ( JoinInner = "JOIN" JoinLeft = "LEFT JOIN" JoinRight = "RIGHT JOIN" JoinFull = "FULL JOIN" JoinCross = "CROSS JOIN" )
Join operators.
const ( DialectSQLite = "sqlite" DialectPostgres = "postgres" DialectMySQL = "mysql" DialectSQLServer = "sqlserver" )
Dialects supported.
Variables ¶
var ( SQLite sqliteQueryBuilder Postgres postgresQueryBuilder MySQL mysqlQueryBuilder SQLServer sqlserverQueryBuilder )
Dialect-specific query builder variables.
var DefaultDialect atomic.Pointer[string]
Default dialect used by all queries (if no dialect is explicitly provided).
Functions ¶
func ArrayValue ¶
ArrayValue takes in a []string, []int, []int64, []int32, []float64, []float32 or []bool and returns a driver.Valuer for that type. For Postgres, it serializes into a Postgres array. Otherwise, it serializes into a JSON array.
func EnumValue ¶
func EnumValue(value Enumeration) driver.Valuer
EnumValue takes in an Enumeration and returns a driver.Valuer which serializes the enum into a string and additionally checks if the enum is valid.
func EscapeQuote ¶
EscapeQuote will escape the relevant quote in a string by doubling up on it (as per SQL rules).
func FetchAllContext ¶
func FetchAllContext[T any](ctx context.Context, db DB, query Query, rowmapper func(*Row) T) ([]T, error)
FetchAllContext is like FetchAll but additionally requires a context.Context.
func FetchExists ¶
FetchExists returns a boolean indicating if running the given Query on the given DB returned any results.
func FetchExistsContext ¶
FetchExistsContext is like FetchExists but additionally requires a context.Context.
func FetchOneContext ¶
func FetchOneContext[T any](ctx context.Context, db DB, query Query, rowmapper func(*Row) T) (T, error)
FetchOneContext is like FetchOne but additionally requires a context.Context.
func JSONValue ¶
JSONValue takes in an interface{} and returns a driver.Valuer which runs the value through json.Marshal before submitting it to the database.
func New ¶
New instantiates a new table struct with the given alias. Passing in an empty string is equivalent to giving no alias to the table.
func QuoteIdentifier ¶
QuoteIdentifier quotes an identifier if necessary using dialect-specific quoting rules.
func SetDefaultLogQuery ¶ added in v0.4.0
func SetDefaultLogQuery(logQuery func(context.Context, QueryStats))
SetDefaultLogQuery sets the default logging function to call for all queries (if a logger is not explicitly passed in).
func SetDefaultLogSettings ¶ added in v0.4.0
func SetDefaultLogSettings(logSettings func(context.Context, *LogSettings))
SetDefaultLogSettings sets the function to configure the default LogSettings. This value is not used unless SetDefaultLogQuery is also configured.
func Sprint ¶
Sprint is the equivalent of Sprintf but for converting a single value into its SQL representation.
func Sprintf ¶
Sprintf will interpolate SQL args into a query string containing prepared statement parameters. It returns an error if an argument cannot be properly represented in SQL. This function may be vulnerable to SQL injection and should be used for logging purposes only.
func ToSQL ¶
func ToSQL(dialect string, w SQLWriter, params map[string][]int) (query string, args []any, err error)
ToSQL converts an SQLWriter into a query string and args slice.
The params map is used to hold the mappings between named parameters in the query to the corresponding index in the args slice and is used for rebinding args by their parameter name. If you don't need to track this, you can pass in a nil map.
func ToSQLContext ¶
func ToSQLContext(ctx context.Context, dialect string, w SQLWriter, params map[string][]int) (query string, args []any, err error)
ToSQLContext is like ToSQL but additionally requires a context.Context.
func UUIDValue ¶
UUIDValue takes in a type whose underlying type must be a [16]byte and returns a driver.Valuer.
func VerboseLog ¶
VerboseLog wraps a DB and adds verbose logging to it.
func WriteValue ¶
func WriteValue(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, params map[string][]int, value any) error
WriteValue is the equivalent of Writef but for writing a single value into the Output.
func Writef ¶
func Writef(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, params map[string][]int, format string, values []any) error
Writef is a fmt.Sprintf-style function that will write a format string and values slice into an Output. The only recognized placeholder is '{}'. Placeholders can be anonymous (e.g. {}), ordinal (e.g. {1}, {2}, {3}) or named (e.g. {name}, {email}, {age}).
- Anonymous placeholders refer to successive values in the values slice. Anonymous placeholders are treated like a series of incrementing ordinal placeholders.
- Ordinal placeholders refer to a specific value in the values slice using 1-based indexing.
- Named placeholders refer to their corresponding sql.NamedArg value in the values slice. If there are multiple sql.NamedArg values with the same name, the last one wins.
If a value is an SQLWriter, its WriteSQL method will be called. Else if a value is a slice, it will undergo slice expansion (https://bokwoon.neocities.org/sq.html#value-expansion). Otherwise, the value is added to the query args slice.
Types ¶
type AnyField ¶
type AnyField struct {
// contains filtered or unexported fields
}
AnyField is a catch-all field type that satisfies the Any interface.
func NewAnyField ¶
func NewAnyField(name string, tbl TableStruct) AnyField
NewAnyField returns a new AnyField.
func (AnyField) Asc ¶
Asc returns a new AnyField indicating that it should be ordered in ascending order i.e. 'ORDER BY field ASC'.
func (AnyField) Desc ¶
Desc returns a new AnyField indicating that it should be ordered in descending order i.e. 'ORDER BY field DESC'.
func (AnyField) Expr ¶
func (field AnyField) Expr(format string, values ...any) Expression
Expr returns an expression where the field is prepended to the front of the expression.
func (AnyField) In ¶
In returns a 'field IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field IN (x, y, z)'.
func (AnyField) IsBinary ¶
func (field AnyField) IsBinary()
IsBinary implements the Binary interface.
func (AnyField) IsBoolean ¶
func (field AnyField) IsBoolean()
IsBoolean implements the Boolean interface.
func (AnyField) IsNumber ¶
func (field AnyField) IsNumber()
IsNumber implements the Number interface.
func (AnyField) IsString ¶
func (field AnyField) IsString()
IsString implements the String interface.
func (AnyField) NotIn ¶ added in v0.3.0
In returns a 'field NOT IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field NOT IN (x, y, z)'.
func (AnyField) NullsFirst ¶
NullsFirst returns a new NumberField indicating that it should be ordered with nulls first i.e. 'ORDER BY field NULLS FIRST'.
func (AnyField) NullsLast ¶
NullsLast returns a new NumberField indicating that it should be ordered with nulls last i.e. 'ORDER BY field NULLS LAST'.
func (AnyField) Set ¶
func (field AnyField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (AnyField) Setf ¶
func (field AnyField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (AnyField) WithPrefix ¶
WithPrefix returns a new Field that with the given prefix.
type ArrayField ¶
type ArrayField struct {
// contains filtered or unexported fields
}
ArrayField represents an SQL array field.
func NewArrayField ¶
func NewArrayField(fieldName string, tableName TableStruct) ArrayField
NewArrayField returns a new ArrayField.
func (ArrayField) As ¶
func (field ArrayField) As(alias string) ArrayField
As returns a new ArrayField with the given alias.
func (ArrayField) GetAlias ¶
func (field ArrayField) GetAlias() string
GetAlias returns the alias of the ArrayField.
func (ArrayField) IsArray ¶
func (field ArrayField) IsArray()
IsArray implements the Array interface.
func (ArrayField) IsField ¶
func (field ArrayField) IsField()
IsField implements the Field interface.
func (ArrayField) IsNotNull ¶
func (field ArrayField) IsNotNull() Predicate
IsNull returns a 'field IS NOT NULL' Predicate.
func (ArrayField) IsNull ¶
func (field ArrayField) IsNull() Predicate
IsNull returns a 'field IS NULL' Predicate.
func (ArrayField) Set ¶
func (field ArrayField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (ArrayField) SetArray ¶
func (field ArrayField) SetArray(value any) Assignment
SetArray returns an Assignment assigning the value to the field. It wraps the value with ArrayValue().
func (ArrayField) Setf ¶
func (field ArrayField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (ArrayField) WithPrefix ¶
func (field ArrayField) WithPrefix(prefix string) Field
WithPrefix returns a new Field that with the given prefix.
type ArrayParameter ¶ added in v0.3.5
ArrayParameter is identical to sql.NamedArg, but implements the Array interface.
func ArrayParam ¶ added in v0.3.5
func ArrayParam(name string, value any) ArrayParameter
ArrayParam creates a new ArrayParameter. It wraps the value with ArrayValue().
func (ArrayParameter) IsArray ¶ added in v0.3.5
func (p ArrayParameter) IsArray()
IsArray implements the Array interface.
func (ArrayParameter) IsField ¶ added in v0.3.5
func (p ArrayParameter) IsField()
IsField implements the Field interface.
type Assignment ¶
type Assignment interface { SQLWriter IsAssignment() }
Assignment is an SQL assignment 'field = value'.
func Set ¶
func Set(field Field, value any) Assignment
Set creates a new Assignment assigning the value to a field.
type Assignments ¶
type Assignments []Assignment
Assignments represents a list of Assignments e.g. x = 1, y = 2, z = 3.
type BinaryField ¶
type BinaryField struct {
// contains filtered or unexported fields
}
BinaryField represents an SQL binary field.
func NewBinaryField ¶
func NewBinaryField(fieldName string, tableName TableStruct) BinaryField
NewBinaryField returns a new BinaryField.
func (BinaryField) As ¶
func (field BinaryField) As(alias string) BinaryField
As returns a new BinaryField with the given alias.
func (BinaryField) Asc ¶
func (field BinaryField) Asc() BinaryField
Asc returns a new BinaryField indicating that it should be ordered in ascending order i.e. 'ORDER BY field ASC'.
func (BinaryField) Desc ¶
func (field BinaryField) Desc() BinaryField
Desc returns a new BinaryField indicating that it should be ordered in ascending order i.e. 'ORDER BY field DESC'.
func (BinaryField) Eq ¶
func (field BinaryField) Eq(value Binary) Predicate
Eq returns a 'field = value' Predicate.
func (BinaryField) EqBytes ¶
func (field BinaryField) EqBytes(b []byte) Predicate
EqBytes returns a 'field = b' Predicate.
func (BinaryField) GetAlias ¶
func (field BinaryField) GetAlias() string
GetAlias returns the alias of the BinaryField.
func (BinaryField) IsBinary ¶
func (field BinaryField) IsBinary()
IsBinary implements the Binary interface.
func (BinaryField) IsField ¶
func (field BinaryField) IsField()
IsField implements the Field interface.
func (BinaryField) IsNotNull ¶
func (field BinaryField) IsNotNull() Predicate
IsNotNull returns a 'field IS NOT NULL' Predicate.
func (BinaryField) IsNull ¶
func (field BinaryField) IsNull() Predicate
IsNull returns a 'field IS NULL' Predicate.
func (BinaryField) Ne ¶
func (field BinaryField) Ne(value Binary) Predicate
Ne returns a 'field <> value' Predicate.
func (BinaryField) NeBytes ¶
func (field BinaryField) NeBytes(b []byte) Predicate
NeBytes returns a 'field <> b' Predicate.
func (BinaryField) NullsFirst ¶
func (field BinaryField) NullsFirst() BinaryField
NullsFirst returns a new BinaryField indicating that it should be ordered with nulls first i.e. 'ORDER BY field NULLS FIRST'.
func (BinaryField) NullsLast ¶
func (field BinaryField) NullsLast() BinaryField
NullsLast returns a new BinaryField indicating that it should be ordered with nulls last i.e. 'ORDER BY field NULLS LAST'.
func (BinaryField) Set ¶
func (field BinaryField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (BinaryField) SetBytes ¶
func (field BinaryField) SetBytes(b []byte) Assignment
SetBytes returns an Assignment assigning a []byte to the field.
func (BinaryField) Setf ¶
func (field BinaryField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (BinaryField) WithPrefix ¶
func (field BinaryField) WithPrefix(prefix string) Field
WithPrefix returns a new Field that with the given prefix.
type BinaryParameter ¶
BinaryParameter is identical to sql.NamedArg, but implements the Binary interface.
func BytesParam ¶
func BytesParam(name string, b []byte) BinaryParameter
BytesParam creates a new BinaryParameter using a []byte value.
func (BinaryParameter) IsBinary ¶
func (p BinaryParameter) IsBinary()
IsBinary implements the Binary interface.
func (BinaryParameter) IsField ¶
func (p BinaryParameter) IsField()
IsField implements the Field interface.
type BooleanField ¶
type BooleanField struct {
// contains filtered or unexported fields
}
BooleanField represents an SQL boolean field.
func NewBooleanField ¶
func NewBooleanField(fieldName string, tableName TableStruct) BooleanField
NewBooleanField returns a new BooleanField.
func (BooleanField) As ¶
func (field BooleanField) As(alias string) BooleanField
As returns a new BooleanField with the given alias.
func (BooleanField) Asc ¶
func (field BooleanField) Asc() BooleanField
Asc returns a new BooleanField indicating that it should be ordered in ascending order i.e. 'ORDER BY field ASC'.
func (BooleanField) Desc ¶
func (f BooleanField) Desc() BooleanField
Desc returns a new BooleanField indicating that it should be ordered in descending order i.e. 'ORDER BY field DESC'.
func (BooleanField) Eq ¶
func (field BooleanField) Eq(value Boolean) Predicate
Eq returns a 'field = value' Predicate.
func (BooleanField) EqBool ¶
func (field BooleanField) EqBool(b bool) Predicate
EqBool returns a 'field = b' Predicate.
func (BooleanField) GetAlias ¶
func (field BooleanField) GetAlias() string
GetAlias returns the alias of the BooleanField.
func (BooleanField) IsBoolean ¶
func (field BooleanField) IsBoolean()
IsBoolean implements the Boolean interface.
func (BooleanField) IsField ¶
func (field BooleanField) IsField()
IsField implements the Field interface.
func (BooleanField) IsNotNull ¶
func (field BooleanField) IsNotNull() Predicate
IsNotNull returns a 'field IS NOT NULL' Predicate.
func (BooleanField) IsNull ¶
func (field BooleanField) IsNull() Predicate
IsNull returns a 'field IS NULL' Predicate.
func (BooleanField) Ne ¶
func (field BooleanField) Ne(value Boolean) Predicate
Ne returns a 'field <> value' Predicate.
func (BooleanField) NeBool ¶
func (field BooleanField) NeBool(b bool) Predicate
NeBool returns a 'field <> b' Predicate.
func (BooleanField) NullsFirst ¶
func (field BooleanField) NullsFirst() BooleanField
NullsFirst returns a new BooleanField indicating that it should be ordered with nulls first i.e. 'ORDER BY field NULLS FIRST'.
func (BooleanField) NullsLast ¶
func (field BooleanField) NullsLast() BooleanField
NullsLast returns a new BooleanField indicating that it should be ordered with nulls last i.e. 'ORDER BY field NULLS LAST'.
func (BooleanField) Set ¶
func (field BooleanField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (BooleanField) SetBool ¶
func (field BooleanField) SetBool(b bool) Assignment
SetBool returns an Assignment assigning a bool to the field i.e. 'field = b'.
func (BooleanField) Setf ¶
func (field BooleanField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (BooleanField) WithPrefix ¶
func (field BooleanField) WithPrefix(prefix string) Field
WithPrefix returns a new Field that with the given prefix.
type BooleanParameter ¶
BooleanParameter is identical to sql.NamedArg, but implements the Boolean interface.
func BoolParam ¶
func BoolParam(name string, b bool) BooleanParameter
BoolParam creates a new BooleanParameter from a bool value.
func (BooleanParameter) IsBoolean ¶
func (p BooleanParameter) IsBoolean()
IsBoolean implements the Boolean interface.
func (BooleanParameter) IsField ¶
func (p BooleanParameter) IsField()
IsField implements the Field interface.
type CTE ¶
type CTE struct {
// contains filtered or unexported fields
}
CTE represents an SQL common table expression (CTE).
func NewRecursiveCTE ¶
NewRecursiveCTE creates a new recursive CTE.
func (CTE) Materialized ¶
Materialized returns a new CTE marked as MATERIALIZED. This only works on postgres.
func (CTE) NotMaterialized ¶
Materialized returns a new CTE marked as NOT MATERIALIZED. This only works on postgres.
type CaseExpression ¶
type CaseExpression struct { Cases PredicateCases Default any // contains filtered or unexported fields }
CaseExpression represents an SQL CASE expression.
func CaseWhen ¶
func CaseWhen(predicate Predicate, result any) CaseExpression
CaseWhen returns a new CaseExpression.
func (CaseExpression) As ¶
func (e CaseExpression) As(alias string) CaseExpression
As returns a new CaseExpression with the given alias.
func (CaseExpression) Else ¶
func (e CaseExpression) Else(fallback any) CaseExpression
Else sets the fallback result of the CaseExpression.
func (CaseExpression) GetAlias ¶
func (e CaseExpression) GetAlias() string
GetAlias returns the alias of the CaseExpression.
func (CaseExpression) IsArray ¶
func (e CaseExpression) IsArray()
IsArray implements the Array interface.
func (CaseExpression) IsBinary ¶
func (e CaseExpression) IsBinary()
IsBinary implements the Binary interface.
func (CaseExpression) IsBoolean ¶
func (e CaseExpression) IsBoolean()
IsBoolean implements the Boolean interface.
func (CaseExpression) IsEnum ¶
func (e CaseExpression) IsEnum()
IsEnum implements the Enum interface.
func (CaseExpression) IsField ¶
func (e CaseExpression) IsField()
IsField implements the Field interface.
func (CaseExpression) IsJSON ¶
func (e CaseExpression) IsJSON()
IsJSON implements the JSON interface.
func (CaseExpression) IsNumber ¶
func (e CaseExpression) IsNumber()
IsNumber implements the Number interface.
func (CaseExpression) IsString ¶
func (e CaseExpression) IsString()
IsString implements the String interface.
func (CaseExpression) IsTime ¶
func (e CaseExpression) IsTime()
IsTime implements the Time interface.
func (CaseExpression) IsUUID ¶
func (e CaseExpression) IsUUID()
IsUUID implements the UUID interface.
func (CaseExpression) When ¶
func (e CaseExpression) When(predicate Predicate, result any) CaseExpression
When adds a new predicate-result pair to the CaseExpression.
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
Column keeps track of what the values mapped to what Field in an InsertQuery or SelectQuery.
func (*Column) SetArray ¶
SetArray maps the array value to the field. The value should be []string, []int, []int64, []int32, []float64, []float32 or []bool.
func (*Column) SetEnum ¶
func (col *Column) SetEnum(field Enum, value Enumeration)
SetEnum maps the enum value to the field.
func (*Column) SetFloat64 ¶
SetFloat64 maps the float64 value to the field.
func (*Column) SetJSON ¶
SetJSON maps the JSON value to the field. The value should be able to be convertible to JSON using json.Marshal.
type CompiledExec ¶
type CompiledExec struct {
// contains filtered or unexported fields
}
CompiledExec is the result of compiling a Query down into a query string and args slice. A CompiledExec can be safely executed in parallel.
func CompileExec ¶
func CompileExec(query Query) (*CompiledExec, error)
CompileExec returns a new CompiledExec.
func CompileExecContext ¶
func CompileExecContext(ctx context.Context, query Query) (*CompiledExec, error)
CompileExecContext is like CompileExec but additionally requires a context.Context.
func NewCompiledExec ¶
func NewCompiledExec(dialect string, query string, args []any, params map[string][]int) *CompiledExec
NewCompiledExec returns a new CompiledExec.
func (*CompiledExec) Exec ¶
func (compiledExec *CompiledExec) Exec(db DB, params Params) (Result, error)
Exec executes the CompiledExec on the given DB with the given params.
func (*CompiledExec) ExecContext ¶
func (compiledExec *CompiledExec) ExecContext(ctx context.Context, db DB, params Params) (Result, error)
ExecContext is like Exec but additionally requires a context.Context.
func (*CompiledExec) GetSQL ¶
func (compiledExec *CompiledExec) GetSQL() (dialect string, query string, args []any, params map[string][]int)
GetSQL returns a copy of the dialect, query, args, params and rowmapper that make up the CompiledExec.
func (*CompiledExec) Prepare ¶
func (compiledExec *CompiledExec) Prepare(db DB) (*PreparedExec, error)
Prepare creates a PreparedExec from a CompiledExec by preparing it on the given DB.
func (*CompiledExec) PrepareContext ¶
func (compiledExec *CompiledExec) PrepareContext(ctx context.Context, db DB) (*PreparedExec, error)
PrepareContext is like Prepare but additionally requires a context.Context.
type CompiledFetch ¶
type CompiledFetch[T any] struct { // contains filtered or unexported fields }
CompiledFetch is the result of compiling a Query down into a query string and args slice. A CompiledFetch can be safely executed in parallel.
func CompileFetch ¶
func CompileFetch[T any](q Query, rowmapper func(*Row) T) (*CompiledFetch[T], error)
CompileFetch returns a new CompileFetch.
func CompileFetchContext ¶
func CompileFetchContext[T any](ctx context.Context, query Query, rowmapper func(*Row) T) (compiledFetch *CompiledFetch[T], err error)
CompileFetchContext is like CompileFetch but accepts a context.Context.
func NewCompiledFetch ¶
func NewCompiledFetch[T any](dialect string, query string, args []any, params map[string][]int, rowmapper func(*Row) T) *CompiledFetch[T]
NewCompiledFetch returns a new CompiledFetch.
func (*CompiledFetch[T]) FetchAll ¶
func (compiledFetch *CompiledFetch[T]) FetchAll(db DB, params Params) ([]T, error)
FetchAll returns all the results from running the CompiledFetch on the given DB with the give params.
func (*CompiledFetch[T]) FetchAllContext ¶
func (compiledFetch *CompiledFetch[T]) FetchAllContext(ctx context.Context, db DB, params Params) ([]T, error)
FetchAllContext is like FetchAll but additionally requires a context.Context.
func (*CompiledFetch[T]) FetchCursor ¶
func (compiledFetch *CompiledFetch[T]) FetchCursor(db DB, params Params) (*Cursor[T], error)
FetchCursor returns a new cursor.
func (*CompiledFetch[T]) FetchCursorContext ¶
func (compiledFetch *CompiledFetch[T]) FetchCursorContext(ctx context.Context, db DB, params Params) (*Cursor[T], error)
FetchCursorContext is like FetchCursor but additionally requires a context.Context.
func (*CompiledFetch[T]) FetchOne ¶
func (compiledFetch *CompiledFetch[T]) FetchOne(db DB, params Params) (T, error)
FetchOne returns the first result from running the CompiledFetch on the given DB with the give params.
func (*CompiledFetch[T]) FetchOneContext ¶
func (compiledFetch *CompiledFetch[T]) FetchOneContext(ctx context.Context, db DB, params Params) (T, error)
FetchOneContext is like FetchOne but additionally requires a context.Context.
func (*CompiledFetch[T]) GetSQL ¶
func (compiledFetch *CompiledFetch[T]) GetSQL() (dialect string, query string, args []any, params map[string][]int, rowmapper func(*Row) T)
GetSQL returns a copy of the dialect, query, args, params and rowmapper that make up the CompiledFetch.
func (*CompiledFetch[T]) Prepare ¶
func (compiledFetch *CompiledFetch[T]) Prepare(db DB) (*PreparedFetch[T], error)
Prepare creates a PreparedFetch from a CompiledFetch by preparing it on the given DB.
func (*CompiledFetch[T]) PrepareContext ¶
func (compiledFetch *CompiledFetch[T]) PrepareContext(ctx context.Context, db DB) (*PreparedFetch[T], error)
PrepareContext is like Prepare but additionally requires a context.Context.
type ConflictClause ¶
type ConflictClause struct { ConstraintName string Fields []Field Predicate Predicate DoNothing bool Resolution []Assignment ResolutionPredicate Predicate }
ConflictClause represents an SQL conflict clause e.g. ON CONFLICT DO NOTHING/DO UPDATE or ON DUPLICATE KEY UPDATE.
type Cursor ¶
type Cursor[T any] struct { // contains filtered or unexported fields }
A Cursor represents a database cursor.
func FetchCursor ¶
FetchCursor returns a new cursor.
func FetchCursorContext ¶
func FetchCursorContext[T any](ctx context.Context, db DB, query Query, rowmapper func(*Row) T) (*Cursor[T], error)
FetchCursorContext is like FetchCursor but additionally requires a context.Context.
type CustomQuery ¶
type CustomQuery struct { Dialect string Format string Values []any // contains filtered or unexported fields }
CustomQuery represents a user-defined query.
func Queryf ¶
func Queryf(format string, values ...any) CustomQuery
Queryf creates a new query using Writef syntax.
func (CustomQuery) Append ¶ added in v0.2.7
func (q CustomQuery) Append(format string, values ...any) CustomQuery
Append returns a new CustomQuery with the format string and values slice appended to the current CustomQuery.
func (CustomQuery) GetDialect ¶
func (q CustomQuery) GetDialect() string
GetDialect gets the dialect of the query.
func (CustomQuery) GetFetchableFields ¶
func (q CustomQuery) GetFetchableFields() []Field
GetFetchableFields gets the fetchable fields of the query.
func (CustomQuery) SetDialect ¶
func (q CustomQuery) SetDialect(dialect string) CustomQuery
SetDialect sets the dialect of the query.
func (CustomQuery) SetFetchableFields ¶
func (q CustomQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields sets the fetchable fields of the query.
type DB ¶
type DB interface { QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) }
DB is a database/sql abstraction that can query the database. *sql.Conn, *sql.DB and *sql.Tx all implement DB.
type DeleteQuery ¶
type DeleteQuery struct { Dialect string // WITH CTEs []CTE // DELETE FROM DeleteTable Table DeleteTables []Table // USING UsingTable Table JoinTables []JoinTable // WHERE WherePredicate Predicate // ORDER BY OrderByFields Fields // LIMIT LimitRows any // OFFSET OffsetRows any // RETURNING ReturningFields []Field }
DeleteQuery represents an SQL DELETE query.
func (DeleteQuery) GetDialect ¶
func (q DeleteQuery) GetDialect() string
GetDialect implements the Query interface.
func (DeleteQuery) GetFetchableFields ¶
func (q DeleteQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (DeleteQuery) SetDialect ¶
func (q DeleteQuery) SetDialect(dialect string) DeleteQuery
SetDialect sets the dialect of the query.
func (DeleteQuery) SetFetchableFields ¶
func (q DeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (DeleteQuery) Where ¶
func (q DeleteQuery) Where(predicates ...Predicate) DeleteQuery
Where appends to the WherePredicate field of the DeleteQuery.
type DialectCase ¶
DialectCase holds the result to be used for a given dialect in a DialectExpression.
type DialectExpression ¶
type DialectExpression struct { Default any Cases DialectCases }
DialectExpression represents an SQL expression that renders differently depending on the dialect.
func DialectExpr ¶
func DialectExpr(format string, values ...any) DialectExpression
DialectExpr returns a new DialectExpression. The expression passed in is used as the default.
func DialectValue ¶
func DialectValue(value any) DialectExpression
DialectValue returns a new DialectExpression. The value passed in is used as the default.
func (DialectExpression) DialectExpr ¶
func (e DialectExpression) DialectExpr(dialect string, format string, values ...any) DialectExpression
DialectExpr adds a new dialect-expression pair to the DialectExpression.
func (DialectExpression) DialectValue ¶
func (e DialectExpression) DialectValue(dialect string, value any) DialectExpression
DialectValue adds a new dialect-value pair to the DialectExpression.
func (DialectExpression) IsArray ¶
func (e DialectExpression) IsArray()
IsArray implements the Array interface.
func (DialectExpression) IsBinary ¶
func (e DialectExpression) IsBinary()
IsBinary implements the Binary interface.
func (DialectExpression) IsBoolean ¶
func (e DialectExpression) IsBoolean()
IsBoolean implements the Boolean interface.
func (DialectExpression) IsEnum ¶
func (e DialectExpression) IsEnum()
IsEnum implements the Enum interface.
func (DialectExpression) IsField ¶
func (e DialectExpression) IsField()
IsField implements the Field interface.
func (DialectExpression) IsJSON ¶
func (e DialectExpression) IsJSON()
IsJSON implements the JSON interface.
func (DialectExpression) IsNumber ¶
func (e DialectExpression) IsNumber()
IsNumber implements the Number interface.
func (DialectExpression) IsString ¶
func (e DialectExpression) IsString()
IsString implements the String interface.
func (DialectExpression) IsTable ¶
func (e DialectExpression) IsTable()
IsTable implements the Table interface.
func (DialectExpression) IsTime ¶
func (e DialectExpression) IsTime()
IsTime implements the Time interface.
func (DialectExpression) IsUUID ¶
func (e DialectExpression) IsUUID()
IsUUID implements the UUID interface.
type DialectValuer ¶
DialectValuer is any type that will yield a different driver.Valuer depending on the SQL dialect.
type EnumField ¶
type EnumField struct {
// contains filtered or unexported fields
}
EnumField represents an SQL enum field.
func NewEnumField ¶
func NewEnumField(name string, tbl TableStruct) EnumField
NewEnumField returns a new EnumField.
func (EnumField) EqEnum ¶ added in v0.2.1
func (field EnumField) EqEnum(value Enumeration) Predicate
EqEnum returns a 'field = value' Predicate. It wraps the value with EnumValue().
func (EnumField) In ¶ added in v0.3.0
In returns a 'field IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field IN (x, y, z)'.
func (EnumField) NeEnum ¶ added in v0.2.1
func (field EnumField) NeEnum(value Enumeration) Predicate
NeEnum returns a 'field <> value' Predicate. it wraps the value with EnumValue().
func (EnumField) NotIn ¶ added in v0.3.0
NotIn returns a 'field NOT IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field NOT IN (x, y, z)'.
func (EnumField) Set ¶
func (field EnumField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (EnumField) SetEnum ¶
func (field EnumField) SetEnum(value Enumeration) Assignment
SetEnum returns an Assignment assigning the value to the field. It wraps the value with EnumValue().
func (EnumField) Setf ¶
func (field EnumField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (EnumField) WithPrefix ¶
WithPrefix returns a new Field that with the given prefix.
type EnumParameter ¶ added in v0.3.5
EnumParameter is identical to sql.NamedArg, but implements the Enum interface.
func EnumParam ¶ added in v0.3.5
func EnumParam(name string, value Enumeration) EnumParameter
EnumParam creates a new EnumParameter. It wraps the value with EnumValue().
func (EnumParameter) IsEnum ¶ added in v0.3.5
func (p EnumParameter) IsEnum()
IsEnum implements the Enum interface.
func (EnumParameter) IsField ¶ added in v0.3.5
func (p EnumParameter) IsField()
IsField implements the Field interface.
type Enumeration ¶
type Enumeration interface { // Enumerate returns the names of all valid enum values. // // If the enum is backed by a string, each string in the slice is the // corresponding enum's string value. // // If the enum is backed by an int, each int index in the slice is the // corresponding enum's int value and the string is the enum's name. Enums // with empty string names are considered invalid, unless it is the very // first enum (at index 0). Enumerate() []string }
Enumeration represents a Go enum.
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
Expression is an SQL expression that satisfies the Table, Field, Predicate, Binary, Boolean, Number, String and Time interfaces.
func AvgOver ¶
func AvgOver(num Number, window Window) Expression
AvgOver represents the AVG(<num>) OVER (<window>) window function.
func CountOver ¶
func CountOver(field Field, window Window) Expression
CountOver represents the COUNT(<field>) OVER (<window>) window function.
func CountStarOver ¶
func CountStarOver(window Window) Expression
CountStarOver represents the COUNT(*) OVER (<window>) window function.
func CumeDistOver ¶
func CumeDistOver(window Window) Expression
CumeDistOver represents the CUME_DIST() OVER (<window>) window function.
func DenseRankOver ¶
func DenseRankOver(window Window) Expression
DenseRankOver represents the DENSE_RANK() OVER (<window>) window function.
func Expr ¶
func Expr(format string, values ...any) Expression
Expr creates a new Expression using Writef syntax.
func FirstValueOver ¶
func FirstValueOver(field Field, window Window) Expression
FirstValueOver represents the FIRST_VALUE(<field>) OVER (<window>) window function.
func LastValueOver ¶
func LastValueOver(field Field, window Window) Expression
LastValueOver represents the LAST_VALUE(<field>) OVER (<window>) window function.
func MaxOver ¶
func MaxOver(field Field, window Window) Expression
MaxOver represents the MAX(<field>) OVER (<window>) window function.
func MinOver ¶
func MinOver(field Field, window Window) Expression
MinOver represents the MIN(<field>) OVER (<window>) window function.
func RankOver ¶
func RankOver(window Window) Expression
RankOver represents the RANK() OVER (<window>) window function.
func RowNumberOver ¶
func RowNumberOver(window Window) Expression
RowNumberOver represents the ROW_NUMBER() OVER (<window>) window function.
func SumOver ¶
func SumOver(num Number, window Window) Expression
SumOver represents the SUM(<num>) OVER (<window>) window function.
func (Expression) As ¶
func (expr Expression) As(alias string) Expression
As returns a new Expression with the given alias.
func (Expression) Eq ¶
func (expr Expression) Eq(value any) Predicate
Eq returns an 'expr = value' Predicate.
func (Expression) Ge ¶
func (expr Expression) Ge(value any) Predicate
Ge returns an 'expr >= value' Predicate.
func (Expression) GetAlias ¶
func (expr Expression) GetAlias() string
GetAlias returns the alias of the Expression.
func (Expression) Gt ¶
func (expr Expression) Gt(value any) Predicate
Gt returns an 'expr > value' Predicate.
func (Expression) In ¶
func (expr Expression) In(value any) Predicate
In returns an 'expr IN (value)' Predicate.
func (Expression) IsArray ¶
func (expr Expression) IsArray()
IsArray implements the Array interface.
func (Expression) IsAssignment ¶
func (e Expression) IsAssignment()
func (Expression) IsBinary ¶
func (expr Expression) IsBinary()
IsBinary implements the Binary interface.
func (Expression) IsBoolean ¶
func (expr Expression) IsBoolean()
IsBoolean implements the Boolean interface.
func (Expression) IsField ¶
func (expr Expression) IsField()
IsField implements the Field interface.
func (Expression) IsNumber ¶
func (expr Expression) IsNumber()
IsNumber implements the Number interface.
func (Expression) IsString ¶
func (expr Expression) IsString()
IsString implements the String interface.
func (Expression) IsTable ¶
func (expr Expression) IsTable()
IsTable implements the Table interface.
func (Expression) Le ¶
func (expr Expression) Le(value any) Predicate
Le returns an 'expr <= value' Predicate.
func (Expression) Lt ¶
func (expr Expression) Lt(value any) Predicate
Lt returns an 'expr < value' Predicate.
func (Expression) Ne ¶
func (expr Expression) Ne(value any) Predicate
Ne returns an 'expr <> value' Predicate.
func (Expression) NotIn ¶ added in v0.3.0
func (expr Expression) NotIn(value any) Predicate
In returns an 'expr NOT IN (value)' Predicate.
type Field ¶
type Field interface { SQLWriter IsField() }
Field is either a table column or some SQL expression.
type Fields ¶
type Fields []Field
Fields represents a list of Fields e.g. tbl.field1, tbl.field2, tbl.field3.
type Identifier ¶
type Identifier string
Identifier represents an SQL identifier. If necessary, it will be quoted according to the dialect.
type InsertQuery ¶
type InsertQuery struct { Dialect string ColumnMapper func(*Column) // WITH CTEs []CTE // INSERT INTO InsertIgnore bool InsertTable Table InsertColumns []Field // VALUES RowValues []RowValue RowAlias string // SELECT SelectQuery Query // ON CONFLICT Conflict ConflictClause // RETURNING ReturningFields []Field }
InsertQuery represents an SQL INSERT query.
func (InsertQuery) ColumnValues ¶
func (q InsertQuery) ColumnValues(colmapper func(*Column)) InsertQuery
ColumnValues sets the ColumnMapper field of the InsertQuery.
func (InsertQuery) Columns ¶
func (q InsertQuery) Columns(fields ...Field) InsertQuery
Columns sets the InsertColumns field of the InsertQuery.
func (InsertQuery) GetDialect ¶
func (q InsertQuery) GetDialect() string
GetDialect implements the Query interface.
func (InsertQuery) GetFetchableFields ¶
func (q InsertQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (InsertQuery) Select ¶
func (q InsertQuery) Select(query Query) InsertQuery
Select sets the SelectQuery field of the InsertQuery.
func (InsertQuery) SetDialect ¶
func (q InsertQuery) SetDialect(dialect string) InsertQuery
SetDialect sets the dialect of the query.
func (InsertQuery) SetFetchableFields ¶
func (q InsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (InsertQuery) Values ¶
func (q InsertQuery) Values(values ...any) InsertQuery
Values sets the RowValues field of the InsertQuery.
type JSONField ¶
type JSONField struct {
// contains filtered or unexported fields
}
JSONField represents an SQL JSON field.
func NewJSONField ¶
func NewJSONField(name string, tbl TableStruct) JSONField
NewJSONField returns a new JSONField.
func (JSONField) IsBinary ¶ added in v0.2.2
func (field JSONField) IsBinary()
IsBinary implements the Binary interface.
func (JSONField) IsString ¶ added in v0.2.2
func (field JSONField) IsString()
IsString implements the String interface.
func (JSONField) Set ¶
func (field JSONField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (JSONField) SetJSON ¶
func (field JSONField) SetJSON(value any) Assignment
SetJSON returns an Assignment assigning the value to the field. It wraps the value in JSONValue().
func (JSONField) Setf ¶
func (field JSONField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (JSONField) WithPrefix ¶
WithPrefix returns a new Field that with the given prefix.
type JSONParameter ¶ added in v0.3.5
JSONParameter is identical to sql.NamedArg, but implements the JSON interface.
func JSONParam ¶ added in v0.3.5
func JSONParam(name string, value any) JSONParameter
JSONParam creates a new JSONParameter. It wraps the value with JSONValue().
func (JSONParameter) IsField ¶ added in v0.3.5
func (p JSONParameter) IsField()
IsField implements the Field interface.
func (JSONParameter) IsJSON ¶ added in v0.3.5
func (p JSONParameter) IsJSON()
IsJSON implements the JSON interface.
type JoinTable ¶
JoinTable represents a join on a table.
func CustomJoin ¶
CustomJoin creates a new JoinTable with the a custom join operator.
type LiteralValue ¶
type LiteralValue struct {
// contains filtered or unexported fields
}
LiteralValue represents an SQL value literally interpolated into the query. Doing so potentially exposes the query to SQL injection so only do this for values that you trust e.g. literals and constants.
func (LiteralValue) As ¶
func (v LiteralValue) As(alias string) LiteralValue
As returns a new LiteralValue with the given alias.
func (LiteralValue) Eq ¶
func (v LiteralValue) Eq(val any) Predicate
Eq returns a 'literal = val' Predicate.
func (LiteralValue) Ge ¶
func (v LiteralValue) Ge(val any) Predicate
Ge returns a 'literal >= val' Predicate.
func (LiteralValue) GetAlias ¶
func (v LiteralValue) GetAlias() string
GetAlias returns the alias of the LiteralValue.
func (LiteralValue) Gt ¶
func (v LiteralValue) Gt(val any) Predicate
Gt returns a 'literal > val' Predicate.
func (LiteralValue) In ¶
func (v LiteralValue) In(val any) Predicate
In returns a 'literal IN (val)' Predicate.
func (LiteralValue) IsBinary ¶
func (v LiteralValue) IsBinary()
IsBinary implements the Binary interface.
func (LiteralValue) IsBoolean ¶
func (v LiteralValue) IsBoolean()
IsBoolean implements the Boolean interface.
func (LiteralValue) IsField ¶
func (v LiteralValue) IsField()
IsField implements the Field interface.
func (LiteralValue) IsNumber ¶
func (v LiteralValue) IsNumber()
IsNumber implements the Number interface.
func (LiteralValue) IsString ¶
func (v LiteralValue) IsString()
IsString implements the String interface.
func (LiteralValue) Le ¶
func (v LiteralValue) Le(val any) Predicate
Le returns a 'literal <= val' Predicate.
func (LiteralValue) Lt ¶
func (v LiteralValue) Lt(val any) Predicate
Lt returns a 'literal < val' Predicate.
func (LiteralValue) Ne ¶
func (v LiteralValue) Ne(val any) Predicate
Ne returns a 'literal <> val' Predicate.
type LogSettings ¶
type LogSettings struct { // Dispatch logging asynchronously (logs may arrive out of order which can be confusing, but it won't block function calls). LogAsynchronously bool // Include time taken by the query. IncludeTime bool // Include caller (filename and line number). IncludeCaller bool // Include fetched results. IncludeResults int }
LogSettings are the various log settings taken into account when producing the QueryStats.
type LoggerConfig ¶
type LoggerConfig struct { // Dispatch logging asynchronously (logs may arrive out of order which can be confusing, but it won't block function calls). LogAsynchronously bool // Show time taken by the query. ShowTimeTaken bool // Show caller (filename and line number). ShowCaller bool // Show fetched results. ShowResults int // If true, logs are shown as plaintext (no color). NoColor bool // Verbose query interpolation, which shows the query before and after // interpolating query arguments. The logged query is interpolated by // default, InterpolateVerbose only controls whether the query before // interpolation is shown. To disable query interpolation entirely, look at // HideArgs. InterpolateVerbose bool // Explicitly hides arguments when logging the query (only the query // placeholders will be shown). HideArgs bool }
LoggerConfig is the config used for the sq logger.
type MySQLDeleteQuery ¶
type MySQLDeleteQuery DeleteQuery
MySQLDeleteQuery represents a MySQL DELETE query.
func (MySQLDeleteQuery) CrossJoin ¶
func (q MySQLDeleteQuery) CrossJoin(table Table) MySQLDeleteQuery
CrossJoin cross joins a new Table to the MySQLDeleteQuery.
func (MySQLDeleteQuery) CustomJoin ¶
func (q MySQLDeleteQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) MySQLDeleteQuery
CustomJoin joins a new Table to the MySQLDeleteQuery with a custom join operator.
func (MySQLDeleteQuery) From ¶
func (q MySQLDeleteQuery) From(table Table) MySQLDeleteQuery
From sets the UsingTable of the MySQLDeleteQuery.
func (MySQLDeleteQuery) FullJoin ¶
func (q MySQLDeleteQuery) FullJoin(table Table, predicates ...Predicate) MySQLDeleteQuery
FullJoin full joins a new Table to the MySQLDeleteQuery.
func (MySQLDeleteQuery) GetDialect ¶
func (q MySQLDeleteQuery) GetDialect() string
GetDialect implements the Query interface.
func (MySQLDeleteQuery) GetFetchableFields ¶
func (q MySQLDeleteQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (MySQLDeleteQuery) Join ¶
func (q MySQLDeleteQuery) Join(table Table, predicates ...Predicate) MySQLDeleteQuery
Join joins a new Table to the MySQLDeleteQuery.
func (MySQLDeleteQuery) JoinUsing ¶
func (q MySQLDeleteQuery) JoinUsing(table Table, fields ...Field) MySQLDeleteQuery
JoinUsing joins a new Table to the MySQLDeleteQuery with the USING operator.
func (MySQLDeleteQuery) LeftJoin ¶
func (q MySQLDeleteQuery) LeftJoin(table Table, predicates ...Predicate) MySQLDeleteQuery
LeftJoin left joins a new Table to the MySQLDeleteQuery.
func (MySQLDeleteQuery) Limit ¶
func (q MySQLDeleteQuery) Limit(limit any) MySQLDeleteQuery
Limit sets the LimitRows field of the MySQLDeleteQuery.
func (MySQLDeleteQuery) OrderBy ¶
func (q MySQLDeleteQuery) OrderBy(fields ...Field) MySQLDeleteQuery
OrderBy sets the OrderByFields field of the MySQLDeleteQuery.
func (MySQLDeleteQuery) Returning ¶ added in v0.2.9
func (q MySQLDeleteQuery) Returning(fields ...Field) MySQLDeleteQuery
Returning appends fields to the RETURNING clause of the MySQLDeleteQuery.
func (MySQLDeleteQuery) SetDialect ¶
func (q MySQLDeleteQuery) SetDialect(dialect string) MySQLDeleteQuery
SetDialect sets the dialect of the query.
func (MySQLDeleteQuery) SetFetchableFields ¶
func (q MySQLDeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (MySQLDeleteQuery) Where ¶
func (q MySQLDeleteQuery) Where(predicates ...Predicate) MySQLDeleteQuery
Where appends to the WherePredicate field of the MySQLDeleteQuery.
type MySQLInsertQuery ¶
type MySQLInsertQuery InsertQuery
MySQLInsertQuery represents a MySQL INSERT query.
func (MySQLInsertQuery) As ¶
func (q MySQLInsertQuery) As(rowAlias string) MySQLInsertQuery
As sets the RowAlias field of the MySQLInsertQuery.
func (MySQLInsertQuery) ColumnValues ¶
func (q MySQLInsertQuery) ColumnValues(colmapper func(*Column)) MySQLInsertQuery
ColumnValues sets the ColumnMapper field of the MySQLInsertQuery.
func (MySQLInsertQuery) Columns ¶
func (q MySQLInsertQuery) Columns(fields ...Field) MySQLInsertQuery
Columns sets the InsertColumns field of the MySQLInsertQuery.
func (MySQLInsertQuery) GetDialect ¶
func (q MySQLInsertQuery) GetDialect() string
GetDialect implements the Query interface.
func (MySQLInsertQuery) GetFetchableFields ¶
func (q MySQLInsertQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (MySQLInsertQuery) OnDuplicateKeyUpdate ¶
func (q MySQLInsertQuery) OnDuplicateKeyUpdate(assignments ...Assignment) MySQLInsertQuery
OnDuplicateKeyUpdate sets the ON DUPLICATE KEY UPDATE clause of the MySQLInsertQuery.
func (MySQLInsertQuery) Returning ¶ added in v0.2.9
func (q MySQLInsertQuery) Returning(fields ...Field) MySQLInsertQuery
Returning adds fields to the RETURNING clause of the MySQLInsertQuery.
func (MySQLInsertQuery) Select ¶
func (q MySQLInsertQuery) Select(query Query) MySQLInsertQuery
Select sets the SelectQuery field of the MySQLInsertQuery.
func (MySQLInsertQuery) SetDialect ¶
func (q MySQLInsertQuery) SetDialect(dialect string) MySQLInsertQuery
SetDialect returns the dialect of the query.
func (MySQLInsertQuery) SetFetchableFields ¶
func (q MySQLInsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (MySQLInsertQuery) Values ¶
func (q MySQLInsertQuery) Values(values ...any) MySQLInsertQuery
Values sets the RowValues field of the MySQLInsertQuery.
type MySQLSelectQuery ¶
type MySQLSelectQuery SelectQuery
MySQLSelectQuery represents a MySQL SELECT query.
func (MySQLSelectQuery) As ¶
func (q MySQLSelectQuery) As(alias string, columns ...string) MySQLSelectQuery
As returns a new MySQLSelectQuery with the table alias (and optionally column aliases).
func (MySQLSelectQuery) CrossJoin ¶
func (q MySQLSelectQuery) CrossJoin(table Table) MySQLSelectQuery
CrossJoin cross joins a new Table to the MySQLSelectQuery.
func (MySQLSelectQuery) CustomJoin ¶
func (q MySQLSelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) MySQLSelectQuery
CustomJoin joins a new Table to the MySQLSelectQuery with a custom join operator.
func (MySQLSelectQuery) Field ¶
func (q MySQLSelectQuery) Field(name string) AnyField
Field returns a new field qualified by the MySQLSelectQuery's alias.
func (MySQLSelectQuery) From ¶
func (q MySQLSelectQuery) From(table Table) MySQLSelectQuery
From sets the FromTable field in the MySQLSelectQuery.
func (MySQLSelectQuery) FullJoin ¶
func (q MySQLSelectQuery) FullJoin(table Table, predicates ...Predicate) MySQLSelectQuery
FullJoin full joins a new Table to the MySQLSelectQuery.
func (MySQLSelectQuery) GetAlias ¶
func (q MySQLSelectQuery) GetAlias() string
GetAlias returns the alias of the MySQLSelectQuery.
func (MySQLSelectQuery) GetDialect ¶
func (q MySQLSelectQuery) GetDialect() string
GetDialect implements the Query interface.
func (MySQLSelectQuery) GetFetchableFields ¶
func (q MySQLSelectQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (MySQLSelectQuery) GroupBy ¶
func (q MySQLSelectQuery) GroupBy(fields ...Field) MySQLSelectQuery
GroupBy appends to the GroupByFields field in the MySQLSelectQuery.
func (MySQLSelectQuery) Having ¶
func (q MySQLSelectQuery) Having(predicates ...Predicate) MySQLSelectQuery
Having appends to the HavingPredicate field in the MySQLSelectQuery.
func (MySQLSelectQuery) IsArray ¶
func (q MySQLSelectQuery) IsArray()
IsArray implements the Array interface.
func (MySQLSelectQuery) IsBinary ¶
func (q MySQLSelectQuery) IsBinary()
IsBinary implements the Binary interface.
func (MySQLSelectQuery) IsBoolean ¶
func (q MySQLSelectQuery) IsBoolean()
IsBoolean implements the Boolean interface.
func (MySQLSelectQuery) IsEnum ¶
func (q MySQLSelectQuery) IsEnum()
IsEnum implements the Enum interface.
func (MySQLSelectQuery) IsField ¶
func (q MySQLSelectQuery) IsField()
IsField implements the Field interface.
func (MySQLSelectQuery) IsJSON ¶
func (q MySQLSelectQuery) IsJSON()
IsJSON implements the JSON interface.
func (MySQLSelectQuery) IsNumber ¶
func (q MySQLSelectQuery) IsNumber()
IsNumber implements the Number interface.
func (MySQLSelectQuery) IsString ¶
func (q MySQLSelectQuery) IsString()
IsString implements the String interface.
func (MySQLSelectQuery) IsTable ¶
func (q MySQLSelectQuery) IsTable()
IsTable implements the Table interface.
func (MySQLSelectQuery) IsTime ¶
func (q MySQLSelectQuery) IsTime()
IsTime implements the Time interface.
func (MySQLSelectQuery) IsUUID ¶
func (q MySQLSelectQuery) IsUUID()
IsUUID implements the UUID interface.
func (MySQLSelectQuery) Join ¶
func (q MySQLSelectQuery) Join(table Table, predicates ...Predicate) MySQLSelectQuery
Join joins a new Table to the MySQLSelectQuery.
func (MySQLSelectQuery) JoinUsing ¶
func (q MySQLSelectQuery) JoinUsing(table Table, fields ...Field) MySQLSelectQuery
JoinUsing joins a new Table to the MySQLSelectQuery with the USING operator.
func (MySQLSelectQuery) LeftJoin ¶
func (q MySQLSelectQuery) LeftJoin(table Table, predicates ...Predicate) MySQLSelectQuery
LeftJoin left joins a new Table to the MySQLSelectQuery.
func (MySQLSelectQuery) Limit ¶
func (q MySQLSelectQuery) Limit(limit any) MySQLSelectQuery
Limit sets the LimitRows field in the MySQLSelectQuery.
func (MySQLSelectQuery) LockRows ¶
func (q MySQLSelectQuery) LockRows(lockClause string, lockValues ...any) MySQLSelectQuery
LockRows sets the lock clause of the MySQLSelectQuery.
func (MySQLSelectQuery) Offset ¶
func (q MySQLSelectQuery) Offset(offset any) MySQLSelectQuery
Offset sets the OffsetRows field in the MySQLSelectQuery.
func (MySQLSelectQuery) OrderBy ¶
func (q MySQLSelectQuery) OrderBy(fields ...Field) MySQLSelectQuery
OrderBy appends to the OrderByFields field in the MySQLSelectQuery.
func (MySQLSelectQuery) Select ¶
func (q MySQLSelectQuery) Select(fields ...Field) MySQLSelectQuery
Select appends to the SelectFields in the MySQLSelectQuery.
func (MySQLSelectQuery) SelectDistinct ¶
func (q MySQLSelectQuery) SelectDistinct(fields ...Field) MySQLSelectQuery
SelectDistinct sets the SelectFields in the MySQLSelectQuery.
func (MySQLSelectQuery) SelectOne ¶
func (q MySQLSelectQuery) SelectOne(fields ...Field) MySQLSelectQuery
SelectOne sets the MySQLSelectQuery to SELECT 1.
func (MySQLSelectQuery) SetDialect ¶
func (q MySQLSelectQuery) SetDialect(dialect string) MySQLSelectQuery
SetDialect sets the dialect of the query.
func (MySQLSelectQuery) SetFetchableFields ¶
func (q MySQLSelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (MySQLSelectQuery) Where ¶
func (q MySQLSelectQuery) Where(predicates ...Predicate) MySQLSelectQuery
Where appends to the WherePredicate field in the MySQLSelectQuery.
type MySQLUpdateQuery ¶
type MySQLUpdateQuery UpdateQuery
MySQLUpdateQuery represents a MySQL UPDATE query.
func (MySQLUpdateQuery) CrossJoin ¶
func (q MySQLUpdateQuery) CrossJoin(table Table) MySQLUpdateQuery
CrossJoin cross joins a new Table to the MySQLUpdateQuery.
func (MySQLUpdateQuery) CustomJoin ¶
func (q MySQLUpdateQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) MySQLUpdateQuery
CustomJoin joins a new Table to the MySQLUpdateQuery with a custom join operator.
func (MySQLUpdateQuery) FullJoin ¶
func (q MySQLUpdateQuery) FullJoin(table Table, predicates ...Predicate) MySQLUpdateQuery
FullJoin full joins a new Table to the MySQLUpdateQuery.
func (MySQLUpdateQuery) GetDialect ¶
func (q MySQLUpdateQuery) GetDialect() string
GetDialect implements the Query interface.
func (MySQLUpdateQuery) GetFetchableFields ¶
func (q MySQLUpdateQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the MySQLUpdateQuery.
func (MySQLUpdateQuery) Join ¶
func (q MySQLUpdateQuery) Join(table Table, predicates ...Predicate) MySQLUpdateQuery
Join joins a new Table to the MySQLUpdateQuery.
func (MySQLUpdateQuery) JoinUsing ¶
func (q MySQLUpdateQuery) JoinUsing(table Table, fields ...Field) MySQLUpdateQuery
JoinUsing joins a new Table to the MySQLUpdateQuery with the USING operator.
func (MySQLUpdateQuery) LeftJoin ¶
func (q MySQLUpdateQuery) LeftJoin(table Table, predicates ...Predicate) MySQLUpdateQuery
LeftJoin left joins a new Table to the MySQLUpdateQuery.
func (MySQLUpdateQuery) Limit ¶
func (q MySQLUpdateQuery) Limit(limit any) MySQLUpdateQuery
Limit sets the LimitRows field of the MySQLUpdateQuery.
func (MySQLUpdateQuery) OrderBy ¶
func (q MySQLUpdateQuery) OrderBy(fields ...Field) MySQLUpdateQuery
OrderBy sets the OrderByFields of the MySQLUpdateQuery.
func (MySQLUpdateQuery) Set ¶
func (q MySQLUpdateQuery) Set(assignments ...Assignment) MySQLUpdateQuery
Set sets the Assignments field of the MySQLUpdateQuery.
func (MySQLUpdateQuery) SetDialect ¶
func (q MySQLUpdateQuery) SetDialect(dialect string) MySQLUpdateQuery
SetDialect sets the dialect of the MySQLUpdateQuery.
func (MySQLUpdateQuery) SetFetchableFields ¶
func (q MySQLUpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (MySQLUpdateQuery) SetFunc ¶
func (q MySQLUpdateQuery) SetFunc(colmapper func(*Column)) MySQLUpdateQuery
SetFunc sets the ColumnMapper of the MySQLUpdateQuery.
func (MySQLUpdateQuery) Where ¶
func (q MySQLUpdateQuery) Where(predicates ...Predicate) MySQLUpdateQuery
Where appends to the WherePredicate field of the MySQLUpdateQuery.
type NamedWindow ¶
NamedWindow represents an SQL named window.
func (NamedWindow) IsWindow ¶
func (w NamedWindow) IsWindow()
IsWindow implements the Window interface.
type NamedWindows ¶
type NamedWindows []NamedWindow
NamedWindows represents a slice of NamedWindows.
type NumberField ¶
type NumberField struct {
// contains filtered or unexported fields
}
NumberField represents an SQL number field.
func NewNumberField ¶
func NewNumberField(name string, tbl TableStruct) NumberField
NewNumberField returns a new NumberField.
func (NumberField) As ¶
func (field NumberField) As(alias string) NumberField
As returns a new NumberField with the given alias.
func (NumberField) Asc ¶
func (field NumberField) Asc() NumberField
Asc returns a new NumberField indicating that it should be ordered in ascending order i.e. 'ORDER BY field ASC'.
func (NumberField) Desc ¶
func (field NumberField) Desc() NumberField
Desc returns a new NumberField indicating that it should be ordered in ascending order i.e. 'ORDER BY field DESC'.
func (NumberField) Eq ¶
func (field NumberField) Eq(value Number) Predicate
Eq returns a 'field = value' Predicate.
func (NumberField) EqFloat64 ¶
func (field NumberField) EqFloat64(num float64) Predicate
EqFloat64 returns a 'field = num' Predicate.
func (NumberField) EqInt ¶
func (field NumberField) EqInt(num int) Predicate
EqInt returns a 'field = num' Predicate.
func (NumberField) EqInt64 ¶
func (field NumberField) EqInt64(num int64) Predicate
EqInt64 returns a 'field = num' Predicate.
func (NumberField) Ge ¶
func (field NumberField) Ge(value Number) Predicate
Ge returns a 'field >= value' Predicate.
func (NumberField) GeFloat64 ¶
func (field NumberField) GeFloat64(num float64) Predicate
GeFloat64 returns a 'field >= num' Predicate.
func (NumberField) GeInt ¶
func (field NumberField) GeInt(num int) Predicate
GeInt returns a 'field >= num' Predicate.
func (NumberField) GeInt64 ¶
func (field NumberField) GeInt64(num int64) Predicate
GeInt64 returns a 'field >= num' Predicate.
func (NumberField) GetAlias ¶
func (field NumberField) GetAlias() string
GetAlias returns the alias of the NumberField.
func (NumberField) Gt ¶
func (field NumberField) Gt(value Number) Predicate
Gt returns a 'field > value' Predicate.
func (NumberField) GtFloat64 ¶
func (field NumberField) GtFloat64(num float64) Predicate
GtFloat64 returns a 'field > num' Predicate.
func (NumberField) GtInt ¶
func (field NumberField) GtInt(num int) Predicate
GtInt returns a 'field > num' Predicate.
func (NumberField) GtInt64 ¶
func (field NumberField) GtInt64(num int64) Predicate
GtInt64 returns a 'field > num' Predicate.
func (NumberField) In ¶
func (field NumberField) In(value any) Predicate
In returns a 'field IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field IN (x, y, z)'.
func (NumberField) IsField ¶
func (field NumberField) IsField()
IsField implements the Field interface.
func (NumberField) IsNotNull ¶
func (field NumberField) IsNotNull() Predicate
IsNotNull returns a 'field IS NOT NULL' Predicate.
func (NumberField) IsNull ¶
func (field NumberField) IsNull() Predicate
IsNull returns a 'field IS NULL' Predicate.
func (NumberField) IsNumber ¶
func (field NumberField) IsNumber()
IsNumber implements the Number interface.
func (NumberField) Le ¶
func (field NumberField) Le(value Number) Predicate
Le returns a 'field <= value' Predicate.
func (NumberField) LeFloat64 ¶
func (field NumberField) LeFloat64(num float64) Predicate
LeFloat64 returns a 'field <= num' Predicate.
func (NumberField) LeInt ¶
func (field NumberField) LeInt(num int) Predicate
LeInt returns a 'field <= num' Predicate.
func (NumberField) LeInt64 ¶
func (field NumberField) LeInt64(num int64) Predicate
LeInt64 returns a 'field <= num' Predicate.
func (NumberField) Lt ¶
func (field NumberField) Lt(value Number) Predicate
Lt returns a 'field < value' Predicate.
func (NumberField) LtFloat64 ¶
func (field NumberField) LtFloat64(num float64) Predicate
LtFloat64 returns a 'field < num' Predicate.
func (NumberField) LtInt ¶
func (field NumberField) LtInt(num int) Predicate
LtInt returns a 'field < num' Predicate.
func (NumberField) LtInt64 ¶
func (field NumberField) LtInt64(num int64) Predicate
LtInt64 returns a 'field < num' Predicate.
func (NumberField) Ne ¶
func (field NumberField) Ne(value Number) Predicate
Ne returns a 'field <> value' Predicate.
func (NumberField) NeFloat64 ¶
func (field NumberField) NeFloat64(num float64) Predicate
NeFloat64 returns a 'field <> num' Predicate.
func (NumberField) NeInt ¶
func (field NumberField) NeInt(num int) Predicate
NeInt returns a 'field <> num' Predicate.
func (NumberField) NeInt64 ¶
func (field NumberField) NeInt64(num int64) Predicate
NeInt64 returns a 'field <> num' Predicate.
func (NumberField) NotIn ¶ added in v0.3.0
func (field NumberField) NotIn(value any) Predicate
NotIn returns a 'field NOT IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field IN (x, y, z)'.
func (NumberField) NullsFirst ¶
func (field NumberField) NullsFirst() NumberField
NullsFirst returns a new NumberField indicating that it should be ordered with nulls first i.e. 'ORDER BY field NULLS FIRST'.
func (NumberField) NullsLast ¶
func (field NumberField) NullsLast() NumberField
NullsLast returns a new NumberField indicating that it should be ordered with nulls last i.e. 'ORDER BY field NULLS LAST'.
func (NumberField) Set ¶
func (field NumberField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (NumberField) SetFloat64 ¶
func (field NumberField) SetFloat64(num float64) Assignment
SetBytes returns an Assignment assigning an float64 to the field.
func (NumberField) SetInt ¶
func (field NumberField) SetInt(num int) Assignment
SetBytes returns an Assignment assigning an int to the field.
func (NumberField) SetInt64 ¶
func (field NumberField) SetInt64(num int64) Assignment
SetBytes returns an Assignment assigning an int64 to the field.
func (NumberField) Setf ¶
func (field NumberField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (NumberField) WithPrefix ¶
func (field NumberField) WithPrefix(prefix string) Field
WithPrefix returns a new Field that with the given prefix.
type NumberParameter ¶
NumberParameter is identical to sql.NamedArg, but implements the Number interface.
func Float64Param ¶
func Float64Param(name string, num float64) NumberParameter
Float64Param creates a new NumberParameter from an float64 value.
func Int64Param ¶
func Int64Param(name string, num int64) NumberParameter
Int64Param creates a new NumberParameter from an int64 value.
func IntParam ¶
func IntParam(name string, num int) NumberParameter
IntParam creates a new NumberParameter from an int value.
func (NumberParameter) IsField ¶
func (p NumberParameter) IsField()
IsField implements the Field interface.
func (NumberParameter) IsNumber ¶
func (p NumberParameter) IsNumber()
IsNumber implements the Number interface.
type PolicyTable ¶
PolicyTable is a table that produces a policy (i.e. a predicate) to be enforced whenever it is invoked in a query. This is equivalent to Postgres' Row Level Security (RLS) feature but works application-side. Only SELECT, UPDATE and DELETE queries are affected.
type PostgresDeleteQuery ¶
type PostgresDeleteQuery DeleteQuery
PostgresDeleteQuery represents a Postgres DELETE query.
func (PostgresDeleteQuery) CrossJoin ¶
func (q PostgresDeleteQuery) CrossJoin(table Table) PostgresDeleteQuery
CrossJoin cross joins a new Table to the PostgresDeleteQuery.
func (PostgresDeleteQuery) CustomJoin ¶
func (q PostgresDeleteQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) PostgresDeleteQuery
CustomJoin joins a new Table to the PostgresDeleteQuery with a custom join operator.
func (PostgresDeleteQuery) FullJoin ¶
func (q PostgresDeleteQuery) FullJoin(table Table, predicates ...Predicate) PostgresDeleteQuery
FullJoin full joins a new Table to the PostgresDeleteQuery.
func (PostgresDeleteQuery) GetDialect ¶
func (q PostgresDeleteQuery) GetDialect() string
GetDialect implements the Query interface.
func (PostgresDeleteQuery) GetFetchableFields ¶
func (q PostgresDeleteQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (PostgresDeleteQuery) Join ¶
func (q PostgresDeleteQuery) Join(table Table, predicates ...Predicate) PostgresDeleteQuery
Join joins a new Table to the PostgresDeleteQuery.
func (PostgresDeleteQuery) JoinUsing ¶
func (q PostgresDeleteQuery) JoinUsing(table Table, fields ...Field) PostgresDeleteQuery
JoinUsing joins a new Table to the PostgresDeleteQuery with the USING operator.
func (PostgresDeleteQuery) LeftJoin ¶
func (q PostgresDeleteQuery) LeftJoin(table Table, predicates ...Predicate) PostgresDeleteQuery
LeftJoin left joins a new Table to the PostgresDeleteQuery.
func (PostgresDeleteQuery) Returning ¶
func (q PostgresDeleteQuery) Returning(fields ...Field) PostgresDeleteQuery
Returning appends fields to the RETURNING clause of the PostgresDeleteQuery.
func (PostgresDeleteQuery) SetDialect ¶
func (q PostgresDeleteQuery) SetDialect(dialect string) PostgresDeleteQuery
SetDialect sets the dialect of the query.
func (PostgresDeleteQuery) SetFetchableFields ¶
func (q PostgresDeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (PostgresDeleteQuery) Using ¶
func (q PostgresDeleteQuery) Using(table Table) PostgresDeleteQuery
Using sets the UsingTable field of the PostgresDeleteQuery.
func (PostgresDeleteQuery) Where ¶
func (q PostgresDeleteQuery) Where(predicates ...Predicate) PostgresDeleteQuery
Where appends to the WherePredicate field of the PostgresDeleteQuery.
type PostgresInsertQuery ¶
type PostgresInsertQuery InsertQuery
PostgresInsertQuery represents a Postgres INSERT query.
func (PostgresInsertQuery) ColumnValues ¶
func (q PostgresInsertQuery) ColumnValues(colmapper func(*Column)) PostgresInsertQuery
ColumnValues sets the ColumnMapper field of the PostgresInsertQuery.
func (PostgresInsertQuery) Columns ¶
func (q PostgresInsertQuery) Columns(fields ...Field) PostgresInsertQuery
Columns sets the InsertColumns field of the PostgresInsertQuery.
func (PostgresInsertQuery) GetDialect ¶
func (q PostgresInsertQuery) GetDialect() string
GetDialect implements the Query interface.
func (PostgresInsertQuery) GetFetchableFields ¶
func (q PostgresInsertQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (PostgresInsertQuery) OnConflict ¶
func (q PostgresInsertQuery) OnConflict(fields ...Field) postgresInsertConflict
OnConflict starts the ON CONFLICT clause of the PostgresInsertQuery.
func (PostgresInsertQuery) OnConflictOnConstraint ¶
func (q PostgresInsertQuery) OnConflictOnConstraint(constraintName string) postgresInsertConflict
OnConflict starts the ON CONFLICT clause of the PostgresInsertQuery.
func (PostgresInsertQuery) Returning ¶
func (q PostgresInsertQuery) Returning(fields ...Field) PostgresInsertQuery
Returning adds fields to the RETURNING clause of the PostgresInsertQuery.
func (PostgresInsertQuery) Select ¶
func (q PostgresInsertQuery) Select(query Query) PostgresInsertQuery
Select sets the SelectQuery field of the PostgresInsertQuery.
func (PostgresInsertQuery) SetDialect ¶
func (q PostgresInsertQuery) SetDialect(dialect string) PostgresInsertQuery
SetDialect returns the dialect of the query.
func (PostgresInsertQuery) SetFetchableFields ¶
func (q PostgresInsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (PostgresInsertQuery) Values ¶
func (q PostgresInsertQuery) Values(values ...any) PostgresInsertQuery
Values sets the RowValues field of the PostgresInsertQuery.
func (PostgresInsertQuery) Where ¶
func (q PostgresInsertQuery) Where(predicates ...Predicate) PostgresInsertQuery
Where adds predicates to the DO UPDATE SET clause of the PostgresInsertQuery.
type PostgresSelectQuery ¶
type PostgresSelectQuery SelectQuery
PostgresSelectQuery represents a Postgres SELECT query.
func (PostgresSelectQuery) As ¶
func (q PostgresSelectQuery) As(alias string, columns ...string) PostgresSelectQuery
As returns a new PostgresSelectQuery with the table alias (and optionally column aliases).
func (PostgresSelectQuery) CrossJoin ¶
func (q PostgresSelectQuery) CrossJoin(table Table) PostgresSelectQuery
CrossJoin cross joins a new Table to the PostgresSelectQuery.
func (PostgresSelectQuery) CustomJoin ¶
func (q PostgresSelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) PostgresSelectQuery
CustomJoin joins a new Table to the PostgresSelectQuery with a custom join operator.
func (PostgresSelectQuery) DistinctOn ¶
func (q PostgresSelectQuery) DistinctOn(fields ...Field) PostgresSelectQuery
DistinctOn sets the DistinctOnFields in the PostgresSelectQuery.
func (PostgresSelectQuery) FetchNext ¶
func (q PostgresSelectQuery) FetchNext(n any) PostgresSelectQuery
FetchNext sets the FetchNextRows field in the PostgresSelectQuery.
func (PostgresSelectQuery) Field ¶
func (q PostgresSelectQuery) Field(name string) AnyField
Field returns a new field qualified by the PostgresSelectQuery's alias.
func (PostgresSelectQuery) From ¶
func (q PostgresSelectQuery) From(table Table) PostgresSelectQuery
From sets the FromTable field in the PostgresSelectQuery.
func (PostgresSelectQuery) FullJoin ¶
func (q PostgresSelectQuery) FullJoin(table Table, predicates ...Predicate) PostgresSelectQuery
FullJoin full joins a new Table to the PostgresSelectQuery.
func (PostgresSelectQuery) GetAlias ¶
func (q PostgresSelectQuery) GetAlias() string
GetAlias returns the alias of the PostgresSelectQuery.
func (PostgresSelectQuery) GetDialect ¶
func (q PostgresSelectQuery) GetDialect() string
GetDialect implements the Query interface.
func (PostgresSelectQuery) GetFetchableFields ¶
func (q PostgresSelectQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (PostgresSelectQuery) GroupBy ¶
func (q PostgresSelectQuery) GroupBy(fields ...Field) PostgresSelectQuery
GroupBy appends to the GroupByFields field in the PostgresSelectQuery.
func (PostgresSelectQuery) Having ¶
func (q PostgresSelectQuery) Having(predicates ...Predicate) PostgresSelectQuery
Having appends to the HavingPredicate field in the PostgresSelectQuery.
func (PostgresSelectQuery) IsArray ¶
func (q PostgresSelectQuery) IsArray()
IsArray implements the Array interface.
func (PostgresSelectQuery) IsBinary ¶
func (q PostgresSelectQuery) IsBinary()
IsBinary implements the Binary interface.
func (PostgresSelectQuery) IsBoolean ¶
func (q PostgresSelectQuery) IsBoolean()
IsBoolean implements the Boolean interface.
func (PostgresSelectQuery) IsEnum ¶
func (q PostgresSelectQuery) IsEnum()
IsEnum implements the Enum interface.
func (PostgresSelectQuery) IsField ¶
func (q PostgresSelectQuery) IsField()
IsField implements the Field interface.
func (PostgresSelectQuery) IsJSON ¶
func (q PostgresSelectQuery) IsJSON()
IsJSON implements the JSON interface.
func (PostgresSelectQuery) IsNumber ¶
func (q PostgresSelectQuery) IsNumber()
IsNumber implements the Number interface.
func (PostgresSelectQuery) IsString ¶
func (q PostgresSelectQuery) IsString()
IsString implements the String interface.
func (PostgresSelectQuery) IsTable ¶
func (q PostgresSelectQuery) IsTable()
IsTable implements the Table interface.
func (PostgresSelectQuery) IsTime ¶
func (q PostgresSelectQuery) IsTime()
IsTime implements the Time interface.
func (PostgresSelectQuery) IsUUID ¶
func (q PostgresSelectQuery) IsUUID()
IsUUID implements the UUID interface.
func (PostgresSelectQuery) Join ¶
func (q PostgresSelectQuery) Join(table Table, predicates ...Predicate) PostgresSelectQuery
Join joins a new Table to the PostgresSelectQuery.
func (PostgresSelectQuery) JoinUsing ¶
func (q PostgresSelectQuery) JoinUsing(table Table, fields ...Field) PostgresSelectQuery
JoinUsing joins a new Table to the PostgresSelectQuery with the USING operator.
func (PostgresSelectQuery) LeftJoin ¶
func (q PostgresSelectQuery) LeftJoin(table Table, predicates ...Predicate) PostgresSelectQuery
LeftJoin left joins a new Table to the PostgresSelectQuery.
func (PostgresSelectQuery) Limit ¶
func (q PostgresSelectQuery) Limit(limit any) PostgresSelectQuery
Limit sets the LimitRows field in the PostgresSelectQuery.
func (PostgresSelectQuery) LockRows ¶
func (q PostgresSelectQuery) LockRows(lockClause string, lockValues ...any) PostgresSelectQuery
LockRows sets the lock clause of the PostgresSelectQuery.
func (PostgresSelectQuery) Offset ¶
func (q PostgresSelectQuery) Offset(offset any) PostgresSelectQuery
Offset sets the OffsetRows field in the PostgresSelectQuery.
func (PostgresSelectQuery) OrderBy ¶
func (q PostgresSelectQuery) OrderBy(fields ...Field) PostgresSelectQuery
OrderBy appends to the OrderByFields field in the PostgresSelectQuery.
func (PostgresSelectQuery) Select ¶
func (q PostgresSelectQuery) Select(fields ...Field) PostgresSelectQuery
Select appends to the SelectFields in the PostgresSelectQuery.
func (PostgresSelectQuery) SelectDistinct ¶
func (q PostgresSelectQuery) SelectDistinct(fields ...Field) PostgresSelectQuery
SelectDistinct sets the SelectFields in the PostgresSelectQuery.
func (PostgresSelectQuery) SelectOne ¶
func (q PostgresSelectQuery) SelectOne(fields ...Field) PostgresSelectQuery
SelectOne sets the PostgresSelectQuery to SELECT 1.
func (PostgresSelectQuery) SetDialect ¶
func (q PostgresSelectQuery) SetDialect(dialect string) PostgresSelectQuery
SetDialect sets the dialect of the query.
func (PostgresSelectQuery) SetFetchableFields ¶
func (q PostgresSelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (PostgresSelectQuery) Where ¶
func (q PostgresSelectQuery) Where(predicates ...Predicate) PostgresSelectQuery
Where appends to the WherePredicate field in the PostgresSelectQuery.
func (PostgresSelectQuery) WithTies ¶
func (q PostgresSelectQuery) WithTies() PostgresSelectQuery
WithTies enables the FetchWithTies field in the PostgresSelectQuery.
type PostgresUpdateQuery ¶
type PostgresUpdateQuery UpdateQuery
PostgresUpdateQuery represents a Postgres UPDATE query.
func (PostgresUpdateQuery) CrossJoin ¶
func (q PostgresUpdateQuery) CrossJoin(table Table) PostgresUpdateQuery
CrossJoin cross joins a new Table to the PostgresUpdateQuery.
func (PostgresUpdateQuery) CustomJoin ¶
func (q PostgresUpdateQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) PostgresUpdateQuery
CustomJoin joins a new Table to the PostgresUpdateQuery with a custom join operator.
func (PostgresUpdateQuery) From ¶
func (q PostgresUpdateQuery) From(table Table) PostgresUpdateQuery
From sets the FromTable field of the PostgresUpdateQuery.
func (PostgresUpdateQuery) FullJoin ¶
func (q PostgresUpdateQuery) FullJoin(table Table, predicates ...Predicate) PostgresUpdateQuery
FullJoin full joins a new Table to the PostgresUpdateQuery.
func (PostgresUpdateQuery) GetDialect ¶
func (q PostgresUpdateQuery) GetDialect() string
GetDialect implements the Query interface.
func (PostgresUpdateQuery) GetFetchableFields ¶
func (q PostgresUpdateQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the PostgresUpdateQuery.
func (PostgresUpdateQuery) Join ¶
func (q PostgresUpdateQuery) Join(table Table, predicates ...Predicate) PostgresUpdateQuery
Join joins a new Table to the PostgresUpdateQuery.
func (PostgresUpdateQuery) JoinUsing ¶
func (q PostgresUpdateQuery) JoinUsing(table Table, fields ...Field) PostgresUpdateQuery
JoinUsing joins a new Table to the PostgresUpdateQuery with the USING operator.
func (PostgresUpdateQuery) LeftJoin ¶
func (q PostgresUpdateQuery) LeftJoin(table Table, predicates ...Predicate) PostgresUpdateQuery
LeftJoin left joins a new Table to the PostgresUpdateQuery.
func (PostgresUpdateQuery) Returning ¶
func (q PostgresUpdateQuery) Returning(fields ...Field) PostgresUpdateQuery
Returning sets the ReturningFields field of the PostgresUpdateQuery.
func (PostgresUpdateQuery) Set ¶
func (q PostgresUpdateQuery) Set(assignments ...Assignment) PostgresUpdateQuery
Set sets the Assignments field of the PostgresUpdateQuery.
func (PostgresUpdateQuery) SetDialect ¶
func (q PostgresUpdateQuery) SetDialect(dialect string) PostgresUpdateQuery
SetDialect sets the dialect of the PostgresUpdateQuery.
func (PostgresUpdateQuery) SetFetchableFields ¶
func (q PostgresUpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (PostgresUpdateQuery) SetFunc ¶
func (q PostgresUpdateQuery) SetFunc(colmapper func(*Column)) PostgresUpdateQuery
SetFunc sets the ColumnMapper of the PostgresUpdateQuery.
func (PostgresUpdateQuery) Where ¶
func (q PostgresUpdateQuery) Where(predicates ...Predicate) PostgresUpdateQuery
Where appends to the WherePredicate field of the PostgresUpdateQuery.
type Predicate ¶
type Predicate interface { Boolean }
Predicate is an SQL expression that evaluates to true or false.
type PredicateCase ¶
PredicateCase holds the result to be used for a given predicate in a CaseExpression.
type PredicateCases ¶
type PredicateCases = []PredicateCase
PredicateCases is a slice of PredicateCases.
type PreparedExec ¶
type PreparedExec struct {
// contains filtered or unexported fields
}
PrepareExec is the result of preparing a CompiledExec on a DB.
func PrepareExec ¶
func PrepareExec(db DB, q Query) (*PreparedExec, error)
PrepareExec returns a new PreparedExec.
func PrepareExecContext ¶
PrepareExecContext is like PrepareExec but additionally requires a context.Context.
func (*PreparedExec) Close ¶
func (preparedExec *PreparedExec) Close() error
Close closes the PreparedExec.
func (*PreparedExec) Exec ¶
func (preparedExec *PreparedExec) Exec(params Params) (Result, error)
Exec executes the PreparedExec with the given params.
func (*PreparedExec) ExecContext ¶
ExecContext is like Exec but additionally requires a context.Context.
type PreparedFetch ¶
type PreparedFetch[T any] struct { // contains filtered or unexported fields }
PreparedFetch is the result of preparing a CompiledFetch on a DB.
func PrepareFetch ¶
PrepareFetch returns a new PreparedFetch.
func PrepareFetchContext ¶
func PrepareFetchContext[T any](ctx context.Context, db DB, q Query, rowmapper func(*Row) T) (*PreparedFetch[T], error)
PrepareFetchContext is like PrepareFetch but additionally requires a context.Context.
func (*PreparedFetch[T]) Close ¶
func (preparedFetch *PreparedFetch[T]) Close() error
Close closes the PreparedFetch.
func (*PreparedFetch[T]) FetchAll ¶
func (preparedFetch *PreparedFetch[T]) FetchAll(params Params) ([]T, error)
FetchAll returns all the results from running the PreparedFetch with the give params.
func (*PreparedFetch[T]) FetchAllContext ¶
func (preparedFetch *PreparedFetch[T]) FetchAllContext(ctx context.Context, params Params) ([]T, error)
FetchAllContext is like FetchAll but additionally requires a context.Context.
func (PreparedFetch[T]) FetchCursor ¶
func (preparedFetch PreparedFetch[T]) FetchCursor(params Params) (*Cursor[T], error)
FetchCursor returns a new cursor.
func (PreparedFetch[T]) FetchCursorContext ¶
func (preparedFetch PreparedFetch[T]) FetchCursorContext(ctx context.Context, params Params) (*Cursor[T], error)
FetchCursorContext is like FetchCursor but additionally requires a context.Context.
func (*PreparedFetch[T]) FetchOne ¶
func (preparedFetch *PreparedFetch[T]) FetchOne(params Params) (T, error)
FetchOne returns the first result from running the PreparedFetch with the give params.
func (*PreparedFetch[T]) FetchOneContext ¶
func (preparedFetch *PreparedFetch[T]) FetchOneContext(ctx context.Context, params Params) (T, error)
FetchOneContext is like FetchOne but additionally requires a context.Context.
func (*PreparedFetch[T]) GetCompiled ¶
func (preparedFetch *PreparedFetch[T]) GetCompiled() *CompiledFetch[T]
GetCompiled returns a copy of the underlying CompiledFetch.
type Query ¶
type Query interface { SQLWriter // SetFetchableFields should return a query with its fetchable fields set // to the given fields. If not applicable, it should return false as the // second return value. SetFetchableFields([]Field) (query Query, ok bool) GetDialect() string }
Query is either SELECT, INSERT, UPDATE or DELETE.
type QueryStats ¶
type QueryStats struct { // Dialect of the query. Dialect string // Query string. Query string // Args slice provided with the query string. Args []any // Params maps param names back to arguments in the args slice (by index). Params map[string][]int // Err is the error from running the query. Err error // RowCount from running the query. Not valid for Exec(). RowCount sql.NullInt64 // RowsAffected by running the query. Not valid for // FetchOne/FetchAll/FetchCursor. RowsAffected sql.NullInt64 // LastInsertId of the query. LastInsertId sql.NullInt64 // Exists is the result of FetchExists(). Exists sql.NullBool // When the query started at. StartedAt time.Time // Time taken by the query. TimeTaken time.Duration // The caller file where the query was invoked. CallerFile string // The line in the caller file that invoked the query. CallerLine int // The name of the function where the query was invoked. CallerFunction string // The results from running the query (if it was provided). Results string }
QueryStats represents the statistics from running a query.
type Result ¶
Result is the result of an Exec command.
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row represents the state of a row after a call to rows.Next().
func (*Row) Array ¶
Array scans the array expression into destPtr. The destPtr must be a pointer to a []string, []int, []int64, []int32, []float64, []float32 or []bool.
func (*Row) ArrayField ¶
ArrayField scans the array field into destPtr. The destPtr must be a pointer to a []string, []int, []int64, []int32, []float64, []float32 or []bool.
func (*Row) BytesField ¶
BytesField returns the []byte value of the field.
func (*Row) ColumnTypes ¶ added in v0.3.0
func (row *Row) ColumnTypes() []*sql.ColumnType
ColumnTypes returns the column types returned by the query. This method can only be called in a rowmapper if it is paired with a raw SQL query e.g. Queryf("SELECT * FROM my_table"). Otherwise, an error will be returned.
func (*Row) Columns ¶ added in v0.3.0
Column returns the names of the columns returned by the query. This method can only be called in a rowmapper if it is paired with a raw SQL query e.g. Queryf("SELECT * FROM my_table"). Otherwise, an error will be returned.
func (*Row) Enum ¶
func (row *Row) Enum(destPtr Enumeration, format string, values ...any)
Enum scans the enum expression into destPtr.
func (*Row) EnumField ¶
func (row *Row) EnumField(destPtr Enumeration, field Enum)
EnumField scans the enum field into destPtr.
func (*Row) Float64Field ¶
Float64Field returns the float64 value of the field.
func (*Row) Int64Field ¶
Int64Field returns the int64 value of the field.
func (*Row) NullBoolField ¶
NullBoolField returns the sql.NullBool value of the field.
func (*Row) NullFloat64 ¶
func (row *Row) NullFloat64(format string, values ...any) sql.NullFloat64
NullFloat64 returns the sql.NullFloat64 valye of the expression.
func (*Row) NullFloat64Field ¶
func (row *Row) NullFloat64Field(field Number) sql.NullFloat64
NullFloat64Field returns the sql.NullFloat64 value of the field.
func (*Row) NullInt64Field ¶
NullInt64Field returns the sql.NullInt64 value of the field.
func (*Row) NullString ¶
func (row *Row) NullString(format string, values ...any) sql.NullString
NullString returns the sql.NullString value of the expression.
func (*Row) NullStringField ¶
func (row *Row) NullStringField(field String) sql.NullString
NullStringField returns the sql.NullString value of the field.
func (*Row) NullTimeField ¶
NullTimeField returns the sql.NullTime value of the field.
func (*Row) StringField ¶
String returns the string value of the field.
type RowValue ¶
type RowValue []any
RowValue represents an SQL row value expression e.g. (x, y, z).
type RowValues ¶
type RowValues []RowValue
RowValues represents a list of RowValues e.g. (x, y, z), (a, b, c).
type SQLServerDeleteQuery ¶
type SQLServerDeleteQuery DeleteQuery
SQLServerDeleteQuery represents an SQL Server DELETE query.
func (SQLServerDeleteQuery) CrossJoin ¶
func (q SQLServerDeleteQuery) CrossJoin(table Table) SQLServerDeleteQuery
CrossJoin cross joins a new Table to the SQLServerDeleteQuery.
func (SQLServerDeleteQuery) CustomJoin ¶
func (q SQLServerDeleteQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLServerDeleteQuery
CustomJoin joins a new Table to the SQLServerDeleteQuery with a custom join operator.
func (SQLServerDeleteQuery) From ¶
func (q SQLServerDeleteQuery) From(table Table) SQLServerDeleteQuery
From sets the UsingTable of the SQLServerDeleteQuery.
func (SQLServerDeleteQuery) FullJoin ¶
func (q SQLServerDeleteQuery) FullJoin(table Table, predicates ...Predicate) SQLServerDeleteQuery
FullJoin full joins a new Table to the SQLServerDeleteQuery.
func (SQLServerDeleteQuery) GetDialect ¶
func (q SQLServerDeleteQuery) GetDialect() string
GetDialect implements the Query interface.
func (SQLServerDeleteQuery) GetFetchableFields ¶
func (q SQLServerDeleteQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (SQLServerDeleteQuery) Join ¶
func (q SQLServerDeleteQuery) Join(table Table, predicates ...Predicate) SQLServerDeleteQuery
Join joins a new Table to the SQLServerDeleteQuery.
func (SQLServerDeleteQuery) LeftJoin ¶
func (q SQLServerDeleteQuery) LeftJoin(table Table, predicates ...Predicate) SQLServerDeleteQuery
LeftJoin left joins a new Table to the SQLServerDeleteQuery.
func (SQLServerDeleteQuery) SetDialect ¶
func (q SQLServerDeleteQuery) SetDialect(dialect string) SQLServerDeleteQuery
SetDialect sets the dialect of the query.
func (SQLServerDeleteQuery) SetFetchableFields ¶
func (q SQLServerDeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SQLServerDeleteQuery) Where ¶
func (q SQLServerDeleteQuery) Where(predicates ...Predicate) SQLServerDeleteQuery
Where appends to the WherePredicate field of the SQLServerDeleteQuery.
type SQLServerInsertQuery ¶
type SQLServerInsertQuery InsertQuery
SQLServerInsertQuery represents an SQL Server INSERT query.
func (SQLServerInsertQuery) ColumnValues ¶
func (q SQLServerInsertQuery) ColumnValues(colmapper func(*Column)) SQLServerInsertQuery
ColumnValues sets the ColumnMapper field of the SQLServerInsertQuery.
func (SQLServerInsertQuery) Columns ¶
func (q SQLServerInsertQuery) Columns(fields ...Field) SQLServerInsertQuery
Columns sets the InsertColumns field of the SQLServerInsertQuery.
func (SQLServerInsertQuery) GetDialect ¶
func (q SQLServerInsertQuery) GetDialect() string
GetDialect implements the Query interface.
func (SQLServerInsertQuery) GetFetchableFields ¶
func (q SQLServerInsertQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (SQLServerInsertQuery) Select ¶
func (q SQLServerInsertQuery) Select(query Query) SQLServerInsertQuery
Select sets the SelectQuery field of the SQLServerInsertQuery.
func (SQLServerInsertQuery) SetDialect ¶
func (q SQLServerInsertQuery) SetDialect(dialect string) SQLServerInsertQuery
SetDialect returns the dialect of the query.
func (SQLServerInsertQuery) SetFetchableFields ¶
func (q SQLServerInsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SQLServerInsertQuery) Values ¶
func (q SQLServerInsertQuery) Values(values ...any) SQLServerInsertQuery
Values sets the RowValues field of the SQLServerInsertQuery.
type SQLServerSelectQuery ¶
type SQLServerSelectQuery SelectQuery
SQLServerSelectQuery represents an SQL Server SELECT query.
func (SQLServerSelectQuery) As ¶
func (q SQLServerSelectQuery) As(alias string, columns ...string) SQLServerSelectQuery
As returns a new SQLServerSelectQuery with the table alias (and optionally column aliases).
func (SQLServerSelectQuery) CrossJoin ¶
func (q SQLServerSelectQuery) CrossJoin(table Table) SQLServerSelectQuery
CrossJoin cross joins a new Table to the SQLServerSelectQuery.
func (SQLServerSelectQuery) CustomJoin ¶
func (q SQLServerSelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLServerSelectQuery
CustomJoin joins a new Table to the SQLServerSelectQuery with a custom join operator.
func (SQLServerSelectQuery) FetchNext ¶
func (q SQLServerSelectQuery) FetchNext(n any) SQLServerSelectQuery
FetchNext sets the FetchNextRows field in the SQLServerSelectQuery.
func (SQLServerSelectQuery) Field ¶
func (q SQLServerSelectQuery) Field(name string) AnyField
Field returns a new field qualified by the SQLServerSelectQuery's alias.
func (SQLServerSelectQuery) From ¶
func (q SQLServerSelectQuery) From(table Table) SQLServerSelectQuery
From sets the FromTable field in the SQLServerSelectQuery.
func (SQLServerSelectQuery) FullJoin ¶
func (q SQLServerSelectQuery) FullJoin(table Table, predicates ...Predicate) SQLServerSelectQuery
FullJoin full joins a new Table to the SQLServerSelectQuery.
func (SQLServerSelectQuery) GetAlias ¶
func (q SQLServerSelectQuery) GetAlias() string
GetAlias returns the alias of the SQLServerSelectQuery.
func (SQLServerSelectQuery) GetDialect ¶
func (q SQLServerSelectQuery) GetDialect() string
GetDialect implements the Query interface.
func (SQLServerSelectQuery) GetFetchableFields ¶
func (q SQLServerSelectQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (SQLServerSelectQuery) GroupBy ¶
func (q SQLServerSelectQuery) GroupBy(fields ...Field) SQLServerSelectQuery
GroupBy appends to the GroupByFields field in the SQLServerSelectQuery.
func (SQLServerSelectQuery) Having ¶
func (q SQLServerSelectQuery) Having(predicates ...Predicate) SQLServerSelectQuery
Having appends to the HavingPredicate field in the SQLServerSelectQuery.
func (SQLServerSelectQuery) IsArray ¶
func (q SQLServerSelectQuery) IsArray()
IsArray implements the Array interface.
func (SQLServerSelectQuery) IsBinary ¶
func (q SQLServerSelectQuery) IsBinary()
IsBinary implements the Binary interface.
func (SQLServerSelectQuery) IsBoolean ¶
func (q SQLServerSelectQuery) IsBoolean()
IsBoolean implements the Boolean interface.
func (SQLServerSelectQuery) IsEnum ¶
func (q SQLServerSelectQuery) IsEnum()
IsEnum implements the Enum interface.
func (SQLServerSelectQuery) IsField ¶
func (q SQLServerSelectQuery) IsField()
IsField implements the Field interface.
func (SQLServerSelectQuery) IsJSON ¶
func (q SQLServerSelectQuery) IsJSON()
IsJSON implements the JSON interface.
func (SQLServerSelectQuery) IsNumber ¶
func (q SQLServerSelectQuery) IsNumber()
IsNumber implements the Number interface.
func (SQLServerSelectQuery) IsString ¶
func (q SQLServerSelectQuery) IsString()
IsString implements the String interface.
func (SQLServerSelectQuery) IsTable ¶
func (q SQLServerSelectQuery) IsTable()
IsTable implements the Table interface.
func (SQLServerSelectQuery) IsTime ¶
func (q SQLServerSelectQuery) IsTime()
IsTime implements the Time interface.
func (SQLServerSelectQuery) IsUUID ¶
func (q SQLServerSelectQuery) IsUUID()
IsUUID implements the UUID interface.
func (SQLServerSelectQuery) Join ¶
func (q SQLServerSelectQuery) Join(table Table, predicates ...Predicate) SQLServerSelectQuery
Join joins a new Table to the SQLServerSelectQuery.
func (SQLServerSelectQuery) LeftJoin ¶
func (q SQLServerSelectQuery) LeftJoin(table Table, predicates ...Predicate) SQLServerSelectQuery
LeftJoin left joins a new Table to the SQLServerSelectQuery.
func (SQLServerSelectQuery) Offset ¶
func (q SQLServerSelectQuery) Offset(offset any) SQLServerSelectQuery
Offset sets the OffsetRows field in the SQLServerSelectQuery.
func (SQLServerSelectQuery) OrderBy ¶
func (q SQLServerSelectQuery) OrderBy(fields ...Field) SQLServerSelectQuery
OrderBy appends to the OrderByFields field in the SQLServerSelectQuery.
func (SQLServerSelectQuery) Select ¶
func (q SQLServerSelectQuery) Select(fields ...Field) SQLServerSelectQuery
Select appends to the SelectFields in the SQLServerSelectQuery.
func (SQLServerSelectQuery) SelectDistinct ¶
func (q SQLServerSelectQuery) SelectDistinct(fields ...Field) SQLServerSelectQuery
SelectDistinct sets the SelectFields in the SQLServerSelectQuery.
func (SQLServerSelectQuery) SelectOne ¶
func (q SQLServerSelectQuery) SelectOne(fields ...Field) SQLServerSelectQuery
SelectOne sets the SQLServerSelectQuery to SELECT 1.
func (SQLServerSelectQuery) SetDialect ¶
func (q SQLServerSelectQuery) SetDialect(dialect string) SQLServerSelectQuery
SetDialect sets the dialect of the query.
func (SQLServerSelectQuery) SetFetchableFields ¶
func (q SQLServerSelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SQLServerSelectQuery) Top ¶
func (q SQLServerSelectQuery) Top(limit any) SQLServerSelectQuery
Top sets the LimitTop field of the SQLServerSelectQuery.
func (SQLServerSelectQuery) TopPercent ¶
func (q SQLServerSelectQuery) TopPercent(percentLimit any) SQLServerSelectQuery
Top sets the LimitTopPercent field of the SQLServerSelectQuery.
func (SQLServerSelectQuery) Where ¶
func (q SQLServerSelectQuery) Where(predicates ...Predicate) SQLServerSelectQuery
Where appends to the WherePredicate field in the SQLServerSelectQuery.
func (SQLServerSelectQuery) WithTies ¶
func (q SQLServerSelectQuery) WithTies() SQLServerSelectQuery
WithTies enables the FetchWithTies field in the SQLServerSelectQuery.
type SQLServerUpdateQuery ¶
type SQLServerUpdateQuery UpdateQuery
SQLServerUpdateQuery represents an SQL Server UPDATE query.
func (SQLServerUpdateQuery) CrossJoin ¶
func (q SQLServerUpdateQuery) CrossJoin(table Table) SQLServerUpdateQuery
CrossJoin cross joins a new Table to the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) CustomJoin ¶
func (q SQLServerUpdateQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLServerUpdateQuery
CustomJoin joins a new Table to the SQLServerUpdateQuery with a custom join operator.
func (SQLServerUpdateQuery) From ¶
func (q SQLServerUpdateQuery) From(table Table) SQLServerUpdateQuery
From sets the FromTable field of the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) FullJoin ¶
func (q SQLServerUpdateQuery) FullJoin(table Table, predicates ...Predicate) SQLServerUpdateQuery
FullJoin full joins a new Table to the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) GetDialect ¶
func (q SQLServerUpdateQuery) GetDialect() string
GetDialect implements the Query interface.
func (SQLServerUpdateQuery) GetFetchableFields ¶
func (q SQLServerUpdateQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) Join ¶
func (q SQLServerUpdateQuery) Join(table Table, predicates ...Predicate) SQLServerUpdateQuery
Join joins a new Table to the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) LeftJoin ¶
func (q SQLServerUpdateQuery) LeftJoin(table Table, predicates ...Predicate) SQLServerUpdateQuery
LeftJoin left joins a new Table to the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) Set ¶
func (q SQLServerUpdateQuery) Set(assignments ...Assignment) SQLServerUpdateQuery
Set sets the Assignments field of the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) SetDialect ¶
func (q SQLServerUpdateQuery) SetDialect(dialect string) SQLServerUpdateQuery
SetDialect sets the dialect of the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) SetFetchableFields ¶
func (q SQLServerUpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SQLServerUpdateQuery) SetFunc ¶
func (q SQLServerUpdateQuery) SetFunc(colmapper func(*Column)) SQLServerUpdateQuery
SetFunc sets the ColumnMapper of the SQLServerUpdateQuery.
func (SQLServerUpdateQuery) Where ¶
func (q SQLServerUpdateQuery) Where(predicates ...Predicate) SQLServerUpdateQuery
Where appends to the WherePredicate field of the SQLServerUpdateQuery.
type SQLWriter ¶
type SQLWriter interface { // WriteSQL writes the SQL representation of the SQLWriter into the query // string (*bytes.Buffer) and args slice (*[]any). // // The params map is used to hold the mappings between named parameters in // the query to the corresponding index in the args slice and is used for // rebinding args by their parameter name. The params map may be nil, check // first before writing to it. WriteSQL(ctx context.Context, dialect string, buf *bytes.Buffer, args *[]any, params map[string][]int) error }
SQLWriter is anything that can be converted to SQL.
type SQLiteDeleteQuery ¶
type SQLiteDeleteQuery DeleteQuery
SQLiteDeleteQuery represents an SQLite DELETE query.
func (SQLiteDeleteQuery) GetDialect ¶
func (q SQLiteDeleteQuery) GetDialect() string
GetDialect implements the Query interface.
func (SQLiteDeleteQuery) GetFetchableFields ¶
func (q SQLiteDeleteQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (SQLiteDeleteQuery) Returning ¶
func (q SQLiteDeleteQuery) Returning(fields ...Field) SQLiteDeleteQuery
Returning appends fields to the RETURNING clause of the SQLiteDeleteQuery.
func (SQLiteDeleteQuery) SetDialect ¶
func (q SQLiteDeleteQuery) SetDialect(dialect string) SQLiteDeleteQuery
SetDialect sets the dialect of the query.
func (SQLiteDeleteQuery) SetFetchableFields ¶
func (q SQLiteDeleteQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SQLiteDeleteQuery) Where ¶
func (q SQLiteDeleteQuery) Where(predicates ...Predicate) SQLiteDeleteQuery
Where appends to the WherePredicate field of the SQLiteDeleteQuery.
type SQLiteInsertQuery ¶
type SQLiteInsertQuery InsertQuery
SQLiteInsertQuery represents an SQLite INSERT query.
func (SQLiteInsertQuery) ColumnValues ¶
func (q SQLiteInsertQuery) ColumnValues(colmapper func(*Column)) SQLiteInsertQuery
ColumnValues sets the ColumnMapper field of the SQLiteInsertQuery.
func (SQLiteInsertQuery) Columns ¶
func (q SQLiteInsertQuery) Columns(fields ...Field) SQLiteInsertQuery
Columns sets the InsertColumns field of the SQLiteInsertQuery.
func (SQLiteInsertQuery) GetDialect ¶
func (q SQLiteInsertQuery) GetDialect() string
GetDialect implements the Query interface.
func (SQLiteInsertQuery) GetFetchableFields ¶
func (q SQLiteInsertQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (SQLiteInsertQuery) OnConflict ¶
func (q SQLiteInsertQuery) OnConflict(fields ...Field) sqliteInsertConflict
OnConflict starts the ON CONFLICT clause of the SQLiteInsertQuery.
func (SQLiteInsertQuery) Returning ¶
func (q SQLiteInsertQuery) Returning(fields ...Field) SQLiteInsertQuery
Returning adds fields to the RETURNING clause of the SQLiteInsertQuery.
func (SQLiteInsertQuery) Select ¶
func (q SQLiteInsertQuery) Select(query Query) SQLiteInsertQuery
Select sets the SelectQuery field of the SQLiteInsertQuery.
func (SQLiteInsertQuery) SetDialect ¶
func (q SQLiteInsertQuery) SetDialect(dialect string) SQLiteInsertQuery
SetDialect returns the dialect of the query.
func (SQLiteInsertQuery) SetFetchableFields ¶
func (q SQLiteInsertQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SQLiteInsertQuery) Values ¶
func (q SQLiteInsertQuery) Values(values ...any) SQLiteInsertQuery
Values sets the RowValues field of the SQLiteInsertQuery.
func (SQLiteInsertQuery) Where ¶
func (q SQLiteInsertQuery) Where(predicates ...Predicate) SQLiteInsertQuery
Where adds predicates to the DO UPDATE SET clause of the SQLiteInsertQuery.
type SQLiteSelectQuery ¶
type SQLiteSelectQuery SelectQuery
SQLiteSelectQuery represents an SQLite SELECT query.
func (SQLiteSelectQuery) As ¶
func (q SQLiteSelectQuery) As(alias string, columns ...string) SQLiteSelectQuery
As returns a new SQLiteSelectQuery with the table alias (and optionally column aliases).
func (SQLiteSelectQuery) CrossJoin ¶
func (q SQLiteSelectQuery) CrossJoin(table Table) SQLiteSelectQuery
CrossJoin cross joins a new Table to the SQLiteSelectQuery.
func (SQLiteSelectQuery) CustomJoin ¶
func (q SQLiteSelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLiteSelectQuery
CustomJoin joins a new Table to the SQLiteSelectQuery with a custom join operator.
func (SQLiteSelectQuery) Field ¶
func (q SQLiteSelectQuery) Field(name string) AnyField
Field returns a new field qualified by the SQLiteSelectQuery's alias.
func (SQLiteSelectQuery) From ¶
func (q SQLiteSelectQuery) From(table Table) SQLiteSelectQuery
From sets the FromTable field in the SQLiteSelectQuery.
func (SQLiteSelectQuery) GetAlias ¶
func (q SQLiteSelectQuery) GetAlias() string
GetAlias returns the alias of the SQLiteSelectQuery.
func (SQLiteSelectQuery) GetDialect ¶
func (q SQLiteSelectQuery) GetDialect() string
GetDialect implements the Query interface.
func (SQLiteSelectQuery) GetFetchableFields ¶
func (q SQLiteSelectQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (SQLiteSelectQuery) GroupBy ¶
func (q SQLiteSelectQuery) GroupBy(fields ...Field) SQLiteSelectQuery
GroupBy appends to the GroupByFields field in the SQLiteSelectQuery.
func (SQLiteSelectQuery) Having ¶
func (q SQLiteSelectQuery) Having(predicates ...Predicate) SQLiteSelectQuery
Having appends to the HavingPredicate field in the SQLiteSelectQuery.
func (SQLiteSelectQuery) IsArray ¶
func (q SQLiteSelectQuery) IsArray()
IsArray implements the Array interface.
func (SQLiteSelectQuery) IsBinary ¶
func (q SQLiteSelectQuery) IsBinary()
IsBinary implements the Binary interface.
func (SQLiteSelectQuery) IsBoolean ¶
func (q SQLiteSelectQuery) IsBoolean()
IsBoolean implements the Boolean interface.
func (SQLiteSelectQuery) IsEnum ¶
func (q SQLiteSelectQuery) IsEnum()
IsEnum implements the Enum interface.
func (SQLiteSelectQuery) IsField ¶
func (q SQLiteSelectQuery) IsField()
IsField implements the Field interface.
func (SQLiteSelectQuery) IsJSON ¶
func (q SQLiteSelectQuery) IsJSON()
IsJSON implements the JSON interface.
func (SQLiteSelectQuery) IsNumber ¶
func (q SQLiteSelectQuery) IsNumber()
IsNumber implements the Number interface.
func (SQLiteSelectQuery) IsString ¶
func (q SQLiteSelectQuery) IsString()
IsString implements the String interface.
func (SQLiteSelectQuery) IsTable ¶
func (q SQLiteSelectQuery) IsTable()
IsTable implements the Table interface.
func (SQLiteSelectQuery) IsTime ¶
func (q SQLiteSelectQuery) IsTime()
IsTime implements the Time interface.
func (SQLiteSelectQuery) IsUUID ¶
func (q SQLiteSelectQuery) IsUUID()
IsUUID implements the UUID interface.
func (SQLiteSelectQuery) Join ¶
func (q SQLiteSelectQuery) Join(table Table, predicates ...Predicate) SQLiteSelectQuery
Join joins a new Table to the SQLiteSelectQuery.
func (SQLiteSelectQuery) JoinUsing ¶
func (q SQLiteSelectQuery) JoinUsing(table Table, fields ...Field) SQLiteSelectQuery
JoinUsing joins a new Table to the SQLiteSelectQuery with the USING operator.
func (SQLiteSelectQuery) LeftJoin ¶
func (q SQLiteSelectQuery) LeftJoin(table Table, predicates ...Predicate) SQLiteSelectQuery
LeftJoin left joins a new Table to the SQLiteSelectQuery.
func (SQLiteSelectQuery) Limit ¶
func (q SQLiteSelectQuery) Limit(limit any) SQLiteSelectQuery
Limit sets the LimitRows field in the SQLiteSelectQuery.
func (SQLiteSelectQuery) Offset ¶
func (q SQLiteSelectQuery) Offset(offset any) SQLiteSelectQuery
Offset sets the OffsetRows field in the SQLiteSelectQuery.
func (SQLiteSelectQuery) OrderBy ¶
func (q SQLiteSelectQuery) OrderBy(fields ...Field) SQLiteSelectQuery
OrderBy appends to the OrderByFields field in the SQLiteSelectQuery.
func (SQLiteSelectQuery) Select ¶
func (q SQLiteSelectQuery) Select(fields ...Field) SQLiteSelectQuery
Select appends to the SelectFields in the SQLiteSelectQuery.
func (SQLiteSelectQuery) SelectDistinct ¶
func (q SQLiteSelectQuery) SelectDistinct(fields ...Field) SQLiteSelectQuery
SelectDistinct sets the SelectFields in the SQLiteSelectQuery.
func (SQLiteSelectQuery) SelectOne ¶
func (q SQLiteSelectQuery) SelectOne(fields ...Field) SQLiteSelectQuery
SelectOne sets the SQLiteSelectQuery to SELECT 1.
func (SQLiteSelectQuery) SetDialect ¶
func (q SQLiteSelectQuery) SetDialect(dialect string) SQLiteSelectQuery
SetDialect sets the dialect of the query.
func (SQLiteSelectQuery) SetFetchableFields ¶
func (q SQLiteSelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SQLiteSelectQuery) Where ¶
func (q SQLiteSelectQuery) Where(predicates ...Predicate) SQLiteSelectQuery
Where appends to the WherePredicate field in the SQLiteSelectQuery.
type SQLiteUpdateQuery ¶
type SQLiteUpdateQuery UpdateQuery
SQLiteUpdateQuery represents an SQLite UPDATE query.
func (SQLiteUpdateQuery) CrossJoin ¶
func (q SQLiteUpdateQuery) CrossJoin(table Table) SQLiteUpdateQuery
CrossJoin cross joins a new Table to the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) CustomJoin ¶
func (q SQLiteUpdateQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SQLiteUpdateQuery
CustomJoin joins a new Table to the SQLiteUpdateQuery with a custom join operator.
func (SQLiteUpdateQuery) From ¶
func (q SQLiteUpdateQuery) From(table Table) SQLiteUpdateQuery
From sets the FromTable field of the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) GetDialect ¶
func (q SQLiteUpdateQuery) GetDialect() string
GetDialect implements the Query interface.
func (SQLiteUpdateQuery) GetFetchableFields ¶
func (q SQLiteUpdateQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) Join ¶
func (q SQLiteUpdateQuery) Join(table Table, predicates ...Predicate) SQLiteUpdateQuery
Join joins a new Table to the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) JoinUsing ¶
func (q SQLiteUpdateQuery) JoinUsing(table Table, fields ...Field) SQLiteUpdateQuery
JoinUsing joins a new Table to the SQLiteUpdateQuery with the USING operator.
func (SQLiteUpdateQuery) LeftJoin ¶
func (q SQLiteUpdateQuery) LeftJoin(table Table, predicates ...Predicate) SQLiteUpdateQuery
LeftJoin left joins a new Table to the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) Returning ¶
func (q SQLiteUpdateQuery) Returning(fields ...Field) SQLiteUpdateQuery
Returning sets the ReturningFields field of the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) Set ¶
func (q SQLiteUpdateQuery) Set(assignments ...Assignment) SQLiteUpdateQuery
Set sets the Assignments field of the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) SetDialect ¶
func (q SQLiteUpdateQuery) SetDialect(dialect string) SQLiteUpdateQuery
SetDialect sets the dialect of the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) SetFetchableFields ¶
func (q SQLiteUpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SQLiteUpdateQuery) SetFunc ¶
func (q SQLiteUpdateQuery) SetFunc(colmapper func(*Column)) SQLiteUpdateQuery
SetFunc sets the ColumnMapper of the SQLiteUpdateQuery.
func (SQLiteUpdateQuery) Where ¶
func (q SQLiteUpdateQuery) Where(predicates ...Predicate) SQLiteUpdateQuery
Where appends to the WherePredicate field of the SQLiteUpdateQuery.
type SelectQuery ¶
type SelectQuery struct { Dialect string // WITH CTEs []CTE // SELECT Distinct bool SelectFields []Field DistinctOnFields []Field // TOP LimitTop any LimitTopPercent any // FROM FromTable Table // JOIN JoinTables []JoinTable // WHERE WherePredicate Predicate // GROUP BY GroupByFields []Field // HAVING HavingPredicate Predicate // WINDOW NamedWindows []NamedWindow // ORDER BY OrderByFields []Field // LIMIT LimitRows any // OFFSET OffsetRows any // FETCH NEXT FetchNextRows any FetchWithTies bool // FOR UPDATE | FOR SHARE LockClause string LockValues []any // AS Alias string Columns []string }
SelectQuery represents an SQL SELECT query.
func SelectDistinct ¶
func SelectDistinct(fields ...Field) SelectQuery
SelectDistinct creates a new SelectQuery.
func (SelectQuery) As ¶
func (q SelectQuery) As(alias string, columns ...string) SelectQuery
As returns a new SelectQuery with the table alias (and optionally column aliases).
func (SelectQuery) CrossJoin ¶
func (q SelectQuery) CrossJoin(table Table) SelectQuery
CrossJoin cross joins a new Table to the SelectQuery.
func (SelectQuery) CustomJoin ¶
func (q SelectQuery) CustomJoin(joinOperator string, table Table, predicates ...Predicate) SelectQuery
CustomJoin joins a new Table to the SelectQuery with a custom join operator.
func (SelectQuery) Field ¶
func (q SelectQuery) Field(name string) AnyField
Field returns a new field qualified by the SelectQuery's alias.
func (SelectQuery) From ¶
func (q SelectQuery) From(table Table) SelectQuery
From sets the FromTable field in the SelectQuery.
func (SelectQuery) GetAlias ¶
func (q SelectQuery) GetAlias() string
GetAlias returns the alias of the SelectQuery.
func (SelectQuery) GetColumns ¶
func (q SelectQuery) GetColumns() []string
GetColumns returns the column aliases of the SelectQuery.
func (SelectQuery) GetDialect ¶
func (q SelectQuery) GetDialect() string
GetDialect implements the Query interface.
func (SelectQuery) GetFetchableFields ¶
func (q SelectQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (SelectQuery) GroupBy ¶
func (q SelectQuery) GroupBy(fields ...Field) SelectQuery
GroupBy appends to the GroupByFields field in the SelectQuery.
func (SelectQuery) Having ¶
func (q SelectQuery) Having(predicates ...Predicate) SelectQuery
Having appends to the HavingPredicate field in the SelectQuery.
func (SelectQuery) IsBinary ¶
func (q SelectQuery) IsBinary()
IsBinary implements the Binary interface.
func (SelectQuery) IsBoolean ¶
func (q SelectQuery) IsBoolean()
IsBoolean implements the Boolean interface.
func (SelectQuery) IsNumber ¶
func (q SelectQuery) IsNumber()
IsNumber implements the Number interface.
func (SelectQuery) IsString ¶
func (q SelectQuery) IsString()
IsString implements the String interface.
func (SelectQuery) Join ¶
func (q SelectQuery) Join(table Table, predicates ...Predicate) SelectQuery
Join joins a new Table to the SelectQuery.
func (SelectQuery) JoinUsing ¶
func (q SelectQuery) JoinUsing(table Table, fields ...Field) SelectQuery
JoinUsing joins a new Table to the SelectQuery with the USING operator.
func (SelectQuery) LeftJoin ¶
func (q SelectQuery) LeftJoin(table Table, predicates ...Predicate) SelectQuery
LeftJoin left joins a new Table to the SelectQuery.
func (SelectQuery) Limit ¶
func (q SelectQuery) Limit(limit any) SelectQuery
Limit sets the LimitRows field in the SelectQuery.
func (SelectQuery) Offset ¶
func (q SelectQuery) Offset(offset any) SelectQuery
Offset sets the OffsetRows field in the SelectQuery.
func (SelectQuery) OrderBy ¶
func (q SelectQuery) OrderBy(fields ...Field) SelectQuery
OrderBy appends to the OrderByFields field in the SelectQuery.
func (SelectQuery) Select ¶
func (q SelectQuery) Select(fields ...Field) SelectQuery
Select appends to the SelectFields in the SelectQuery.
func (SelectQuery) SelectDistinct ¶
func (q SelectQuery) SelectDistinct(fields ...Field) SelectQuery
SelectDistinct sets the SelectFields in the SelectQuery.
func (SelectQuery) SelectOne ¶
func (q SelectQuery) SelectOne(fields ...Field) SelectQuery
SelectOne sets the SelectQuery to SELECT 1.
func (SelectQuery) SetDialect ¶
func (q SelectQuery) SetDialect(dialect string) SelectQuery
SetDialect sets the dialect of the query.
func (SelectQuery) SetFetchableFields ¶
func (q SelectQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (SelectQuery) Where ¶
func (q SelectQuery) Where(predicates ...Predicate) SelectQuery
Where appends to the WherePredicate field in the SelectQuery.
type SelectValues ¶
SelectValues represents a table literal comprised of SELECT statements UNION-ed together e.g.
(SELECT 1 AS a, 2 AS b, 3 AS c UNION ALL SELECT 4, 5, 6 UNION ALL SELECT 7, 8, 9) AS tbl
func (SelectValues) Field ¶
func (vs SelectValues) Field(name string) AnyField
Field returns a new field qualified by the SelectValues' alias.
func (SelectValues) GetAlias ¶
func (vs SelectValues) GetAlias() string
GetAlias returns the alias of the SelectValues.
func (SelectValues) GetDialect ¶
func (vs SelectValues) GetDialect() string
GetDialect implements the Query interface. It always returns an empty string.
func (SelectValues) IsTable ¶
func (vs SelectValues) IsTable()
IsTable implements the Table interface.
func (SelectValues) SetFetchableFields ¶
func (vs SelectValues) SetFetchableFields([]Field) (query Query, ok bool)
SetFetchableFields implements the Query interface. It always returns false as the second result.
type SimpleCase ¶
SimpleCase holds the result to be used for a given value in a SimpleCaseExpression.
type SimpleCaseExpression ¶
type SimpleCaseExpression struct { Expression any Cases SimpleCases Default any // contains filtered or unexported fields }
SimpleCaseExpression represents an SQL simple CASE expression.
func (SimpleCaseExpression) As ¶
func (e SimpleCaseExpression) As(alias string) SimpleCaseExpression
As returns a new SimpleCaseExpression with the given alias.
func (SimpleCaseExpression) Else ¶
func (e SimpleCaseExpression) Else(fallback any) SimpleCaseExpression
Else sets the fallback result of the SimpleCaseExpression.
func (SimpleCaseExpression) GetAlias ¶
func (e SimpleCaseExpression) GetAlias() string
GetAlias returns the alias of the SimpleCaseExpression.
func (SimpleCaseExpression) IsArray ¶
func (e SimpleCaseExpression) IsArray()
IsArray implements the Array interface.
func (SimpleCaseExpression) IsBinary ¶
func (e SimpleCaseExpression) IsBinary()
IsBinary implements the Binary interface.
func (SimpleCaseExpression) IsBoolean ¶
func (e SimpleCaseExpression) IsBoolean()
IsBoolean implements the Boolean interface.
func (SimpleCaseExpression) IsEnum ¶
func (e SimpleCaseExpression) IsEnum()
IsEnum implements the Enum interface.
func (SimpleCaseExpression) IsField ¶
func (e SimpleCaseExpression) IsField()
IsField implements the Field interface.
func (SimpleCaseExpression) IsJSON ¶
func (e SimpleCaseExpression) IsJSON()
IsJSON implements the JSON interface.
func (SimpleCaseExpression) IsNumber ¶
func (e SimpleCaseExpression) IsNumber()
IsNumber implements the Number interface.
func (SimpleCaseExpression) IsString ¶
func (e SimpleCaseExpression) IsString()
IsString implements the String interface.
func (SimpleCaseExpression) IsTime ¶
func (e SimpleCaseExpression) IsTime()
IsTime implements the Time interface.
func (SimpleCaseExpression) IsUUID ¶
func (e SimpleCaseExpression) IsUUID()
IsUUID implements the UUID interface.
func (SimpleCaseExpression) When ¶
func (e SimpleCaseExpression) When(value any, result any) SimpleCaseExpression
When adds a new value-result pair to the SimpleCaseExpression.
type SqLogger ¶
type SqLogger interface { // SqLogSettings should populate a LogSettings struct, which influences // what is added into the QueryStats. SqLogSettings(context.Context, *LogSettings) // SqLogQuery logs a query when for the given QueryStats. SqLogQuery(context.Context, QueryStats) }
SqLogger represents a logger for the sq package.
type StringField ¶
type StringField struct {
// contains filtered or unexported fields
}
StringField represents an SQL string field.
func NewStringField ¶
func NewStringField(name string, tbl TableStruct) StringField
NewStringField returns a new StringField.
func (StringField) As ¶
func (field StringField) As(alias string) StringField
As returns a new StringField with the given alias.
func (StringField) Asc ¶
func (field StringField) Asc() StringField
Asc returns a new StringField indicating that it should be ordered in ascending order i.e. 'ORDER BY field ASC'.
func (StringField) Collate ¶
func (field StringField) Collate(collation string) StringField
Collate returns a new StringField using the given collation.
func (StringField) Desc ¶
func (field StringField) Desc() StringField
Desc returns a new StringField indicating that it should be ordered in descending order i.e. 'ORDER BY field DESC'.
func (StringField) Eq ¶
func (field StringField) Eq(value String) Predicate
Eq returns a 'field = value' Predicate.
func (StringField) EqString ¶
func (field StringField) EqString(str string) Predicate
EqString returns a 'field = str' Predicate.
func (StringField) Ge ¶
func (field StringField) Ge(value String) Predicate
Ge returns a 'field >= value' Predicate.
func (StringField) GeString ¶
func (field StringField) GeString(str string) Predicate
GeString returns a 'field >= str' Predicate.
func (StringField) GetAlias ¶
func (field StringField) GetAlias() string
GetAlias returns the alias of the StringField.
func (StringField) Gt ¶
func (field StringField) Gt(value String) Predicate
Gt returns a 'field > value' Predicate.
func (StringField) GtString ¶
func (field StringField) GtString(str string) Predicate
GtString returns a 'field > str' Predicate.
func (StringField) ILikeString ¶
func (field StringField) ILikeString(str string) Predicate
ILikeString returns a 'field ILIKE str' Predicate.
func (StringField) In ¶
func (field StringField) In(value any) Predicate
In returns a 'field IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field IN (x, y, z)'.
func (StringField) IsField ¶
func (field StringField) IsField()
IsField implements the Field interface.
func (StringField) IsNotNull ¶
func (field StringField) IsNotNull() Predicate
IsNotNull returns a 'field IS NOT NULL' Predicate.
func (StringField) IsNull ¶
func (field StringField) IsNull() Predicate
IsNull returns a 'field IS NULL' Predicate.
func (StringField) IsString ¶
func (field StringField) IsString()
IsString implements the String interface.
func (StringField) Le ¶
func (field StringField) Le(value String) Predicate
Le returns a 'field <= value' Predicate.
func (StringField) LeString ¶
func (field StringField) LeString(str string) Predicate
LeString returns a 'field <= str' Predicate.
func (StringField) LikeString ¶
func (field StringField) LikeString(str string) Predicate
LikeString returns a 'field LIKE str' Predicate.
func (StringField) Lt ¶
func (field StringField) Lt(value String) Predicate
Lt returns a 'field < value' Predicate.
func (StringField) LtString ¶
func (field StringField) LtString(str string) Predicate
LtString returns a 'field < str' Predicate.
func (StringField) Ne ¶
func (field StringField) Ne(value String) Predicate
Ne returns a 'field <> value' Predicate.
func (StringField) NeString ¶
func (field StringField) NeString(str string) Predicate
NeString returns a 'field <> str' Predicate.
func (StringField) NotILikeString ¶ added in v0.3.0
func (field StringField) NotILikeString(str string) Predicate
NotILikeString returns a 'field NOT ILIKE str' Predicate.
func (StringField) NotIn ¶ added in v0.3.0
func (field StringField) NotIn(value any) Predicate
In returns a 'field NOT IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field NOT IN (x, y, z)'.
func (StringField) NotLikeString ¶ added in v0.3.0
func (field StringField) NotLikeString(str string) Predicate
NotLikeString returns a 'field NOT LIKE str' Predicate.
func (StringField) NullsFirst ¶
func (field StringField) NullsFirst() StringField
NullsFirst returns a new StringField indicating that it should be ordered with nulls first i.e. 'ORDER BY field NULLS FIRST'.
func (StringField) NullsLast ¶
func (field StringField) NullsLast() StringField
NullsLast returns a new StringField indicating that it should be ordered with nulls last i.e. 'ORDER BY field NULLS LAST'.
func (StringField) Set ¶
func (field StringField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (StringField) SetString ¶
func (field StringField) SetString(str string) Assignment
SetString returns an Assignment assigning a string to the field.
func (StringField) Setf ¶
func (field StringField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (StringField) WithPrefix ¶
func (field StringField) WithPrefix(prefix string) Field
WithPrefix returns a new Field that with the given prefix.
type StringParameter ¶
StringParameter is identical to sql.NamedArg, but implements the String interface.
func StringParam ¶
func StringParam(name string, s string) StringParameter
StringParam creates a new StringParameter from a string value.
func (StringParameter) IsField ¶
func (p StringParameter) IsField()
IsField implements the Field interface.
func (StringParameter) IsString ¶
func (p StringParameter) IsString()
IsString implements the String interface.
type Table ¶
type Table interface { SQLWriter IsTable() }
Table is anything you can Select from or Join.
type TableStruct ¶
type TableStruct struct {
// contains filtered or unexported fields
}
TableStruct is meant to be embedded in table structs to make them implement the Table interface.
func NewTableStruct ¶
func NewTableStruct(schema, name, alias string) TableStruct
NewTableStruct creates a new TableStruct.
func (TableStruct) GetAlias ¶
func (ts TableStruct) GetAlias() string
GetAlias returns the alias of the TableStruct.
func (TableStruct) IsTable ¶
func (ts TableStruct) IsTable()
IsTable implements the Table interface.
type TableValues ¶
TableValues represents a table literal created by the VALUES clause e.g.
(VALUES
(1, 2, 3), (4, 5, 6), (7, 8, 9)) AS tbl (a, b, c)
func (TableValues) Field ¶
func (vs TableValues) Field(name string) AnyField
Field returns a new field qualified by the TableValues' alias.
func (TableValues) GetAlias ¶
func (vs TableValues) GetAlias() string
GetAlias returns the alias of the TableValues.
func (TableValues) GetColumns ¶
func (vs TableValues) GetColumns() []string
GetColumns returns the names of the columns in the TableValues.
func (TableValues) GetDialect ¶
func (vs TableValues) GetDialect() string
GetDialect implements the Query interface. It always returns an empty string.
func (TableValues) IsTable ¶
func (vs TableValues) IsTable()
IsTable implements the Table interface.
func (TableValues) SetFetchableFields ¶
func (vs TableValues) SetFetchableFields([]Field) (query Query, ok bool)
SetFetchableFields implements the Query interface. It always returns false as the second result.
type TimeField ¶
type TimeField struct {
// contains filtered or unexported fields
}
TimeField represents an SQL time field.
func NewTimeField ¶
func NewTimeField(name string, tbl TableStruct) TimeField
NewTimeField returns a new TimeField.
func (TimeField) Asc ¶
Asc returns a new TimeField indicating that it should be ordered in ascending order i.e. 'ORDER BY field ASC'.
func (TimeField) Desc ¶
Desc returns a new TimeField indicating that it should be ordered in ascending order i.e. 'ORDER BY field DESC'.
func (TimeField) In ¶
In returns a 'field IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field IN (x, y, z)'.
func (TimeField) NotIn ¶ added in v0.3.0
NotIn returns a 'field NOT IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field NOT IN (x, y, z)'.
func (TimeField) NullsFirst ¶
NullsFirst returns a new TimeField indicating that it should be ordered with nulls first i.e. 'ORDER BY field NULLS FIRST'.
func (TimeField) NullsLast ¶
NullsLast returns a new TimeField indicating that it should be ordered with nulls last i.e. 'ORDER BY field NULLS LAST'.
func (TimeField) Set ¶
func (field TimeField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (TimeField) SetTime ¶
func (field TimeField) SetTime(t time.Time) Assignment
SetTime returns an Assignment assigning a time.Time to the field.
func (TimeField) Setf ¶
func (field TimeField) Setf(format string, values ...any) Assignment
Setf returns an Assignment assigning an expression to the field.
func (TimeField) WithPrefix ¶
WithPrefix returns a new Field that with the given prefix.
type TimeParameter ¶
TimeParameter is identical to sql.NamedArg, but implements the Time interface.
func TimeParam ¶
func TimeParam(name string, t time.Time) TimeParameter
TimeParam creates a new TimeParameter from a time.Time value.
func (TimeParameter) IsField ¶
func (p TimeParameter) IsField()
IsField implements the Field interface.
type Timestamp ¶
Timestamp is as a replacement for sql.NullTime but with the following enhancements:
1. Timestamp.Value() returns an int64 unix timestamp if the dialect is SQLite, otherwise it returns a time.Time (similar to sql.NullTime).
2. Timestamp.Scan() additionally supports scanning from int64 and text (string/[]byte) values on top of what sql.NullTime already supports. The following text timestamp formats are supported:
var timestampFormats = []string{ "2006-01-02 15:04:05.999999999-07:00", "2006-01-02T15:04:05.999999999-07:00", "2006-01-02 15:04:05.999999999", "2006-01-02T15:04:05.999999999", "2006-01-02 15:04:05", "2006-01-02T15:04:05", "2006-01-02 15:04", "2006-01-02T15:04", "2006-01-02", }
func NewTimestamp ¶
NewTimestamp creates a new Timestamp from a time.Time.
func (Timestamp) DialectValuer ¶
DialectValuer implements the DialectValuer interface.
func (*Timestamp) Scan ¶
Scan implements the sql.Scanner interface. It additionally supports scanning from int64 and text (string/[]byte) values on top of what sql.NullTime already supports. The following text timestamp formats are supported:
var timestampFormats = []string{ "2006-01-02 15:04:05.999999999-07:00", "2006-01-02T15:04:05.999999999-07:00", "2006-01-02 15:04:05.999999999", "2006-01-02T15:04:05.999999999", "2006-01-02 15:04:05", "2006-01-02T15:04:05", "2006-01-02 15:04", "2006-01-02T15:04", "2006-01-02", }
type UUIDField ¶
type UUIDField struct {
// contains filtered or unexported fields
}
UUIDField represents an SQL UUID field.
func NewUUIDField ¶
func NewUUIDField(name string, tbl TableStruct) UUIDField
NewUUIDField returns a new UUIDField.
func (UUIDField) Asc ¶
Asc returns a new UUIDField indicating that it should be ordered in ascending order i.e. 'ORDER BY field ASC'.
func (UUIDField) Desc ¶
Desc returns a new UUIDField indicating that it should be ordered in ascending order i.e. 'ORDER BY field DESC'.
func (UUIDField) EqUUID ¶ added in v0.2.1
EqUUID returns a 'field = value' Predicate. The value is wrapped in UUIDValue().
func (UUIDField) In ¶
In returns a 'field IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field IN (x, y, z)'.
func (UUIDField) NeUUID ¶ added in v0.2.1
NeUUID returns a 'field <> value' Predicate. The value is wrapped in UUIDValue().
func (UUIDField) NotIn ¶ added in v0.3.0
NotIn returns a 'field NOT IN (value)' Predicate. The value can be a slice, which corresponds to the expression 'field NOT IN (x, y, z)'.
func (UUIDField) NullsFirst ¶
NullsFirst returns a new UUIDField indicating that it should be ordered with nulls first i.e. 'ORDER BY field NULLS FIRST'.
func (UUIDField) NullsLast ¶
NullsLast returns a new UUIDField indicating that it should be ordered with nulls last i.e. 'ORDER BY field NULLS LAST'.
func (UUIDField) Set ¶
func (field UUIDField) Set(value any) Assignment
Set returns an Assignment assigning the value to the field.
func (UUIDField) SetUUID ¶
func (field UUIDField) SetUUID(value any) Assignment
SetUUID returns an Assignment assigning the value to the field. It wraps the value in UUIDValue().
func (UUIDField) Setf ¶
func (field UUIDField) Setf(format string, values ...any) Assignment
Set returns an Assignment assigning the value to the field.
func (UUIDField) WithPrefix ¶
WithPrefix returns a new Field that with the given prefix.
type UUIDParameter ¶ added in v0.3.5
UUIDParameter is identical to sql.NamedArg, but implements the UUID interface.
func UUIDParam ¶ added in v0.3.5
func UUIDParam(name string, value any) UUIDParameter
UUIDParam creates a new UUIDParameter. It wraps the value with UUIDValue().
func (UUIDParameter) IsField ¶ added in v0.3.5
func (p UUIDParameter) IsField()
IsField implements the Field interface.
func (UUIDParameter) IsUUID ¶ added in v0.3.5
func (p UUIDParameter) IsUUID()
IsUUID implements the UUID interface.
type UpdateQuery ¶
type UpdateQuery struct { Dialect string ColumnMapper func(*Column) // WITH CTEs []CTE // UPDATE UpdateTable Table // FROM FromTable Table JoinTables []JoinTable // SET Assignments []Assignment // WHERE WherePredicate Predicate // ORDER BY OrderByFields []Field // LIMIT LimitRows any // RETURNING ReturningFields []Field }
UpdateQuery represents an SQL UPDATE query.
func (UpdateQuery) GetDialect ¶
func (q UpdateQuery) GetDialect() string
GetDialect implements the Query interface.
func (UpdateQuery) GetFetchableFields ¶
func (q UpdateQuery) GetFetchableFields() []Field
GetFetchableFields returns the fetchable fields of the query.
func (UpdateQuery) Set ¶
func (q UpdateQuery) Set(assignments ...Assignment) UpdateQuery
Set sets the Assignments field of the UpdateQuery.
func (UpdateQuery) SetDialect ¶
func (q UpdateQuery) SetDialect(dialect string) UpdateQuery
SetDialect sets the dialect of the query.
func (UpdateQuery) SetFetchableFields ¶
func (q UpdateQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
func (UpdateQuery) SetFunc ¶
func (q UpdateQuery) SetFunc(colmapper func(*Column)) UpdateQuery
SetFunc sets the ColumnMapper field of the UpdateQuery.
func (UpdateQuery) Where ¶
func (q UpdateQuery) Where(predicates ...Predicate) UpdateQuery
Where appends to the WherePredicate field of the UpdateQuery.
type ValueExpression ¶
type ValueExpression struct {
// contains filtered or unexported fields
}
ValueExpression represents an SQL value that is passed in as an argument to a prepared query.
func (ValueExpression) As ¶
func (e ValueExpression) As(alias string) ValueExpression
As returns a new ValueExpression with the given alias.
func (ValueExpression) Eq ¶
func (e ValueExpression) Eq(val any) Predicate
Eq returns a 'expr = val' Predicate.
func (ValueExpression) Ge ¶
func (e ValueExpression) Ge(val any) Predicate
Ge returns a 'expr >= val' Predicate.
func (ValueExpression) GetAlias ¶
func (e ValueExpression) GetAlias() string
GetAlias returns the alias of the ValueExpression.
func (ValueExpression) Gt ¶
func (e ValueExpression) Gt(val any) Predicate
Gt returns a 'expr > val' Predicate.
func (ValueExpression) In ¶
func (e ValueExpression) In(val any) Predicate
In returns a 'expr IN (val)' Predicate.
func (ValueExpression) IsArray ¶
func (e ValueExpression) IsArray()
IsArray implements the Array interface.
func (ValueExpression) IsBinary ¶
func (e ValueExpression) IsBinary()
IsBinary implements the Binary interface.
func (ValueExpression) IsBoolean ¶
func (e ValueExpression) IsBoolean()
IsBoolean implements the Boolean interface.
func (ValueExpression) IsEnum ¶
func (e ValueExpression) IsEnum()
IsEnum implements the Enum interface.
func (ValueExpression) IsField ¶
func (e ValueExpression) IsField()
IsField implements the Field interface.
func (ValueExpression) IsJSON ¶
func (e ValueExpression) IsJSON()
IsJSON implements the JSON interface.
func (ValueExpression) IsNumber ¶
func (e ValueExpression) IsNumber()
IsNumber implements the Number interface.
func (ValueExpression) IsString ¶
func (e ValueExpression) IsString()
IsString implements the String interface.
func (ValueExpression) IsTime ¶
func (e ValueExpression) IsTime()
IsTime implements the Time interfaces.
func (ValueExpression) IsUUID ¶
func (e ValueExpression) IsUUID()
IsUUID implements the UUID interface.
func (ValueExpression) Le ¶
func (e ValueExpression) Le(val any) Predicate
Le returns a 'expr <= val' Predicate.
func (ValueExpression) Lt ¶
func (e ValueExpression) Lt(val any) Predicate
Lt returns a 'expr < val' Predicate.
func (ValueExpression) Ne ¶
func (e ValueExpression) Ne(val any) Predicate
Ne returns a 'expr <> val' Predicate.
type VariadicPredicate ¶
type VariadicPredicate struct { // Toplevel indicates if the VariadicPredicate can skip writing the // (surrounding brackets). Toplevel bool // If IsDisjunction is true, the Predicates are joined using OR. If false, // the Predicates are joined using AND. The default is AND. IsDisjunction bool // Predicates holds the predicates inside the VariadicPredicate Predicates []Predicate // contains filtered or unexported fields }
VariadicPredicate represents the 'x AND y AND z...' or 'x OR Y OR z...' SQL construct.
func And ¶
func And(predicates ...Predicate) VariadicPredicate
And joins the predicates together with the AND operator.
func Or ¶
func Or(predicates ...Predicate) VariadicPredicate
Or joins the predicates together with the OR operator.
func (VariadicPredicate) As ¶
func (p VariadicPredicate) As(alias string) VariadicPredicate
As returns a new VariadicPredicate with the given alias.
func (VariadicPredicate) GetAlias ¶
func (p VariadicPredicate) GetAlias() string
GetAlias returns the alias of the VariadicPredicate.
func (VariadicPredicate) IsBoolean ¶
func (p VariadicPredicate) IsBoolean()
IsBooleanType implements the Predicate interface.
func (VariadicPredicate) IsField ¶
func (p VariadicPredicate) IsField()
IsField implements the Field interface.
type VariadicQuery ¶
type VariadicQuery struct { Toplevel bool Operator VariadicQueryOperator Queries []Query }
VariadicQuery represents the 'x UNION y UNION z...' etc SQL constructs.
func Except ¶
func Except(queries ...Query) VariadicQuery
Except joins the queries together with the EXCEPT operator.
func ExceptAll ¶
func ExceptAll(queries ...Query) VariadicQuery
ExceptAll joins the queries together with the EXCEPT ALL operator.
func Intersect ¶
func Intersect(queries ...Query) VariadicQuery
Intersect joins the queries together with the INTERSECT operator.
func IntersectAll ¶
func IntersectAll(queries ...Query) VariadicQuery
IntersectAll joins the queries together with the INTERSECT ALL operator.
func Union ¶
func Union(queries ...Query) VariadicQuery
Union joins the queries together with the UNION operator.
func UnionAll ¶
func UnionAll(queries ...Query) VariadicQuery
UnionAll joins the queries together with the UNION ALL operator.
func (VariadicQuery) GetDialect ¶
func (q VariadicQuery) GetDialect() string
GetDialect returns the SQL dialect of the VariadicQuery.
func (VariadicQuery) GetFetchableFields ¶
func (q VariadicQuery) GetFetchableFields() []Field
GetFetchableFields implements the Query interface.
func (VariadicQuery) SetFetchableFields ¶
func (q VariadicQuery) SetFetchableFields(fields []Field) (query Query, ok bool)
SetFetchableFields implements the Query interface.
type VariadicQueryOperator ¶
type VariadicQueryOperator string
VariadicQueryOperator represents a variadic query operator.
const ( QueryUnion VariadicQueryOperator = "UNION" QueryUnionAll VariadicQueryOperator = "UNION ALL" QueryIntersect VariadicQueryOperator = "INTERSECT" QueryIntersectAll VariadicQueryOperator = "INTERSECT ALL" QueryExcept VariadicQueryOperator = "EXCEPT" QueryExceptAll VariadicQueryOperator = "EXCEPT ALL" )
VariadicQuery operators.
type Window ¶
type Window interface { SQLWriter IsWindow() }
Window is a window used in SQL window functions.
type WindowDefinition ¶
type WindowDefinition struct { BaseWindowName string PartitionByFields []Field OrderByFields []Field FrameSpec string FrameValues []any }
WindowDefinition represents an SQL window definition.
func BaseWindow ¶
func BaseWindow(w NamedWindow) WindowDefinition
BaseWindow creates a new WindowDefinition based off an existing NamedWindow.
func OrderBy ¶
func OrderBy(fields ...Field) WindowDefinition
PartitionBy returns a new WindowDefinition with the ORDER BY clause.
func PartitionBy ¶
func PartitionBy(fields ...Field) WindowDefinition
PartitionBy returns a new WindowDefinition with the PARTITION BY clause.
func (WindowDefinition) Frame ¶
func (w WindowDefinition) Frame(frameSpec string, frameValues ...any) WindowDefinition
Frame returns a new WindowDefinition with the frame specification set.
func (WindowDefinition) IsWindow ¶
func (w WindowDefinition) IsWindow()
IsWindow implements the Window interface.
func (WindowDefinition) OrderBy ¶
func (w WindowDefinition) OrderBy(fields ...Field) WindowDefinition
OrderBy returns a new WindowDefinition with the ORDER BY clause.
func (WindowDefinition) PartitionBy ¶
func (w WindowDefinition) PartitionBy(fields ...Field) WindowDefinition
PartitionBy returns a new WindowDefinition with the PARTITION BY clause.