Documentation
¶
Overview ¶
Package database provides cross-database query building utilities
Package database provides performance tracking for database operations
Index ¶
- Constants
- func GetSupportedDatabaseTypes() []string
- func ValidateDatabaseType(dbType string) error
- type Interface
- type QueryBuilder
- func (qb *QueryBuilder) BuildBooleanValue(value bool) interface{}
- func (qb *QueryBuilder) BuildCaseInsensitiveLike(column, value string) squirrel.Sqlizer
- func (qb *QueryBuilder) BuildCurrentTimestamp() string
- func (qb *QueryBuilder) BuildLimitOffset(query squirrel.SelectBuilder, limit, offset int) squirrel.SelectBuilder
- func (qb *QueryBuilder) BuildUUIDGeneration() string
- func (qb *QueryBuilder) BuildUpsert(table string, conflictColumns []string, ...) (query string, args []interface{}, err error)
- func (qb *QueryBuilder) Delete(table string) squirrel.DeleteBuilder
- func (qb *QueryBuilder) EscapeIdentifier(identifier string) string
- func (qb *QueryBuilder) Insert(table string) squirrel.InsertBuilder
- func (qb *QueryBuilder) Select(columns ...string) squirrel.SelectBuilder
- func (qb *QueryBuilder) Update(table string) squirrel.UpdateBuilder
- func (qb *QueryBuilder) Vendor() string
- type TrackedDB
- func (db *TrackedDB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (db *TrackedDB) PrepareContext(ctx context.Context, query string) (*TrackedStmt, error)
- func (db *TrackedDB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (db *TrackedDB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- type TrackedStmt
- type TrackedTx
- func (tx *TrackedTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (tx *TrackedTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (tx *TrackedTx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
Constants ¶
const ( PostgreSQL = "postgresql" Oracle = "oracle" )
Database type constants
Variables ¶
This section is empty.
Functions ¶
func GetSupportedDatabaseTypes ¶
func GetSupportedDatabaseTypes() []string
GetSupportedDatabaseTypes returns a list of supported database types
func ValidateDatabaseType ¶
ValidateDatabaseType checks if the database type is supported
Types ¶
type Interface ¶
Interface defines the common database operations supported by the framework
func NewConnection ¶
NewConnection creates a new database connection based on the configuration
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder provides vendor-specific SQL query building
func NewQueryBuilder ¶
func NewQueryBuilder(vendor string) *QueryBuilder
NewQueryBuilder creates a new query builder for the specified database vendor
func (*QueryBuilder) BuildBooleanValue ¶
func (qb *QueryBuilder) BuildBooleanValue(value bool) interface{}
BuildBooleanValue converts Go boolean to vendor-specific boolean representation
func (*QueryBuilder) BuildCaseInsensitiveLike ¶
func (qb *QueryBuilder) BuildCaseInsensitiveLike(column, value string) squirrel.Sqlizer
BuildCaseInsensitiveLike creates a case-insensitive LIKE condition based on vendor
func (*QueryBuilder) BuildCurrentTimestamp ¶
func (qb *QueryBuilder) BuildCurrentTimestamp() string
BuildCurrentTimestamp returns the current timestamp function for the vendor
func (*QueryBuilder) BuildLimitOffset ¶
func (qb *QueryBuilder) BuildLimitOffset(query squirrel.SelectBuilder, limit, offset int) squirrel.SelectBuilder
BuildLimitOffset creates LIMIT/OFFSET clause based on vendor
func (*QueryBuilder) BuildUUIDGeneration ¶
func (qb *QueryBuilder) BuildUUIDGeneration() string
BuildUUIDGeneration returns the UUID generation function for the vendor
func (*QueryBuilder) BuildUpsert ¶
func (qb *QueryBuilder) BuildUpsert(table string, conflictColumns []string, insertColumns, updateColumns map[string]interface{}) (query string, args []interface{}, err error)
BuildUpsert creates an UPSERT/MERGE query based on vendor
func (*QueryBuilder) Delete ¶
func (qb *QueryBuilder) Delete(table string) squirrel.DeleteBuilder
Delete creates a new DELETE query builder
func (*QueryBuilder) EscapeIdentifier ¶
func (qb *QueryBuilder) EscapeIdentifier(identifier string) string
EscapeIdentifier escapes database identifiers (table names, column names) for the vendor
func (*QueryBuilder) Insert ¶
func (qb *QueryBuilder) Insert(table string) squirrel.InsertBuilder
Insert creates a new INSERT query builder
func (*QueryBuilder) Select ¶
func (qb *QueryBuilder) Select(columns ...string) squirrel.SelectBuilder
Select creates a new SELECT query builder
func (*QueryBuilder) Update ¶
func (qb *QueryBuilder) Update(table string) squirrel.UpdateBuilder
Update creates a new UPDATE query builder
func (*QueryBuilder) Vendor ¶
func (qb *QueryBuilder) Vendor() string
Vendor returns the database vendor
type TrackedDB ¶
TrackedDB wraps sql.DB to provide request-scoped performance tracking
func NewTrackedDB ¶
NewTrackedDB creates a new tracked database connection
func (*TrackedDB) ExecContext ¶
func (db *TrackedDB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext executes a query without returning rows and tracks performance
func (*TrackedDB) PrepareContext ¶
PrepareContext prepares a statement with context and tracks performance
type TrackedStmt ¶
TrackedStmt wraps sql.Stmt to provide performance tracking for prepared statements
func (*TrackedStmt) ExecContext ¶
ExecContext executes a prepared statement with context and tracks performance
func (*TrackedStmt) QueryContext ¶
QueryContext executes a prepared query with context and tracks performance
func (*TrackedStmt) QueryRowContext ¶
func (s *TrackedStmt) QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row
QueryRowContext executes a prepared single row query with context and tracks performance
type TrackedTx ¶
TrackedTx wraps sql.Tx to provide performance tracking for transactions
func (*TrackedTx) ExecContext ¶
func (tx *TrackedTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext executes a query within a transaction and tracks performance