sql¶
import "github.com/go-rel/sql"
Overview¶
Constants¶
const DefaultTimeLayout = "2006-01-02 15:04:05"
func ColumnMapper¶
func ColumnMapper(column *rel.Column) (string, int, int)
func ColumnOptionsMapper¶
func ColumnOptionsMapper(column *rel.Column) string
func DropKeyMapper¶
func DropKeyMapper(keyType rel.KeyType) string
func ExtractString¶
func ExtractString(s, left, right string) string
type Cursor¶
type Cursor struct {
*sql.Rows
}
func (*Cursor) Fields¶
func (c *Cursor) Fields() ([]string, error)
func (*Cursor) NopScanner¶
func (c *Cursor) NopScanner() any
type DeleteBuilder¶
type DeleteBuilder interface {
Build(table string, filter rel.FilterQuery) (string, []any)
}
type ErrorMapper¶
type ErrorMapper func(error) error
type IncrementFunc¶
type IncrementFunc func(SQL) int
type IndexBuilder¶
type IndexBuilder interface {
Build(index rel.Index) string
}
type InsertAllBuilder¶
type InsertAllBuilder interface {
Build(table string, primaryField string, fields []string, bulkMutates []map[string]rel.Mutate, onConflict rel.OnConflict) (string, []any)
}
type InsertBuilder¶
type InsertBuilder interface {
Build(table string, primaryField string, mutates map[string]rel.Mutate, onConflict rel.OnConflict) (string, []any)
}
type QueryBuilder¶
type QueryBuilder interface {
Build(query rel.Query) (string, []any)
}
type SQL¶
type SQL struct {
QueryBuilder QueryBuilder
InsertBuilder InsertBuilder
InsertAllBuilder InsertAllBuilder
UpdateBuilder UpdateBuilder
DeleteBuilder DeleteBuilder
TableBuilder TableBuilder
IndexBuilder IndexBuilder
Increment int
IncrementFunc IncrementFunc
ErrorMapper ErrorMapper
DB *sql.DB
Tx *sql.Tx
Savepoint int
Instrumenter rel.Instrumenter
}
func (SQL) Aggregate¶
func (s SQL) Aggregate(ctx context.Context, query rel.Query, mode string, field string) (int, error)
func (SQL) Apply¶
func (s SQL) Apply(ctx context.Context, migration rel.Migration) error
Deprecated: Use Schema Apply instead.
func (SQL) Begin¶
func (s SQL) Begin(ctx context.Context) (rel.Adapter, error)
func (SQL) Close¶
func (s SQL) Close() error
TODO: add closer to adapter interface
func (SQL) Commit¶
func (s SQL) Commit(ctx context.Context) error
func (SQL) Delete¶
func (s SQL) Delete(ctx context.Context, query rel.Query) (int, error)
func (SQL) DoExec¶
func (s SQL) DoExec(ctx context.Context, statement string, args []any) (sql.Result, error)
func (SQL) DoQuery¶
func (s SQL) DoQuery(ctx context.Context, statement string, args []any) (*sql.Rows, error)
func (SQL) Exec¶
func (s SQL) Exec(ctx context.Context, statement string, args []any) (int64, int64, error)
func (SQL) Insert¶
func (s SQL) Insert(ctx context.Context, query rel.Query, primaryField string, mutates map[string]rel.Mutate, onConflict rel.OnConflict) (any, error)
func (SQL) InsertAll¶
func (s SQL) InsertAll(ctx context.Context, query rel.Query, primaryField string, fields []string, bulkMutates []map[string]rel.Mutate, onConflict rel.OnConflict) ([]any, error)
func (*SQL) Instrumentation¶
func (s *SQL) Instrumentation(instrumenter rel.Instrumenter)
func (SQL) Name¶
func (s SQL) Name() string
func (SQL) Ping¶
func (s SQL) Ping(ctx context.Context) error
func (SQL) Query¶
func (s SQL) Query(ctx context.Context, query rel.Query) (rel.Cursor, error)
func (SQL) Rollback¶
func (s SQL) Rollback(ctx context.Context) error
func (SQL) SchemaApply¶
func (s SQL) SchemaApply(ctx context.Context, migration rel.Migration) error
func (SQL) Update¶
func (s SQL) Update(ctx context.Context, query rel.Query, primaryField string, mutates map[string]rel.Mutate) (int, error)
type TableBuilder¶
type TableBuilder interface {
Build(table rel.Table) string
}
type UpdateBuilder¶
type UpdateBuilder interface {
Build(table string, primaryField string, mutates map[string]rel.Mutate, filter rel.FilterQuery) (string, []any)
}
Last update: 2024-12-19