expr

package
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BetweenExpr

type BetweenExpr struct {
	Column string
	Start  interface{}
	End    interface{}
	Not    bool
}

BetweenExpr represents BETWEEN operations

func (*BetweenExpr) ToSQL

func (b *BetweenExpr) ToSQL() (string, []interface{})

type BinaryExpr

type BinaryExpr struct {
	Left     string
	Operator string
	Right    interface{}
}

BinaryExpr represents a binary operation (=, !=, <, >, etc.)

func (*BinaryExpr) ToSQL

func (b *BinaryExpr) ToSQL() (string, []interface{})

type CompareExpr added in v2.0.9

type CompareExpr struct {
	Left     string
	Operator string
	Right    SQLValue
}

CompareExpr represents a comparison operation that supports both column and value comparisons

func (*CompareExpr) ToSQL added in v2.0.9

func (c *CompareExpr) ToSQL() (string, []interface{})

type Expr

type Expr interface {
	// ToSQL converts the expression to SQL with placeholders
	ToSQL() (string, []interface{})
}

Expr represents a SQL expression (WHERE, HAVING, etc.)

func And

func And(exprs ...Expr) Expr

And combines multiple expressions with AND

func Between

func Between[T any](col *table.Column[T], start, end T) Expr

Between creates a BETWEEN expression

func Eq

func Eq[T any](col *table.Column[T], value any) Expr

Eq creates an equality expression (column = value OR column = column) Accepts either a raw value or another column (SQLValue)

func Ge

func Ge[T any](col *table.Column[T], value any) Expr

Ge creates a greater-than-or-equal expression (column >= value OR column >= column)

func Gt

func Gt[T any](col *table.Column[T], value any) Expr

Gt creates a greater-than expression (column > value OR column > column)

func ILike

func ILike(col *table.Column[string], pattern string) Expr

ILike creates an ILIKE expression (case-insensitive)

func In

func In[T any](col *table.Column[T], values ...T) Expr

In creates an IN expression (column IN (values...))

func IsNotNull

func IsNotNull[T any](col *table.Column[T]) Expr

IsNotNull creates an IS NOT NULL expression

func IsNull

func IsNull[T any](col *table.Column[T]) Expr

IsNull creates an IS NULL expression

func Le

func Le[T any](col *table.Column[T], value any) Expr

Le creates a less-than-or-equal expression (column <= value OR column <= column)

func Like

func Like(col *table.Column[string], pattern string) Expr

Like creates a LIKE expression

func Lt

func Lt[T any](col *table.Column[T], value any) Expr

Lt creates a less-than expression (column < value OR column < column)

func Ne

func Ne[T any](col *table.Column[T], value any) Expr

Ne creates a not-equal expression (column != value OR column != column)

func NotBetween

func NotBetween[T any](col *table.Column[T], start, end T) Expr

NotBetween creates a NOT BETWEEN expression

func NotIn

func NotIn[T any](col *table.Column[T], values ...T) Expr

NotIn creates a NOT IN expression

func NotLike

func NotLike(col *table.Column[string], pattern string) Expr

NotLike creates a NOT LIKE expression

func Or

func Or(exprs ...Expr) Expr

Or combines multiple expressions with OR

func Raw

func Raw(sql string, args ...interface{}) Expr

Raw creates a raw SQL expression

type InExpr

type InExpr struct {
	Column string
	Values []interface{}
	Not    bool
}

InExpr represents IN/NOT IN operations

func (*InExpr) ToSQL

func (i *InExpr) ToSQL() (string, []interface{})

type LikeExpr

type LikeExpr struct {
	Column          string
	Pattern         string
	CaseInsensitive bool
	Not             bool
}

LikeExpr represents LIKE/ILIKE operations

func (*LikeExpr) ToSQL

func (l *LikeExpr) ToSQL() (string, []interface{})

type Literal added in v2.0.9

type Literal struct {
	Val interface{}
}

Literal wraps a value to implement SQLValue interface

func (Literal) SQLString added in v2.0.9

func (l Literal) SQLString() (string, bool)

func (Literal) Value added in v2.0.9

func (l Literal) Value() interface{}

type LogicalExpr

type LogicalExpr struct {
	Operator string // "AND" or "OR"
	Exprs    []Expr
}

LogicalExpr represents AND/OR combinations

func (*LogicalExpr) ToSQL

func (l *LogicalExpr) ToSQL() (string, []interface{})

type RawExpr

type RawExpr struct {
	SQL  string
	Args []interface{}
}

RawExpr represents a raw SQL expression

func (*RawExpr) ToSQL

func (r *RawExpr) ToSQL() (string, []interface{})

type SQLValue added in v2.0.9

type SQLValue interface {
	// SQLString returns the SQL representation
	// Returns (sqlString, isLiteral) where:
	// - For columns: ("table.column", false)
	// - For values: ("?", true) with the actual value stored separately
	SQLString() (string, bool)
	// Value returns the actual value if this is a literal, nil otherwise
	Value() interface{}
}

SQLValue represents a value that can be used in SQL comparisons It can be either a column reference or a literal value

func V added in v2.0.9

func V(value interface{}) SQLValue

V creates a Literal SQLValue from any value

type UnaryExpr

type UnaryExpr struct {
	Column   string
	Operator string
}

UnaryExpr represents unary operations (IS NULL, IS NOT NULL, NOT)

func (*UnaryExpr) ToSQL

func (u *UnaryExpr) ToSQL() (string, []interface{})

Jump to

Keyboard shortcuts

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