builder

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatPlaceholders

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

FormatPlaceholders converts ? placeholders to driver-specific format.

Types

type Builder

type Builder interface {
	// ToSQL generates the SQL query string and arguments
	ToSQL() (string, []interface{}, error)
}

Builder is the interface that all query builders must implement. It provides a method to generate SQL queries with their arguments.

type DeleteBuilder

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

DeleteBuilder builds DELETE queries

func NewDelete

NewDelete creates a new DELETE builder

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

NewInsert creates a new INSERT builder

func (*InsertBuilder) OrIgnore added in v2.0.9

func (b *InsertBuilder) OrIgnore() *InsertBuilder

OrIgnore adds conflict resolution to ignore constraint violations SQL syntax varies by database:

  • SQLite: INSERT OR IGNORE INTO ...
  • MySQL: INSERT IGNORE INTO ...
  • PostgreSQL: INSERT INTO ... ON CONFLICT DO NOTHING

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     table.TableInterface
	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(tbl table.TableInterface) *SelectBuilder

NewSelect creates a new SELECT builder

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(tbl table.TableInterface, condition expr.Expr) *SelectBuilder

Join adds an INNER JOIN

func (*SelectBuilder) LeftJoin

func (b *SelectBuilder) LeftJoin(tbl table.TableInterface, 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) 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(tbl table.TableInterface, 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

NewUpdate creates a new UPDATE builder

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