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 ¶
- Variables
- type AllHookFunc
- type AndOrExp
- type BaseBuilder
- type BaseQueryBuilder
- type BetweenExp
- type BuildHookFunc
- type Builder
- type BuilderFunc
- type ConnectFunc
- type DB
- type EncloseExp
- type Errors
- type ExecHookFunc
- type ExecLogFunc
- type Executor
- type ExistsExp
- type Exp
- type Expression
- type FieldMapFunc
- type HashExp
- type InExp
- type JoinInfo
- type LikeExp
- type LogFunc
- type ModelQuery
- type MssqlBuilder
- type MssqlQueryBuilder
- type MysqlBuilder
- type NotExp
- type NullStringMap
- type OciBuilder
- type OciQueryBuilder
- type OneHookFunc
- type Params
- type PerfFunc
- type PgsqlBuilder
- type Pool
- type PoolConfig
- type PoolManager
- type PoolStats
- type PostScanner
- type Query
- type QueryBuilder
- type QueryInfo
- type QueryLogFunc
- type Rows
- type SelectQuery
- type SqliteBuilder
- type SqliteQueryBuilder
- type StandardBuilder
- type SyncOptions
- type TableMapFunc
- type TableModel
- type Tx
- type UnionInfo
- type VarTypeError
Constants ¶
This section is empty.
Variables ¶
var ( MissingPKError = dbx.MissingPKError CompositePKError = dbx.CompositePKError )
Sentinel errors from dbx.
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 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 BuildHookFunc ¶
type BuildHookFunc = dbx.BuildHookFunc
BuildHookFunc runs once while a SelectQuery is being built.
type BuilderFunc ¶
type BuilderFunc = dbx.BuilderFunc
BuilderFunc constructs a Builder for a registered driver.
type EncloseExp ¶
type EncloseExp = dbx.EncloseExp
EncloseExp wraps an Expression in parentheses for precedence.
type ExecLogFunc ¶
type ExecLogFunc = dbx.ExecLogFunc
ExecLogFunc is the signature of DB.ExecLogFunc.
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 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 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 PgsqlBuilder ¶
type PgsqlBuilder = dbx.PgsqlBuilder
Concrete driver builders. Most callers should not touch these directly — use Open() / NewFromDB() instead. Re-exported for completeness.
type PoolManager ¶
type PoolManager = dbx.PoolManager
PoolManager is a sharded LRU of Pool instances keyed by path.
type PostScanner ¶
type PostScanner = dbx.PostScanner
PostScanner is implemented by types that want a callback after being scanned from a row.
type QueryBuilder ¶
type QueryBuilder = dbx.QueryBuilder
QueryBuilder is the low-level SQL string builder interface.
type QueryLogFunc ¶
type QueryLogFunc = dbx.QueryLogFunc
QueryLogFunc is the signature of DB.QueryLogFunc.
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 VarTypeError ¶
type VarTypeError = dbx.VarTypeError
VarTypeError reports an unexpected variable type during scan.