sqlbuilder

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuoteIdent

func QuoteIdent(dialect string, parts ...string) string

QuoteIdent quotes identifier parts for the given dialect. PostgreSQL/SQLite: "schema"."table" MySQL: `schema`.`table`

Types

type Builder

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

Builder constructs parameterized SQL queries.

func New

func New(dialect string) *Builder

New creates a Builder for the given dialect.

func (*Builder) And

func (b *Builder) And(condition string, args ...any) *Builder

And adds an AND clause.

func (*Builder) Build

func (b *Builder) Build() (string, []any)

Build returns the assembled SQL string and collected arguments.

func (*Builder) Columns

func (b *Builder) Columns(cols ...string) *Builder

Columns adds a parenthesized column list.

func (*Builder) Delete

func (b *Builder) Delete(table string) *Builder

Delete starts a DELETE FROM statement.

func (*Builder) From

func (b *Builder) From(table string) *Builder

From adds a FROM clause.

func (*Builder) GroupBy

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

GroupBy adds a GROUP BY clause.

func (*Builder) Having

func (b *Builder) Having(condition string, args ...any) *Builder

Having adds a HAVING clause.

func (*Builder) Insert

func (b *Builder) Insert(table string) *Builder

Insert starts an INSERT INTO statement.

func (*Builder) Join

func (b *Builder) Join(joinType, table, condition string) *Builder

Join adds a JOIN clause. joinType is e.g. "INNER", "LEFT", "RIGHT".

func (*Builder) Limit

func (b *Builder) Limit(n int) *Builder

Limit adds a LIMIT clause.

func (*Builder) Offset

func (b *Builder) Offset(n int) *Builder

Offset adds an OFFSET clause.

func (*Builder) Or

func (b *Builder) Or(condition string, args ...any) *Builder

Or adds an OR clause.

func (*Builder) OrderBy

func (b *Builder) OrderBy(clause string) *Builder

OrderBy adds an ORDER BY clause.

func (*Builder) Placeholder

func (b *Builder) Placeholder() string

Placeholder returns the next placeholder token and advances the counter.

func (*Builder) Returning

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

Returning adds a RETURNING clause.

func (*Builder) Select

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

Select starts a SELECT statement.

func (*Builder) Set

func (b *Builder) Set(column string, value any) *Builder

Set adds a SET assignment.

func (*Builder) Update

func (b *Builder) Update(table string) *Builder

Update starts an UPDATE statement.

func (*Builder) Values

func (b *Builder) Values(vals ...any) *Builder

Values adds a VALUES clause with placeholders for each value.

func (*Builder) Where

func (b *Builder) Where(condition string, args ...any) *Builder

Where adds a WHERE clause. Occurrences of "?" in condition are rewritten to dialect-specific placeholders.

Jump to

Keyboard shortcuts

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