Help us shape the future of Go! Take the 2026 Go Developer Survey

statement

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlterTableAddColumnStmt

type AlterTableAddColumnStmt struct {
	TableName        string
	FieldConstraint  *database.FieldConstraint
	TableConstraints database.TableConstraints
}

func (*AlterTableAddColumnStmt) IsReadOnly

func (stmt *AlterTableAddColumnStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*AlterTableAddColumnStmt) Run

func (stmt *AlterTableAddColumnStmt) Run(ctx *Context) (Result, error)

Run runs the ALTER TABLE ADD COLUMN statement in the given transaction. It implements the Statement interface. The statement rebuilds the table.

type AlterTableRenameStmt

type AlterTableRenameStmt struct {
	TableName    string
	NewTableName string
}

AlterTableRenameStmt is a DSL that allows creating a full ALTER TABLE query.

func (AlterTableRenameStmt) IsReadOnly

func (stmt AlterTableRenameStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (AlterTableRenameStmt) Run

func (stmt AlterTableRenameStmt) Run(ctx *Context) (Result, error)

Run runs the ALTER TABLE statement in the given transaction. It implements the Statement interface.

type Context

type Context struct {
	DB     *database.Database
	Tx     *database.Transaction
	Params []environment.Param
}

type CreateIndexStmt

type CreateIndexStmt struct {
	IfNotExists bool
	Info        database.IndexInfo
}

CreateIndexStmt represents a parsed CREATE INDEX statement.

func (*CreateIndexStmt) IsReadOnly

func (stmt *CreateIndexStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*CreateIndexStmt) Run

func (stmt *CreateIndexStmt) Run(ctx *Context) (Result, error)

Run runs the Create index statement in the given transaction. It implements the Statement interface.

type CreateSequenceStmt

type CreateSequenceStmt struct {
	IfNotExists bool
	Info        database.SequenceInfo
}

CreateSequenceStmt represents a parsed CREATE SEQUENCE statement.

func (*CreateSequenceStmt) IsReadOnly

func (stmt *CreateSequenceStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*CreateSequenceStmt) Run

func (stmt *CreateSequenceStmt) Run(ctx *Context) (Result, error)

Run the statement in the given transaction. It implements the Statement interface.

type CreateTableStmt

type CreateTableStmt struct {
	IfNotExists bool
	Info        database.TableInfo
}

CreateTableStmt represents a parsed CREATE TABLE statement.

func (*CreateTableStmt) IsReadOnly

func (stmt *CreateTableStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*CreateTableStmt) Run

func (stmt *CreateTableStmt) Run(ctx *Context) (Result, error)

Run runs the Create table statement in the given transaction. It implements the Statement interface.

type DeleteStmt

type DeleteStmt struct {
	TableName        string
	WhereExpr        expr.Expr
	OffsetExpr       expr.Expr
	OrderBy          expr.Path
	LimitExpr        expr.Expr
	OrderByDirection scanner.Token
	// contains filtered or unexported fields
}

DeleteConfig holds DELETE configuration.

func NewDeleteStatement

func NewDeleteStatement() *DeleteStmt

func (*DeleteStmt) IsReadOnly

func (stmt *DeleteStmt) IsReadOnly() bool

func (*DeleteStmt) Prepare

func (stmt *DeleteStmt) Prepare(c *Context) (Statement, error)

func (*DeleteStmt) Run

func (stmt *DeleteStmt) Run(ctx *Context) (Result, error)

type DropIndexStmt

type DropIndexStmt struct {
	IndexName string
	IfExists  bool
}

DropIndexStmt is a DSL that allows creating a DROP INDEX query.

func (DropIndexStmt) IsReadOnly

func (stmt DropIndexStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (DropIndexStmt) Run

func (stmt DropIndexStmt) Run(ctx *Context) (Result, error)

Run runs the DropIndex statement in the given transaction. It implements the Statement interface.

type DropSequenceStmt

type DropSequenceStmt struct {
	SequenceName string
	IfExists     bool
}

DropSequenceStmt is a DSL that allows creating a DROP INDEX query.

func (DropSequenceStmt) IsReadOnly

func (stmt DropSequenceStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (DropSequenceStmt) Run

func (stmt DropSequenceStmt) Run(ctx *Context) (Result, error)

Run runs the DropSequence statement in the given transaction. It implements the Statement interface.

type DropTableStmt

type DropTableStmt struct {
	TableName string
	IfExists  bool
}

DropTableStmt is a DSL that allows creating a DROP TABLE query.

func (DropTableStmt) IsReadOnly

func (stmt DropTableStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (DropTableStmt) Run

func (stmt DropTableStmt) Run(ctx *Context) (Result, error)

Run runs the DropTable statement in the given transaction. It implements the Statement interface.

type ExplainStmt

type ExplainStmt struct {
	Statement Preparer
}

ExplainStmt is a Statement that displays information about how a statement is going to be executed, without executing it.

func (*ExplainStmt) IsReadOnly

func (s *ExplainStmt) IsReadOnly() bool

IsReadOnly indicates that this statement doesn't write anything into the database.

func (*ExplainStmt) Run

func (stmt *ExplainStmt) Run(ctx *Context) (Result, error)

Run analyses the inner statement and displays its execution plan. If the statement is a stream, Optimize will be called prior to displaying all the operations. Explain currently only works on SELECT, UPDATE, INSERT and DELETE statements.

type InsertStmt

type InsertStmt struct {
	TableName  string
	Values     []expr.Expr
	Fields     []string
	SelectStmt Preparer
	Returning  []expr.Expr
	OnConflict database.OnConflictAction
	// contains filtered or unexported fields
}

InsertStmt holds INSERT configuration.

func NewInsertStatement

func NewInsertStatement() *InsertStmt

func (*InsertStmt) IsReadOnly

func (stmt *InsertStmt) IsReadOnly() bool

func (*InsertStmt) Prepare

func (stmt *InsertStmt) Prepare(c *Context) (Statement, error)

func (*InsertStmt) Run

func (stmt *InsertStmt) Run(ctx *Context) (Result, error)

type PreparedStreamStmt

type PreparedStreamStmt struct {
	Stream   *stream.Stream
	ReadOnly bool
}

PreparedStreamStmt is a PreparedStreamStmt using a Stream.

func (*PreparedStreamStmt) IsReadOnly

func (s *PreparedStreamStmt) IsReadOnly() bool

IsReadOnly reports whether the stream will modify the database or only read it.

func (*PreparedStreamStmt) Run

func (s *PreparedStreamStmt) Run(ctx *Context) (Result, error)

Run returns a result containing the stream. The stream will be executed by calling the Iterate method of the result.

func (*PreparedStreamStmt) String

func (s *PreparedStreamStmt) String() string

type Preparer

type Preparer interface {
	Prepare(*Context) (Statement, error)
}

type ReIndexStmt

type ReIndexStmt struct {
	TableOrIndexName string
	// contains filtered or unexported fields
}

ReIndexStmt is a DSL that allows creating a full REINDEX statement.

func NewReIndexStatement

func NewReIndexStatement() *ReIndexStmt

func (*ReIndexStmt) IsReadOnly

func (stmt *ReIndexStmt) IsReadOnly() bool

func (ReIndexStmt) Prepare

func (stmt ReIndexStmt) Prepare(ctx *Context) (Statement, error)

Prepare implements the Preparer interface.

func (*ReIndexStmt) Run

func (stmt *ReIndexStmt) Run(ctx *Context) (Result, error)

type Result

type Result struct {
	Iterator database.RowIterator
	Tx       *database.Transaction
	// contains filtered or unexported fields
}

Result of a query.

func (*Result) Close

func (r *Result) Close() (err error)

Close the result stream. After closing the result, Stream is not supposed to be used. If the result stream was already closed, it returns an error.

func (*Result) Iterate

func (r *Result) Iterate(fn func(database.Row) error) error

type SelectCoreStmt

type SelectCoreStmt struct {
	TableName       string
	Distinct        bool
	WhereExpr       expr.Expr
	GroupByExpr     expr.Expr
	ProjectionExprs []expr.Expr
}

func (*SelectCoreStmt) Prepare

func (stmt *SelectCoreStmt) Prepare(*Context) (*StreamStmt, error)

type SelectStmt

type SelectStmt struct {
	CompoundSelect    []*SelectCoreStmt
	CompoundOperators []scanner.Token
	OrderBy           expr.Path
	OrderByDirection  scanner.Token
	OffsetExpr        expr.Expr
	LimitExpr         expr.Expr
	// contains filtered or unexported fields
}

SelectStmt holds SELECT configuration.

func NewSelectStatement

func NewSelectStatement() *SelectStmt

func (*SelectStmt) IsReadOnly

func (stmt *SelectStmt) IsReadOnly() bool

func (*SelectStmt) Prepare

func (stmt *SelectStmt) Prepare(ctx *Context) (Statement, error)

Prepare implements the Preparer interface.

func (*SelectStmt) Run

func (stmt *SelectStmt) Run(ctx *Context) (Result, error)

type Statement

type Statement interface {
	Run(*Context) (Result, error)
	IsReadOnly() bool
}

A Statement represents a unique action that can be executed against the database.

type StreamStmt

type StreamStmt struct {
	Stream   *stream.Stream
	ReadOnly bool
}

StreamStmt is a StreamStmt using a Stream.

func (*StreamStmt) Prepare

func (s *StreamStmt) Prepare(ctx *Context) (Statement, error)

Prepare implements the Preparer interface.

type StreamStmtIterator

type StreamStmtIterator struct {
	Stream  *stream.Stream
	Context *Context
}

StreamStmtIterator iterates over a stream.

func (*StreamStmtIterator) Iterate

func (s *StreamStmtIterator) Iterate(fn func(r database.Row) error) error

type UpdateSetPair

type UpdateSetPair struct {
	Path object.Path
	E    expr.Expr
}

type UpdateStmt

type UpdateStmt struct {
	TableName string

	// SetPairs is used along with the Set clause. It holds
	// each path with its corresponding value that
	// should be set in the object.
	SetPairs []UpdateSetPair

	// UnsetFields is used along with the Unset clause. It holds
	// each path that should be unset from the object.
	UnsetFields []string

	WhereExpr expr.Expr
	// contains filtered or unexported fields
}

UpdateConfig holds UPDATE configuration.

func NewUpdateStatement

func NewUpdateStatement() *UpdateStmt

func (*UpdateStmt) IsReadOnly

func (stmt *UpdateStmt) IsReadOnly() bool

func (*UpdateStmt) Prepare

func (stmt *UpdateStmt) Prepare(c *Context) (Statement, error)

Prepare implements the Preparer interface.

func (*UpdateStmt) Run

func (stmt *UpdateStmt) Run(ctx *Context) (Result, error)

Jump to

Keyboard shortcuts

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