sql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownOperation   = errors.New("unknown operation")
	ErrMultipleStatements = errors.New("multiple statements in query")
)
View Source
var Parameterized = false

Functions

func And

func And(exprs ...Expr) *logicExpr

func Eq

func Eq(column string, value any) *compExpr

func FromString

func FromString(query string, args ...any) (database.Request, error)

func FullJoin

func FullJoin(table, on string) joinClause

func Gt

func Gt(column string, value any) *compExpr

func InnerJoin

func InnerJoin(table, on string) joinClause

func LeftJoin

func LeftJoin(table, on string) joinClause

func Like

func Like(column string, value any) *compExpr

func Lt

func Lt(column string, value any) *compExpr

func Ne

func Ne(column string, value any) *compExpr

func Not

func Not(expr *compExpr) *notExpr

func Null

func Null(column string) *compExpr

func Or

func Or(exprs ...Expr) *logicExpr

func RightJoin

func RightJoin(table, on string) joinClause

Types

type ConnectionProperties

type ConnectionProperties struct {
	Addr     string
	Port     int
	DBName   string
	Username string
	Password string

	Extra map[string]string
}

type Expr

type Expr interface {
	ToSQL() (string, []any)
}

type Exprs

type Exprs []Expr

func (Exprs) ToSQL

func (e Exprs) ToSQL() (string, []any)

type From

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

func DistinctSelect

func DistinctSelect(fields ...string) *From

func DistinctSelectAll

func DistinctSelectAll() *From

func Select

func Select(fields ...string) *From

func SelectAll

func SelectAll() *From

func (From) From

func (b From) From(table string, joins ...joinClause) *SelectBuilder

type JoinType

type JoinType string
const (
	JoinTypeInner JoinType = "INNER"
	JoinTypeLeft  JoinType = "LEFT"
	JoinTypeRight JoinType = "RIGHT"
	JoinTypeFull  JoinType = "FULL"
)

type SelectBuilder

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

func Count

func Count(field, table string) *SelectBuilder

func (*SelectBuilder) Copy

func (s *SelectBuilder) Copy() *SelectBuilder

func (*SelectBuilder) GroupBy

func (s *SelectBuilder) GroupBy(fields ...string) *SelectBuilder

func (*SelectBuilder) Having

func (s *SelectBuilder) Having(having string) *SelectBuilder

func (*SelectBuilder) Limit

func (s *SelectBuilder) Limit(limit int) *SelectBuilder

func (*SelectBuilder) Offset

func (s *SelectBuilder) Offset(offset int) *SelectBuilder

func (*SelectBuilder) OrderBy

func (s *SelectBuilder) OrderBy(field string, desc bool) *SelectBuilder

func (*SelectBuilder) Parameters

func (s *SelectBuilder) Parameters() []any

func (*SelectBuilder) ShouldReturn

func (s *SelectBuilder) ShouldReturn() int

func (*SelectBuilder) ToRequest

func (s *SelectBuilder) ToRequest() database.Request

func (*SelectBuilder) Where

func (s *SelectBuilder) Where(expr ...Expr) *SelectBuilder

type SelectQuery

type SelectQuery struct {
	AsDistinct bool
	IsCount    bool

	Fields []string
	Table  string

	Joins []joinClause

	WhereClause string

	GroupByClause []string
	HavingClause  string
	OrderByClause []orderByClause

	LimitClause  *int
	OffsetClause *int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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