builder

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package builder provides cross-database query building utilities. This package implements vendor-specific SQL generation and identifier handling for PostgreSQL, Oracle, and other database backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryBuilder

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

QueryBuilder provides vendor-specific SQL query building. It wraps squirrel.StatementBuilderType with database-specific customizations for placeholder formats, identifier quoting, and function generation.

func NewQueryBuilder

func NewQueryBuilder(vendor string) *QueryBuilder

NewQueryBuilder creates a new query builder for the specified database vendor. NewQueryBuilder creates a vendor-aware QueryBuilder configured with the appropriate placeholder format and other vendor-specific settings for SQL generation. For PostgreSQL it configures Dollar-style placeholders; for Oracle it configures Colon-style placeholders; other SQL vendors use question-mark placeholders. It panics if called with the MongoDB vendor because this builder supports SQL only.

func (*QueryBuilder) BuildBooleanValue

func (qb *QueryBuilder) BuildBooleanValue(value bool) any

BuildBooleanValue converts a Go boolean to the appropriate database representation

func (*QueryBuilder) BuildCaseInsensitiveLike

func (qb *QueryBuilder) BuildCaseInsensitiveLike(column, value string) squirrel.Sqlizer

BuildCaseInsensitiveLike creates a case-insensitive LIKE expression. The implementation varies by database vendor.

func (*QueryBuilder) BuildCurrentTimestamp

func (qb *QueryBuilder) BuildCurrentTimestamp() string

BuildCurrentTimestamp returns the current timestamp function for the database vendor

func (*QueryBuilder) BuildLimitOffset

func (qb *QueryBuilder) BuildLimitOffset(query squirrel.SelectBuilder, limit, offset int) squirrel.SelectBuilder

BuildLimitOffset applies LIMIT and OFFSET to a SELECT query using vendor-specific syntax. Different databases have different pagination mechanisms.

func (*QueryBuilder) BuildUUIDGeneration

func (qb *QueryBuilder) BuildUUIDGeneration() string

BuildUUIDGeneration returns the UUID generation function for the database vendor

func (*QueryBuilder) BuildUpsert

func (qb *QueryBuilder) BuildUpsert(table string, conflictColumns []string, insertColumns, updateColumns map[string]any) (query string, args []any, err error)

BuildUpsert creates an UPSERT/MERGE query using Oracle's MERGE statement. Oracle uses MERGE INTO ... USING ... ON ... WHEN MATCHED ... WHEN NOT MATCHED syntax.

func (*QueryBuilder) Delete

func (qb *QueryBuilder) Delete(table string) squirrel.DeleteBuilder

Delete creates a DELETE query builder for the specified table

func (*QueryBuilder) EscapeIdentifier

func (qb *QueryBuilder) EscapeIdentifier(identifier string) string

EscapeIdentifier escapes a database identifier (table/column name) according to vendor rules

func (*QueryBuilder) Insert

func (qb *QueryBuilder) Insert(table string) squirrel.InsertBuilder

Insert creates an INSERT query builder for the specified table

func (*QueryBuilder) InsertWithColumns

func (qb *QueryBuilder) InsertWithColumns(table string, columns ...string) squirrel.InsertBuilder

InsertWithColumns creates an INSERT query builder with pre-specified columns. It applies vendor-specific column quoting to the provided column list.

func (*QueryBuilder) Select

func (qb *QueryBuilder) Select(columns ...string) squirrel.SelectBuilder

Select creates a SELECT query builder with vendor-specific column quoting. For Oracle, it applies identifier quoting to handle reserved words appropriately.

func (*QueryBuilder) Update

func (qb *QueryBuilder) Update(table string) squirrel.UpdateBuilder

Update creates an UPDATE query builder for the specified table

func (*QueryBuilder) Vendor

func (qb *QueryBuilder) Vendor() string

Vendor returns the database vendor string

Jump to

Keyboard shortcuts

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