query

package
v2.0.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatPlaceholders added in v2.0.6

func FormatPlaceholders(sql string, dialect dialect.Dialect) string

FormatPlaceholders converts ? placeholders to driver-specific format.

Types

type ConnectionInterface added in v2.0.3

type ConnectionInterface interface {
	Engine() *engine.Engine
	Context() context.Context
	ExecuteContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	QueryRowsContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	GetTableName(tbl interface{}) string
	GetTableColumns(tbl interface{}) []*table.ColumnRef
}

ConnectionInterface defines the methods required by query builders

type DeleteBuilder

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

DeleteBuilder builds DELETE queries

func NewDelete

func NewDelete(session ConnectionInterface, table interface{}) *DeleteBuilder

NewDelete creates a new DELETE builder

func (*DeleteBuilder) All

func (b *DeleteBuilder) All(ctx context.Context, dest interface{}) error

All executes the DELETE with RETURNING and returns all deleted rows

func (*DeleteBuilder) Exec

func (b *DeleteBuilder) Exec(ctx context.Context) (sql.Result, error)

Exec executes the DELETE and returns the result

func (*DeleteBuilder) Returning

func (b *DeleteBuilder) Returning(columns ...string) *DeleteBuilder

Returning specifies which columns to return

func (*DeleteBuilder) ToSQL

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

ToSQL generates the SQL query and arguments

func (*DeleteBuilder) Where

func (b *DeleteBuilder) Where(condition expr.Expr) *DeleteBuilder

Where adds a WHERE condition

type InsertBuilder

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

InsertBuilder builds INSERT queries

func NewInsert

func NewInsert(session ConnectionInterface, table interface{}) *InsertBuilder

NewInsert creates a new INSERT builder

func (*InsertBuilder) Exec

func (b *InsertBuilder) Exec(ctx context.Context) (sql.Result, error)

Exec executes the INSERT and returns the result

func (*InsertBuilder) One

func (b *InsertBuilder) One(ctx context.Context, dest interface{}) error

One executes the INSERT with RETURNING and scans into dest

func (*InsertBuilder) Returning

func (b *InsertBuilder) Returning(columns ...string) *InsertBuilder

Returning specifies which columns to return

func (*InsertBuilder) Set

func (b *InsertBuilder) Set(column string, value interface{}) *InsertBuilder

Set sets a specific column value

func (*InsertBuilder) ToSQL

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

ToSQL generates the SQL query and arguments

func (*InsertBuilder) Values

func (b *InsertBuilder) Values(data interface{}) *InsertBuilder

Values adds values to insert (can be called multiple times for batch insert)

type JoinClause

type JoinClause struct {
	Type      string // "INNER", "LEFT", "RIGHT", "FULL"
	Table     interface{}
	Condition expr.Expr
}

JoinClause represents a JOIN operation

type OrderByClause

type OrderByClause struct {
	Column    string
	Direction string // "ASC" or "DESC"
}

OrderByClause represents an ORDER BY clause

type SelectBuilder

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

SelectBuilder builds SELECT queries

func NewSelect

func NewSelect(session ConnectionInterface, table interface{}) *SelectBuilder

NewSelect creates a new SELECT builder

func (*SelectBuilder) All

func (b *SelectBuilder) All(ctx context.Context, dest interface{}) error

All executes the query and returns all results

func (*SelectBuilder) Count

func (b *SelectBuilder) Count(ctx context.Context) (int64, error)

Count returns the count of matching rows

func (*SelectBuilder) Distinct

func (b *SelectBuilder) Distinct() *SelectBuilder

Distinct enables DISTINCT

func (*SelectBuilder) GroupBy

func (b *SelectBuilder) GroupBy(columns ...string) *SelectBuilder

GroupBy adds a GROUP BY clause

func (*SelectBuilder) Having

func (b *SelectBuilder) Having(condition expr.Expr) *SelectBuilder

Having adds a HAVING condition

func (*SelectBuilder) Join

func (b *SelectBuilder) Join(table interface{}, condition expr.Expr) *SelectBuilder

Join adds an INNER JOIN

func (*SelectBuilder) LeftJoin

func (b *SelectBuilder) LeftJoin(table interface{}, condition expr.Expr) *SelectBuilder

LeftJoin adds a LEFT JOIN

func (*SelectBuilder) Limit

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

Limit sets the LIMIT

func (*SelectBuilder) Offset

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

Offset sets the OFFSET

func (*SelectBuilder) One

func (b *SelectBuilder) One(ctx context.Context, dest interface{}) error

One executes the query and returns a single result

func (*SelectBuilder) OrderBy

func (b *SelectBuilder) OrderBy(column string) *SelectBuilder

OrderBy adds an ORDER BY clause (default ASC)

func (*SelectBuilder) OrderByDesc

func (b *SelectBuilder) OrderByDesc(column string) *SelectBuilder

OrderByDesc adds an ORDER BY DESC clause

func (*SelectBuilder) RightJoin

func (b *SelectBuilder) RightJoin(table interface{}, condition expr.Expr) *SelectBuilder

RightJoin adds a RIGHT JOIN

func (*SelectBuilder) Select

func (b *SelectBuilder) Select(columns ...string) *SelectBuilder

Select specifies which columns to select (defaults to all)

func (*SelectBuilder) ToSQL

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

ToSQL generates the SQL query and arguments

func (*SelectBuilder) Where

func (b *SelectBuilder) Where(condition expr.Expr) *SelectBuilder

Where adds a WHERE condition

type UpdateBuilder

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

UpdateBuilder builds UPDATE queries

func NewUpdate

func NewUpdate(session ConnectionInterface, table interface{}) *UpdateBuilder

NewUpdate creates a new UPDATE builder

func (*UpdateBuilder) Exec

func (b *UpdateBuilder) Exec(ctx context.Context) (sql.Result, error)

Exec executes the UPDATE and returns the result

func (*UpdateBuilder) One

func (b *UpdateBuilder) One(ctx context.Context, dest interface{}) error

One executes the UPDATE with RETURNING and scans into dest

func (*UpdateBuilder) Returning

func (b *UpdateBuilder) Returning(columns ...string) *UpdateBuilder

Returning specifies which columns to return

func (*UpdateBuilder) Set

func (b *UpdateBuilder) Set(column string, value interface{}) *UpdateBuilder

Set sets a column value

func (*UpdateBuilder) ToSQL

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

ToSQL generates the SQL query and arguments

func (*UpdateBuilder) Where

func (b *UpdateBuilder) Where(condition expr.Expr) *UpdateBuilder

Where adds a WHERE condition

Jump to

Keyboard shortcuts

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