Documentation
¶
Index ¶
- type Column
- type Context
- type ContextOptions
- type DryRunContext
- func (drc *DryRunContext) Dialect() string
- func (drc *DryRunContext) Exec(query string, args ...any) (sql.Result, error)
- func (drc *DryRunContext) GetCapturedSQL() []string
- func (drc *DryRunContext) GetPendingQueries() []QueryWithArgs
- func (drc *DryRunContext) GetPendingQuery() (string, []any)
- func (drc *DryRunContext) HasPendingQuery() bool
- func (drc *DryRunContext) Query(query string, args ...any) (Rows, error)
- func (drc *DryRunContext) QueryRow(query string, args ...any) Row
- type DryRunContextOptions
- type Index
- type MockResult
- type MockRow
- type MockRows
- type QueryWithArgs
- type RegularContext
- type Row
- type Rows
- type TableInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct {
Name string // Name is the name of the column.
TypeName string // TypeName is the name of the column type (e.g., "VARCHAR", "INT").
TypeFull string // TypeFull is the full type name including any modifiers (e.g., "VARCHAR(255)", "INT(11)").
Collation sql.NullString // Collation is the collation of the column, if applicable.
Nullable bool // Nullable indicates whether the column can contain NULL values.
DefaultVal sql.NullString // DefaultVal is the default value for the column, if any.
Comment sql.NullString // Comment is an optional comment for the column.
Extra sql.NullString // Extra contains additional information about the column (e.g., "auto_increment").
}
Column represents a database column with its properties.
type Context ¶
type Context interface {
Exec(query string, args ...any) (sql.Result, error)
Query(query string, args ...any) (Rows, error)
QueryRow(query string, args ...any) Row
Dialect() string
}
Context interface defines the contract for database operations.
func NewContext ¶
type ContextOptions ¶
type ContextOptions func(*RegularContext)
func WithDialect ¶
func WithDialect(dialect string) ContextOptions
func WithFilename ¶
func WithFilename(filename string) ContextOptions
type DryRunContext ¶
type DryRunContext struct {
// contains filtered or unexported fields
}
DryRunContext implements Context for dry-run mode (captures SQL without executing).
func NewDryRunContext ¶
func NewDryRunContext(ctx context.Context, opts ...DryRunContextOptions) *DryRunContext
func (*DryRunContext) Dialect ¶
func (drc *DryRunContext) Dialect() string
func (*DryRunContext) GetCapturedSQL ¶
func (drc *DryRunContext) GetCapturedSQL() []string
func (*DryRunContext) GetPendingQueries ¶
func (drc *DryRunContext) GetPendingQueries() []QueryWithArgs
func (*DryRunContext) GetPendingQuery ¶
func (drc *DryRunContext) GetPendingQuery() (string, []any)
func (*DryRunContext) HasPendingQuery ¶
func (drc *DryRunContext) HasPendingQuery() bool
type DryRunContextOptions ¶
type DryRunContextOptions func(*DryRunContext)
DryRunContextOptions is a function type for configuring DryRunContext.
func WithDryRunDialect ¶
func WithDryRunDialect(dialect string) DryRunContextOptions
type Index ¶
type Index struct {
Name string // Name is the name of the index.
Columns []string // Columns is a slice of column names that are part of the index.
Type string // e.g., "btree", "hash"
Unique bool // Indicates if the index is unique
Primary bool // Indicates if the index is a primary key
}
Index represents a database index with its properties.
type MockResult ¶
MockResult implements sql.Result for dry-run mode.
func (*MockResult) LastInsertId ¶
func (m *MockResult) LastInsertId() (int64, error)
func (*MockResult) RowsAffected ¶
func (m *MockResult) RowsAffected() (int64, error)
type MockRows ¶
type MockRows struct {
Closed bool
}
MockRows implements basic sql.Rows functionality for dry-run mode.
type QueryWithArgs ¶
QueryWithArgs stores a query and its arguments.
type RegularContext ¶
type RegularContext struct {
// contains filtered or unexported fields
}
RegularContext implements Context for normal database operations.
func (*RegularContext) Dialect ¶
func (c *RegularContext) Dialect() string
type Rows ¶
type Rows interface {
Next() bool
Scan(dest ...any) error
Close() error
Err() error
Columns() ([]string, error)
}
Rows interface defines the methods required for database rows.
type TableInfo ¶
type TableInfo struct {
Name string // Name is the name of the table.
Schema string // Schema is the schema where the table resides.
Size int64 // Size is the size of the table in bytes.
Comment sql.NullString // Comment is an optional comment for the table.
Engine sql.NullString // Engine is the storage engine used for the table (e.g., "InnoDB", "MyISAM").
Collation sql.NullString // Collation is the collation used for the table (e.g., "utf8mb4_general_ci").
}
TableInfo represents information about a database table.