query

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package query re-exports the SQL AST primitives from hanzoai/dbx under the canonical orm namespace. Consumers of hanzoai/orm should import "github.com/hanzoai/orm/query" and never import hanzoai/dbx directly.

All re-exports are identity type aliases (type X = dbx.X) and thin var bindings to dbx package functions. Values produced by this package are bit-identical to values produced by dbx and pass through any boundary without conversion. This makes incremental migration safe: a caller can flip an import from dbx to orm/query without changing behavior or breaking neighboring code that still uses dbx directly.

See hanzoai/orm for the higher-level Typed[T] generic wrapper that sits on top of this package for type-safe result binding.

Index

Constants

This section is empty.

Variables

View Source
var (
	MissingPKError   = dbx.MissingPKError
	CompositePKError = dbx.CompositePKError
)

Sentinel errors from dbx.

View Source
var (
	// NewExp builds a raw SQL expression with a named-params map.
	NewExp = dbx.NewExp

	// Not negates an Expression.
	Not = dbx.Not

	// And conjoins Expressions.
	And = dbx.And

	// Or disjoins Expressions.
	Or = dbx.Or

	// In builds a `col IN (...)` clause.
	In = dbx.In

	// NotIn builds a `col NOT IN (...)` clause.
	NotIn = dbx.NotIn

	// Like builds a `col LIKE ...` clause.
	Like = dbx.Like

	// NotLike builds a `col NOT LIKE ...` clause.
	NotLike = dbx.NotLike

	// OrLike builds an OR chain of LIKE clauses.
	OrLike = dbx.OrLike

	// OrNotLike builds an OR chain of NOT LIKE clauses.
	OrNotLike = dbx.OrNotLike

	// Exists builds an `EXISTS (...)` clause.
	Exists = dbx.Exists

	// NotExists builds a `NOT EXISTS (...)` clause.
	NotExists = dbx.NotExists

	// Between builds a `col BETWEEN from AND to` clause.
	Between = dbx.Between

	// NotBetween builds a `col NOT BETWEEN from AND to` clause.
	NotBetween = dbx.NotBetween

	// Enclose wraps an Expression in parentheses for precedence.
	Enclose = dbx.Enclose

	// NewFromDB wraps an existing *sql.DB with the given driver name.
	NewFromDB = dbx.NewFromDB

	// Open opens a new database connection.
	Open = dbx.Open

	// MustOpen is like Open but panics on error.
	MustOpen = dbx.MustOpen

	// NewQuery builds a raw Query with a SQL string.
	NewQuery = dbx.NewQuery

	// NewSelectQuery builds an empty SelectQuery.
	NewSelectQuery = dbx.NewSelectQuery

	// NewModelQuery builds a struct-aware ModelQuery.
	NewModelQuery = dbx.NewModelQuery

	// NewPoolManager constructs a sharded PoolManager.
	NewPoolManager = dbx.NewPoolManager

	// DefaultSQLiteConnect is the default single-file SQLite connector
	// used by PoolManager.
	DefaultSQLiteConnect = dbx.DefaultSQLiteConnect

	// DefaultFieldMapFunc converts CamelCase struct fields to snake_case.
	DefaultFieldMapFunc = dbx.DefaultFieldMapFunc

	// GetTableName returns the default table name for a struct.
	GetTableName = dbx.GetTableName

	// Driver-specific builder constructors.
	NewBaseBuilder      = dbx.NewBaseBuilder
	NewBaseQueryBuilder = dbx.NewBaseQueryBuilder
	NewStandardBuilder  = dbx.NewStandardBuilder
	NewSqliteBuilder    = dbx.NewSqliteBuilder
	NewMysqlBuilder     = dbx.NewMysqlBuilder
	NewPgsqlBuilder     = dbx.NewPgsqlBuilder
	NewMssqlBuilder     = dbx.NewMssqlBuilder
	NewOciBuilder       = dbx.NewOciBuilder

	// BuilderFuncMap is the driver-name → Builder registry.
	// Callers may extend this map to register new drivers.
	BuilderFuncMap = dbx.BuilderFuncMap

	// DefaultLikeEscape is the LIKE escape map used when no explicit
	// escape is provided to Like / NotLike.
	DefaultLikeEscape = dbx.DefaultLikeEscape
)

Package-level constructors and variadic helpers. These are function-value re-exports so callers can write query.NewExp(...) and never touch hanzoai/dbx directly.

Functions

This section is empty.

Types

type AllHookFunc

type AllHookFunc = dbx.AllHookFunc

AllHookFunc wraps a Query.All() call.

type AndOrExp

type AndOrExp = dbx.AndOrExp

AndOrExp is a conjunction or disjunction of Expressions.

type BaseBuilder

type BaseBuilder = dbx.BaseBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type BaseQueryBuilder

type BaseQueryBuilder = dbx.BaseQueryBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type BetweenExp

type BetweenExp = dbx.BetweenExp

BetweenExp is the BETWEEN / NOT BETWEEN clause.

type BuildHookFunc

type BuildHookFunc = dbx.BuildHookFunc

BuildHookFunc runs once while a SelectQuery is being built.

type Builder

type Builder = dbx.Builder

Builder is the SQL dialect builder interface.

type BuilderFunc

type BuilderFunc = dbx.BuilderFunc

BuilderFunc constructs a Builder for a registered driver.

type ConnectFunc

type ConnectFunc = dbx.ConnectFunc

ConnectFunc is the pool's per-path connector.

type DB

type DB = dbx.DB

DB is a database handle. See dbx.DB for method set.

type EncloseExp

type EncloseExp = dbx.EncloseExp

EncloseExp wraps an Expression in parentheses for precedence.

type Errors

type Errors = dbx.Errors

Errors is a slice of errors returned from batch operations.

type ExecHookFunc

type ExecHookFunc = dbx.ExecHookFunc

ExecHookFunc wraps a Query.Execute() call.

type ExecLogFunc

type ExecLogFunc = dbx.ExecLogFunc

ExecLogFunc is the signature of DB.ExecLogFunc.

type Executor

type Executor = dbx.Executor

Executor is the low-level sql.DB/sql.Tx execution interface.

type ExistsExp

type ExistsExp = dbx.ExistsExp

ExistsExp is the EXISTS / NOT EXISTS clause.

type Exp

type Exp = dbx.Exp

Exp is a raw SQL fragment with params.

type Expression

type Expression = dbx.Expression

Expression is the root interface every WHERE clause implements.

type FieldMapFunc

type FieldMapFunc = dbx.FieldMapFunc

FieldMapFunc maps a struct field name to a column name.

type HashExp

type HashExp = dbx.HashExp

HashExp is the column=>value map sugar for equality AND-clauses.

type InExp

type InExp = dbx.InExp

InExp is the IN / NOT IN clause.

type JoinInfo

type JoinInfo = dbx.JoinInfo

JoinInfo describes a single JOIN clause.

type LikeExp

type LikeExp = dbx.LikeExp

LikeExp is the LIKE / NOT LIKE / OrLike / OrNotLike clause.

type LogFunc

type LogFunc = dbx.LogFunc

LogFunc is the signature of DB.LogFunc.

type ModelQuery

type ModelQuery = dbx.ModelQuery

ModelQuery is the struct-aware Insert / Update / Delete builder.

type MssqlBuilder

type MssqlBuilder = dbx.MssqlBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type MssqlQueryBuilder

type MssqlQueryBuilder = dbx.MssqlQueryBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type MysqlBuilder

type MysqlBuilder = dbx.MysqlBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type NotExp

type NotExp = dbx.NotExp

NotExp is the negation of an Expression.

type NullStringMap

type NullStringMap = dbx.NullStringMap

NullStringMap is a map of sql.NullString values, handy for scanning sparse result rows.

type OciBuilder

type OciBuilder = dbx.OciBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type OciQueryBuilder

type OciQueryBuilder = dbx.OciQueryBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type OneHookFunc

type OneHookFunc = dbx.OneHookFunc

OneHookFunc wraps a Query.One() call.

type Params

type Params = dbx.Params

Params is the named parameter map used with NewExp / queries.

type PerfFunc

type PerfFunc = dbx.PerfFunc

PerfFunc is the deprecated signature of DB.PerfFunc.

type PgsqlBuilder

type PgsqlBuilder = dbx.PgsqlBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type Pool

type Pool = dbx.Pool

Pool is a single pooled DB handle.

type PoolConfig

type PoolConfig = dbx.PoolConfig

PoolConfig configures PoolManager.

type PoolManager

type PoolManager = dbx.PoolManager

PoolManager is a sharded LRU of Pool instances keyed by path.

type PoolStats

type PoolStats = dbx.PoolStats

PoolStats is a snapshot of PoolManager counters.

type PostScanner

type PostScanner = dbx.PostScanner

PostScanner is implemented by types that want a callback after being scanned from a row.

type Query

type Query = dbx.Query

Query is a prepared SQL query with bound parameters.

type QueryBuilder

type QueryBuilder = dbx.QueryBuilder

QueryBuilder is the low-level SQL string builder interface.

type QueryInfo

type QueryInfo = dbx.QueryInfo

QueryInfo captures a query's metadata for hooks and logging.

type QueryLogFunc

type QueryLogFunc = dbx.QueryLogFunc

QueryLogFunc is the signature of DB.QueryLogFunc.

type Rows

type Rows = dbx.Rows

Rows wraps sql.Rows for struct scanning.

type SelectQuery

type SelectQuery = dbx.SelectQuery

SelectQuery is a fluent SELECT builder. This is the primary surface returned from DB.Select() / RecordQuery() style APIs.

type SqliteBuilder

type SqliteBuilder = dbx.SqliteBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type SqliteQueryBuilder

type SqliteQueryBuilder = dbx.SqliteQueryBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type StandardBuilder

type StandardBuilder = dbx.StandardBuilder

Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.

type SyncOptions

type SyncOptions = dbx.SyncOptions

SyncOptions configures DB.SyncWith() schema migration.

type TableMapFunc

type TableMapFunc = dbx.TableMapFunc

TableMapFunc maps a sample struct value to a table name.

type TableModel

type TableModel = dbx.TableModel

TableModel is implemented by models with a custom TableName.

type Tx

type Tx = dbx.Tx

Tx is a transaction handle. See dbx.Tx for method set.

type UnionInfo

type UnionInfo = dbx.UnionInfo

UnionInfo describes a single UNION clause.

type VarTypeError

type VarTypeError = dbx.VarTypeError

VarTypeError reports an unexpected variable type during scan.

Jump to

Keyboard shortcuts

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