expr

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 5 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arg added in v0.3.1

func Arg(vals ...any) bob.Expression

func Not

func Not[T any, B builder[T]](exp any) T

prefix the expression with a NOT

func OP

func OP(operator string, left, right any) bob.Expression

Generic operator between a left and right val

func P

func P(exp any) bob.Expression

Add parentheses around an expression

func Quote added in v0.2.0

func Quote(aa ...string) bob.Expression

func RawQuery

func RawQuery(d bob.Dialect, q string, args ...any) bob.BaseQuery[Raw]

func X

func X[T any, B builder[T]](exp any, others ...any) T

Build an expression

Types

type Builder

type Builder[T any, B builder[T]] struct{}

To be embedded in query mods T is the chain type, this allows dialects to have custom chain methods F is function type, so that the dialect can change where it accepted. E.g. it can be modified to work as a mod B has a New() method that is used to create a new instance of T

func (Builder[T, B]) And

func (e Builder[T, B]) And(args ...any) T

And

func (Builder[T, B]) Arg

func (e Builder[T, B]) Arg(vals ...any) T

Comma separated list of arguments

func (Builder[T, B]) Group

func (e Builder[T, B]) Group(exps ...any) T

func (Builder[T, B]) Not

func (e Builder[T, B]) Not(exp any) T

prefix the expression with a NOT

func (Builder[T, B]) Or

func (e Builder[T, B]) Or(args ...any) T

Or

func (Builder[T, B]) P

func (e Builder[T, B]) P(exp any) T

Add parentheses around an expression

func (Builder[T, B]) Placeholder

func (e Builder[T, B]) Placeholder(n uint) T

func (Builder[T, B]) Quote

func (e Builder[T, B]) Quote(aa ...string) T

quoted and joined... something like "users"."id"

func (Builder[T, B]) Raw

func (e Builder[T, B]) Raw(query string, args ...any) T

func (Builder[T, B]) S

func (e Builder[T, B]) S(s string) T

single quoted raw string

func (Builder[T, B]) X

func (e Builder[T, B]) X(exp any, others ...any) T

Start building an expression

type Chain

type Chain[T any, B builder[T]] struct {
	Base any
}

func (Chain[T, B]) And

func (x Chain[T, B]) And(targets ...any) T

AND

func (Chain[T, B]) As

func (x Chain[T, B]) As(alias string) bob.Expression

As does not return a new chain. Should be used at the end of an expression useful for columns

func (Chain[T, B]) Between

func (x Chain[T, B]) Between(a, b any) T

BETWEEN a AND b

func (Chain[T, B]) Concat

func (x Chain[T, B]) Concat(targets ...any) T

Concatenate: ||

func (Chain[T, B]) EQ

func (x Chain[T, B]) EQ(target any) T

Equal

func (Chain[T, B]) GT

func (x Chain[T, B]) GT(target any) T

Greater than

func (Chain[T, B]) GTE

func (x Chain[T, B]) GTE(target any) T

Greater than or equal to

func (Chain[T, B]) In

func (x Chain[T, B]) In(vals ...any) T

IN

func (Chain[T, B]) IsDistinctFrom added in v0.2.0

func (x Chain[T, B]) IsDistinctFrom(exp any) T

IS DISTINCT FROM

func (Chain[T, B]) IsNotDistinctFrom added in v0.2.0

func (x Chain[T, B]) IsNotDistinctFrom(exp any) T

IS NOT DISTINCT FROM

func (Chain[T, B]) IsNotNull

func (x Chain[T, B]) IsNotNull() T

IS NOT NUll

func (Chain[T, B]) IsNull

func (x Chain[T, B]) IsNull() T

IS NUll

func (Chain[T, B]) LT

func (x Chain[T, B]) LT(target any) T

Less than

func (Chain[T, B]) LTE

func (x Chain[T, B]) LTE(target any) T

Less than or equal to

func (Chain[T, B]) Minus

func (x Chain[T, B]) Minus(target any) T

Subtract

func (Chain[T, B]) NE

func (x Chain[T, B]) NE(target any) T

Not Equal

func (Chain[T, B]) NotBetween

func (x Chain[T, B]) NotBetween(a, b any) T

NOT BETWEEN a AND b

func (Chain[T, B]) NotIn

func (x Chain[T, B]) NotIn(vals ...any) T

NOT IN

func (Chain[T, B]) Or

func (x Chain[T, B]) Or(targets ...any) T

OR

func (Chain[T, B]) WriteSQL

func (x Chain[T, B]) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

WriteSQL satisfies the bob.Expression interface

type Join

type Join struct {
	Exprs []any
	Sep   string
}

If no separator, a space is used

func (Join) WriteSQL

func (s Join) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type Raw

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

A Raw Raw with arguments

func (Raw) WriteSQL

func (r Raw) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

Jump to

Keyboard shortcuts

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