Versions in this module Expand all Collapse all v1 v1.0.4 Mar 6, 2025 v1.0.3 Mar 6, 2025 v1.0.2 Nov 12, 2024 v1.0.1 Nov 12, 2024 v1.0.0 Nov 12, 2024 Changes in this version + func SafeQuery(query string, args ...any) chschema.QueryWithArgs + type AfterScanRowHook = chschema.AfterScanRowHook + type ArrayValues struct + func Array(slice any) ArrayValues + func (in ArrayValues) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + type CHModel = chschema.CHModel + type Config struct + Addr string + Cluster string + Compression bool + Database string + DialTimeout time.Duration + MaxRetries int + MaxRetryBackoff time.Duration + MinRetryBackoff time.Duration + Password string + QuerySettings map[string]any + ReadTimeout time.Duration + TLSConfig *tls.Config + User string + WriteTimeout time.Duration + type CreateTableQuery struct + func NewCreateTableQuery(db *DB) *CreateTableQuery + func (q *CreateTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool) + func (q *CreateTableQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + func (q *CreateTableQuery) Apply(fn func(*CreateTableQuery) *CreateTableQuery) *CreateTableQuery + func (q *CreateTableQuery) As(table string) *CreateTableQuery + func (q *CreateTableQuery) ColumnExpr(query string, args ...any) *CreateTableQuery + func (q *CreateTableQuery) DB() *DB + func (q *CreateTableQuery) Engine(query string, args ...any) *CreateTableQuery + func (q *CreateTableQuery) Exec(ctx context.Context) (sql.Result, error) + func (q *CreateTableQuery) GetModel() Model + func (q *CreateTableQuery) GetTableName() string + func (q *CreateTableQuery) IfNotExists() *CreateTableQuery + func (q *CreateTableQuery) Model(model any) *CreateTableQuery + func (q *CreateTableQuery) ModelTable(table string) *CreateTableQuery + func (q *CreateTableQuery) ModelTableExpr(query string, args ...any) *CreateTableQuery + func (q *CreateTableQuery) OnCluster(cluster string) *CreateTableQuery + func (q *CreateTableQuery) Operation() string + func (q *CreateTableQuery) Order(query string, args ...any) *CreateTableQuery + func (q *CreateTableQuery) Partition(query string, args ...any) *CreateTableQuery + func (q *CreateTableQuery) Setting(query string, args ...any) *CreateTableQuery + func (q *CreateTableQuery) TTL(query string, args ...any) *CreateTableQuery + func (q *CreateTableQuery) Table(tables ...string) *CreateTableQuery + func (q *CreateTableQuery) TableExpr(query string, args ...any) *CreateTableQuery + type CreateViewQuery struct + func NewCreateViewQuery(db *DB) *CreateViewQuery + func (q *CreateViewQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool) + func (q *CreateViewQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + func (q *CreateViewQuery) Apply(fn func(*CreateViewQuery) *CreateViewQuery) *CreateViewQuery + func (q *CreateViewQuery) Column(columns ...string) *CreateViewQuery + func (q *CreateViewQuery) ColumnExpr(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) DB() *DB + func (q *CreateViewQuery) ExcludeColumn(columns ...string) *CreateViewQuery + func (q *CreateViewQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error) + func (q *CreateViewQuery) GetModel() Model + func (q *CreateViewQuery) GetTableName() string + func (q *CreateViewQuery) Group(columns ...string) *CreateViewQuery + func (q *CreateViewQuery) GroupExpr(group string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) IfNotExists() *CreateViewQuery + func (q *CreateViewQuery) Materialized() *CreateViewQuery + func (q *CreateViewQuery) Model(model any) *CreateViewQuery + func (q *CreateViewQuery) ModelTableExpr(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) OnCluster(cluster string) *CreateViewQuery + func (q *CreateViewQuery) OnClusterExpr(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) Operation() string + func (q *CreateViewQuery) OrderExpr(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) Setting(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) Table(tables ...string) *CreateViewQuery + func (q *CreateViewQuery) TableExpr(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) To(to string) *CreateViewQuery + func (q *CreateViewQuery) ToExpr(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) View(view string) *CreateViewQuery + func (q *CreateViewQuery) ViewExpr(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) Where(query string, args ...any) *CreateViewQuery + func (q *CreateViewQuery) WhereGroup(sep string, fn func(*CreateViewQuery) *CreateViewQuery) *CreateViewQuery + func (q *CreateViewQuery) WhereOr(query string, args ...any) *CreateViewQuery + type DB struct + func Connect(opts ...Option) *DB + func (db *DB) AddQueryHook(hook QueryHook) + func (db *DB) Close() error + func (db *DB) Config() *Config + func (db *DB) Exec(query string, args ...any) (sql.Result, error) + func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) + func (db *DB) FormatQuery(query string, args ...any) string + func (db *DB) Formatter() chschema.Formatter + func (db *DB) NewCreateTable() *CreateTableQuery + func (db *DB) NewCreateView() *CreateViewQuery + func (db *DB) NewDropTable() *DropTableQuery + func (db *DB) NewDropView() *DropViewQuery + func (db *DB) NewInsert() *InsertQuery + func (db *DB) NewRaw(query string, args ...any) *RawQuery + func (db *DB) NewSelect() *SelectQuery + func (db *DB) NewTruncateTable() *TruncateTableQuery + func (db *DB) Ping(ctx context.Context) error + func (db *DB) Query(query string, args ...any) (*Rows, error) + func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error) + func (db *DB) QueryRow(query string, args ...any) *Row + func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *Row + func (db *DB) ResetModel(ctx context.Context, models ...any) error + func (db *DB) Stats() DBStats + func (db *DB) String() string + func (db *DB) WithFormatter(fmter chschema.Formatter) *DB + func (db *DB) WithTimeout(d time.Duration) *DB + type DBStats struct + Errors uint64 + Queries uint64 + type DropTableQuery struct + func NewDropTableQuery(db *DB) *DropTableQuery + func (q *DropTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool) + func (q *DropTableQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + func (q *DropTableQuery) DB() *DB + func (q *DropTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error) + func (q *DropTableQuery) GetModel() Model + func (q *DropTableQuery) GetTableName() string + func (q *DropTableQuery) IfExists() *DropTableQuery + func (q *DropTableQuery) Model(model any) *DropTableQuery + func (q *DropTableQuery) ModelTableExpr(query string, args ...any) *DropTableQuery + func (q *DropTableQuery) OnCluster(cluster string) *DropTableQuery + func (q *DropTableQuery) Operation() string + func (q *DropTableQuery) Table(tables ...string) *DropTableQuery + func (q *DropTableQuery) TableExpr(query string, args ...any) *DropTableQuery + type DropViewQuery struct + func NewDropViewQuery(db *DB) *DropViewQuery + func (q *DropViewQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool) + func (q *DropViewQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + func (q *DropViewQuery) Apply(fn func(*DropViewQuery) *DropViewQuery) *DropViewQuery + func (q *DropViewQuery) DB() *DB + func (q *DropViewQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error) + func (q *DropViewQuery) GetModel() Model + func (q *DropViewQuery) GetTableName() string + func (q *DropViewQuery) IfExists() *DropViewQuery + func (q *DropViewQuery) Model(model any) *DropViewQuery + func (q *DropViewQuery) OnCluster(cluster string) *DropViewQuery + func (q *DropViewQuery) OnClusterExpr(query string, args ...any) *DropViewQuery + func (q *DropViewQuery) Operation() string + func (q *DropViewQuery) View(view string) *DropViewQuery + func (q *DropViewQuery) ViewExpr(query string, args ...any) *DropViewQuery + type Error struct + Code int32 + Message string + Name string + StackTrace string + func (exc *Error) Error() string + type Ident = chschema.Ident + type InValues struct + func In(slice any) InValues + func (in InValues) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + type InsertQuery struct + func NewInsertQuery(db *DB) *InsertQuery + func (q *InsertQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool) + func (q *InsertQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + func (q *InsertQuery) Column(columns ...string) *InsertQuery + func (q *InsertQuery) ColumnExpr(query string, args ...any) *InsertQuery + func (q *InsertQuery) DB() *DB + func (q *InsertQuery) ExcludeColumn(columns ...string) *InsertQuery + func (q *InsertQuery) Exec(ctx context.Context) (sql.Result, error) + func (q *InsertQuery) GetModel() Model + func (q *InsertQuery) GetTableName() string + func (q *InsertQuery) Model(model any) *InsertQuery + func (q *InsertQuery) ModelTable(table string) *InsertQuery + func (q *InsertQuery) ModelTableExpr(query string, args ...any) *InsertQuery + func (q *InsertQuery) Operation() string + func (q *InsertQuery) Setting(query string, args ...any) *InsertQuery + func (q *InsertQuery) Table(tables ...string) *InsertQuery + func (q *InsertQuery) TableExpr(query string, args ...any) *InsertQuery + func (q *InsertQuery) Where(query string, args ...any) *InsertQuery + func (q *InsertQuery) WhereOr(query string, args ...any) *InsertQuery + type ListValues struct + func List(slice any) ListValues + func (in ListValues) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + type Model = chschema.Model + type Name = chschema.Name + type Option func(db *DB) + func WithAddr(addr string) Option + func WithAutoCreateDatabase(enabled bool) Option + func WithCluster(cluster string) Option + func WithCompression(enabled bool) Option + func WithConnMaxIdleTime(d time.Duration) Option + func WithConnMaxLifetime(d time.Duration) Option + func WithDSN(dsn string) Option + func WithDatabase(database string) Option + func WithDialTimeout(timeout time.Duration) Option + func WithDiscardUnknownColumns() Option + func WithInsecure(on bool) Option + func WithMaxRetries(maxRetries int) Option + func WithMaxRetryBackoff(backoff time.Duration) Option + func WithMinRetryBackoff(backoff time.Duration) Option + func WithPassword(password string) Option + func WithPoolSize(poolSize int) Option + func WithPoolTimeout(timeout time.Duration) Option + func WithQuerySettings(params map[string]any) Option + func WithReadTimeout(timeout time.Duration) Option + func WithTLSConfig(conf *tls.Config) Option + func WithTimeout(timeout time.Duration) Option + func WithUser(user string) Option + func WithWriteTimeout(timeout time.Duration) Option + type Query = chschema.Query + type QueryEvent struct + DB *DB + Err error + IQuery Query + Model Model + Query string + QueryArgs []any + Result sql.Result + StartTime time.Time + Stash map[any]any + func (e *QueryEvent) Operation() string + type QueryHook interface + AfterQuery func(context.Context, *QueryEvent) + BeforeQuery func(context.Context, *QueryEvent) context.Context + type RawQuery struct + func NewRawQuery(db *DB, query string, args ...any) *RawQuery + func (q *RawQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool) + func (q *RawQuery) AppendQuery(fmter chschema.Formatter, b []byte) ([]byte, error) + func (q *RawQuery) DB() *DB + func (q *RawQuery) GetModel() Model + func (q *RawQuery) GetTableName() string + func (q *RawQuery) Operation() string + func (q *RawQuery) Scan(ctx context.Context, dest ...any) error + func (q *RawQuery) ScanColumns(ctx context.Context, dest ...any) error + type Row struct + func (r *Row) Err() error + func (r *Row) Scan(dest ...any) error + type Rows struct + func (rs *Rows) Close() error + func (rs *Rows) ColumnTypes() ([]*sql.ColumnType, error) + func (rs *Rows) Columns() ([]string, error) + func (rs *Rows) Err() error + func (rs *Rows) Next() bool + func (rs *Rows) NextResultSet() bool + func (rs *Rows) Scan(dest ...any) error + type Safe = chschema.Safe + type SelectQuery struct + func NewSelectQuery(db *DB) *SelectQuery + func (q *SelectQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool) + func (q *SelectQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + func (q *SelectQuery) Apply(fn func(*SelectQuery) *SelectQuery) *SelectQuery + func (q *SelectQuery) Clone() *SelectQuery + func (q *SelectQuery) Column(columns ...string) *SelectQuery + func (q *SelectQuery) ColumnExpr(query string, args ...any) *SelectQuery + func (q *SelectQuery) Count(ctx context.Context) (int, error) + func (q *SelectQuery) DB() *DB + func (q *SelectQuery) Distinct() *SelectQuery + func (q *SelectQuery) DistinctOn(query string, args ...any) *SelectQuery + func (q *SelectQuery) Err(err error) *SelectQuery + func (q *SelectQuery) ExcludeColumn(columns ...string) *SelectQuery + func (q *SelectQuery) Final() *SelectQuery + func (q *SelectQuery) GetModel() Model + func (q *SelectQuery) GetTableName() string + func (q *SelectQuery) Group(columns ...string) *SelectQuery + func (q *SelectQuery) GroupExpr(group string, args ...any) *SelectQuery + func (q *SelectQuery) Having(having string, args ...any) *SelectQuery + func (q *SelectQuery) Join(join string, args ...any) *SelectQuery + func (q *SelectQuery) JoinOn(cond string, args ...any) *SelectQuery + func (q *SelectQuery) JoinOnOr(cond string, args ...any) *SelectQuery + func (q *SelectQuery) Limit(limit int) *SelectQuery + func (q *SelectQuery) Model(model any) *SelectQuery + func (q *SelectQuery) ModelTable(table string) *SelectQuery + func (q *SelectQuery) ModelTableExpr(query string, args ...any) *SelectQuery + func (q *SelectQuery) Offset(offset int) *SelectQuery + func (q *SelectQuery) Operation() string + func (q *SelectQuery) Order(orders ...string) *SelectQuery + func (q *SelectQuery) OrderExpr(order string, args ...any) *SelectQuery + func (q *SelectQuery) Prewhere(query string, args ...any) *SelectQuery + func (q *SelectQuery) PrewhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery + func (q *SelectQuery) PrewhereOr(query string, args ...any) *SelectQuery + func (q *SelectQuery) Sample(query string, args ...any) *SelectQuery + func (q *SelectQuery) Scan(ctx context.Context, values ...any) error + func (q *SelectQuery) ScanAndCount(ctx context.Context, values ...any) (count int, firstErr error) + func (q *SelectQuery) ScanColumns(ctx context.Context, values ...any) error + func (q *SelectQuery) Setting(query string, args ...any) *SelectQuery + func (q *SelectQuery) String() string + func (q *SelectQuery) Table(tables ...string) *SelectQuery + func (q *SelectQuery) TableExpr(query string, args ...any) *SelectQuery + func (q *SelectQuery) Union(other *SelectQuery) *SelectQuery + func (q *SelectQuery) UnionAll(other *SelectQuery) *SelectQuery + func (q *SelectQuery) Where(query string, args ...any) *SelectQuery + func (q *SelectQuery) WhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery + func (q *SelectQuery) WhereOr(query string, args ...any) *SelectQuery + func (q *SelectQuery) With(name string, subq chschema.QueryAppender) *SelectQuery + func (q *SelectQuery) WithAlias(name, query string, args ...any) *SelectQuery + type TableModel interface + Block func(fields []*chschema.Field) *chschema.Block + Table func() *chschema.Table + type TruncateTableQuery struct + func NewTruncateTableQuery(db *DB) *TruncateTableQuery + func (q *TruncateTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool) + func (q *TruncateTableQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error) + func (q *TruncateTableQuery) DB() *DB + func (q *TruncateTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error) + func (q *TruncateTableQuery) GetModel() Model + func (q *TruncateTableQuery) GetTableName() string + func (q *TruncateTableQuery) IfExists() *TruncateTableQuery + func (q *TruncateTableQuery) Model(model any) *TruncateTableQuery + func (q *TruncateTableQuery) Operation() string + func (q *TruncateTableQuery) Table(tables ...string) *TruncateTableQuery + func (q *TruncateTableQuery) TableExpr(query string, args ...any) *TruncateTableQuery