core

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

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

func NewContext(ctx context.Context, tx *sql.Tx, opts ...ContextOptions) Context

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) Exec

func (drc *DryRunContext) Exec(query string, args ...any) (sql.Result, error)

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

func (*DryRunContext) Query

func (drc *DryRunContext) Query(query string, args ...any) (Rows, error)

func (*DryRunContext) QueryRow

func (drc *DryRunContext) QueryRow(query string, args ...any) Row

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

type MockResult struct {
	LastInsertID      int64
	RowsAffectedValue int64
}

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 MockRow

type MockRow struct{}

MockRow implements Row functionality for dry-run mode.

func (*MockRow) Scan

func (m *MockRow) Scan(_ ...any) error

type MockRows

type MockRows struct {
	Closed bool
}

MockRows implements basic sql.Rows functionality for dry-run mode.

func (*MockRows) Close

func (m *MockRows) Close() error

func (*MockRows) Columns

func (m *MockRows) Columns() ([]string, error)

func (*MockRows) Err

func (m *MockRows) Err() error

func (*MockRows) Next

func (m *MockRows) Next() bool

func (*MockRows) Scan

func (m *MockRows) Scan(_ ...any) error

type QueryWithArgs

type QueryWithArgs struct {
	Query string
	Args  []any
}

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

func (*RegularContext) Exec

func (c *RegularContext) Exec(query string, args ...any) (sql.Result, error)

func (*RegularContext) Query

func (c *RegularContext) Query(query string, args ...any) (Rows, error)

func (*RegularContext) QueryRow

func (c *RegularContext) QueryRow(query string, args ...any) Row

type Row

type Row interface {
	Scan(dest ...any) error
}

Row interface defines the method required for a single database row.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL