Documentation ¶
Index ¶
- Constants
- Variables
- func ExecuteFunction(name string, args ...any) (any, error)
- func WithAlterTableAddColumn(column *Column) func(*AlterTable)
- func WithAlterTableAddIndex(index *Index) func(*AlterTable)
- func WithAlterTableDropColumn(column *Column) func(*AlterTable)
- func WithAlterTableRenameColumn(from *Column, to *Column) func(*AlterTable)
- func WithAlterTableRenameTo(tbl *Table) func(*AlterTable)
- func WithAlterTableSchema(name string) func(*AlterTable)
- func WithColumnArguments(args []any) func(*Column)
- func WithColumnConstant(c ColumnConstraint) func(*Column)
- func WithColumnData(data *DataDef) func(*Column)
- func WithColumnFunction(fn FunctionExecutor) func(*Column)
- func WithColumnLiteral(l *Literal) func(*Column)
- func WithColumnName(name string) func(*Column)
- func WithCopyColumns(columns ...*Column) func(*Copy)
- func WithCopyFormat(fmt string) func(*Copy)
- func WithDeleteCondition(cond *Condition) func(*Delete)
- func WithLiteralType(t LiteralType) func(*Literal)
- func WithSchemaColumns(columns ColumnList) func(*Schema)
- func WithSchemaIndexes(idxes IndexList) func(*Schema)
- func WithSelectGroupBy(name string) func(*Select)
- func WithSelectLimit(offset int, limit int) func(*Select)
- func WithSelectOrderBy(orderBy *OrderBy) func(*Select)
- func WithTableSchema(schema string) func(*Table)
- type AggregateFunc
- type AggregateFunction
- type AggregateResultSet
- type AlterDatabase
- type AlterTable
- func (stmt *AlterTable) AddColumn() (*Column, bool)
- func (stmt *AlterTable) AddIndex() (*Index, bool)
- func (stmt *AlterTable) DropColumn() (*Column, bool)
- func (stmt *AlterTable) RenameColumns() (*Column, *Column, bool)
- func (stmt *AlterTable) RenameTable() (*Table, bool)
- func (stmt *AlterTable) StatementType() StatementType
- func (stmt *AlterTable) String() string
- type AlterTableOption
- type AndExpr
- type Argument
- type ArgumentList
- type ArithFunc
- type ArithFunction
- func NewAddFunction(name string) *ArithFunction
- func NewArithFunctionWith(name string, fn ArithFunc) *ArithFunction
- func NewDivFunction(name string) *ArithFunction
- func NewModFunction(name string) *ArithFunction
- func NewMulFunction(name string) *ArithFunction
- func NewSubFunction(name string) *ArithFunction
- type Begin
- type BindParam
- type BindParams
- type CastFunc
- type CastFunction
- type CmpExpr
- func NewCmpExprWith(op CmpExprOperator, left *Column, right *Literal) *CmpExpr
- func NewEQWith(left *Column, right *Literal) *CmpExpr
- func NewGEWith(left *Column, right *Literal) *CmpExpr
- func NewGTWith(left *Column, right *Literal) *CmpExpr
- func NewLEWith(left *Column, right *Literal) *CmpExpr
- func NewLTWith(left *Column, right *Literal) *CmpExpr
- func NewNEQWith(left *Column, right *Literal) *CmpExpr
- type CmpExprOperator
- type Column
- func (col *Column) Arguments() []any
- func (col *Column) Constrains() ColumnConstraint
- func (col *Column) Copy() *Column
- func (col *Column) DefinitionString() string
- func (col *Column) ExecuteUpdator(row map[string]any) (any, error)
- func (col *Column) Executor() FunctionExecutor
- func (col *Column) IsName(name string) bool
- func (col *Column) Name() string
- func (col *Column) SelectorString() string
- func (col *Column) SetConstant(c ColumnConstraint)
- func (col *Column) SetDef(dataDef *DataDef) error
- func (col *Column) SetValue(v any) error
- func (col *Column) String() string
- func (col *Column) UpdatorString() string
- type ColumnConstraint
- type ColumnList
- func (columns ColumnList) ColumnAt(n int) (*Column, error)
- func (columns ColumnList) ColumnByName(name string) (*Column, error)
- func (columns ColumnList) Columns() ColumnList
- func (columns ColumnList) Copy() ColumnList
- func (columns ColumnList) DefinitionString() string
- func (columns ColumnList) IndexOfColumnByName(name string) (int, error)
- func (columns ColumnList) IsSelectAll() bool
- func (columns ColumnList) Len() int
- func (columns ColumnList) NameString() string
- func (columns ColumnList) Names() []string
- func (columns ColumnList) Selectors() SelectorList
- func (columns ColumnList) SetSchema(schema *Schema) error
- func (columns ColumnList) ValueString() string
- type ColumnOption
- type Commit
- type Condition
- type Copy
- type CopyFormat
- type CopyOption
- type CreateDatabase
- type CreateIndex
- type CreateTable
- type DataDef
- type DataType
- type Database
- type Delete
- type DeleteOption
- type DropDatabase
- type DropIndex
- type DropTable
- type Expr
- type Function
- type FunctionExecutor
- type FunctionType
- type GroupBy
- type IfExistsOpt
- type IfNotExistsOpt
- type Index
- type IndexList
- type IndexType
- type Insert
- type Limit
- type Literal
- type LiteralOption
- type LiteralType
- type MathFunc
- type MathFunction
- type MathResultSet
- type OrExpr
- type Order
- type OrderBy
- type OrderType
- type Rollback
- type Schema
- type SchemaOption
- type Select
- type SelectOption
- type Selector
- type SelectorList
- func (selectors SelectorList) AggregateFunctions() ([]FunctionExecutor, error)
- func (selectors SelectorList) Columns() []*Column
- func (selectors SelectorList) FunctionByName(name string) (*Function, error)
- func (selectors SelectorList) FunctionExecutorByName(name string) (FunctionExecutor, error)
- func (selectors SelectorList) FunctionExecutors() ([]FunctionExecutor, error)
- func (selectors SelectorList) FunctionExecutorsWithType(t FunctionType) ([]FunctionExecutor, error)
- func (selectors SelectorList) Functions() []*Function
- func (selectors SelectorList) HasAggregateFunction() bool
- func (selectors SelectorList) HasFunction() bool
- func (selectors SelectorList) HasFunctionWithType(t FunctionType) bool
- func (selectors SelectorList) IsSelectAll() bool
- func (selectors SelectorList) Len() int
- func (selectors SelectorList) SelectorString() string
- func (selectors SelectorList) Selectors() SelectorList
- type Statement
- type StatementList
- type StatementType
- type Table
- type TableList
- type TableOption
- type Truncate
- type Update
- type Vacuum
Constants ¶
const ( UnknownData = iota BigIntData BinaryData BitData BlobData BooleanData CharData CharacterData ClobData DateData DecimalData DoubleData DoublePrecision FloatData IntData IntegerData LongBlobData LongTextData MediumBlobData MediumIntData MediumTextData NumericData RealData SetData SmallIntData TextData TimeData TimeStampData TinyBlobData TinyIntData TinyTextData VarBinaryData VarCharData VarCharacterData YearData )
const ( // Math. AbsFunctionName = "ABS" CeilFunctionName = "CEIL" FloorFunctionName = "FLOOR" // Aggregator. MaxFunctionName = "MAX" MinFunctionName = "MIN" SumFunctionName = "SUM" AvgFunctionName = "AVG" CountFunctionName = "COUNT" )
const ( UnknownLiteral = iota StringLiteral )
const ( CreateDatabaseStatement = iota CreateTableStatement CreateIndexStatement InsertStatement SelectStatement UpdateStatement DeleteStatement DropDatabaseStatement DropTableStatement DropIndexStatement AlterDatabaseStatement AlterTableStatement AlterIndexStatement CopyStatement CommitStatement VacuumStatement TruncateStatement BeginStatement RollbackStatement )
const (
// Asterisk is a asterisk string.
Asterisk = "*"
)
const GroupByNone = ""
GroupByNone represents an empty ORDER BY clause.
const TableNameSep = "."
TableNameSep represents a table name separator.
Variables ¶
var ErrInvalid = errors.New("invalid")
ErrInvalid is returned when the value is invalid.
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when the data type is invalid.
var ErrNotSupported = errors.New("not supported")
ErrNotSupported is returned when the function is not supported.
var NullLiteral = NewLiteralWith(nil)
NullLiteral represents a null value.
Functions ¶
func ExecuteFunction ¶ added in v1.1.1
ExecuteFunction returns the executed value with the specified arguments.
func WithAlterTableAddColumn ¶ added in v0.9.2
func WithAlterTableAddColumn(column *Column) func(*AlterTable)
WithAlterTableAddColumn sets an add column.
func WithAlterTableAddIndex ¶ added in v1.2.6
func WithAlterTableAddIndex(index *Index) func(*AlterTable)
WithAlterTableAddIndex sets an add index.
func WithAlterTableDropColumn ¶ added in v0.9.2
func WithAlterTableDropColumn(column *Column) func(*AlterTable)
WithAlterTableDropColumn sets a drop column.
func WithAlterTableRenameColumn ¶ added in v0.9.2
func WithAlterTableRenameColumn(from *Column, to *Column) func(*AlterTable)
WithAlterTableRenameColumn sets a rename column.
func WithAlterTableRenameTo ¶ added in v0.9.2
func WithAlterTableRenameTo(tbl *Table) func(*AlterTable)
WithAlterTableRenameTo sets a rename table.
func WithAlterTableSchema ¶ added in v0.9.2
func WithAlterTableSchema(name string) func(*AlterTable)
WithAlterTableSchema sets a schema.
func WithColumnArguments ¶ added in v1.2.3
WithColumnArguments sets column arguments.
func WithColumnConstant ¶ added in v1.1.0
func WithColumnConstant(c ColumnConstraint) func(*Column)
func WithColumnData ¶ added in v0.9.1
WithColumnData sets a column data.
func WithColumnFunction ¶ added in v1.2.3
func WithColumnFunction(fn FunctionExecutor) func(*Column)
WithColumnFunction sets a column function.
func WithColumnLiteral ¶ added in v0.9.1
WithColumnLiteral sets a column data.
func WithColumnName ¶ added in v0.9.1
WithColumnName sets a column name.
func WithCopyColumns ¶ added in v1.2.4
WithCopyColumns returns a copy option to set the columns.
func WithCopyFormat ¶ added in v1.2.4
WithCopyFormat returns a copy option to set the format.
func WithDeleteCondition ¶ added in v1.2.2
func WithLiteralType ¶ added in v0.9.1
func WithLiteralType(t LiteralType) func(*Literal)
WithSchemaColumns returns a schema option to set the columns.
func WithSchemaColumns ¶ added in v0.9.1
func WithSchemaColumns(columns ColumnList) func(*Schema)
WithSchemaColumns returns a schema option to set the columns.
func WithSchemaIndexes ¶ added in v0.9.1
WithSchemaIndexes returns a schema option to set the indexes.
func WithSelectGroupBy ¶ added in v1.1.1
WithSelectOrderBy sets order by options.
func WithSelectLimit ¶ added in v1.0.0
WithSelectLimit sets order by options.
func WithSelectOrderBy ¶ added in v1.0.0
WithSelectOrderBy sets order by options.
func WithTableSchema ¶ added in v1.2.4
WithTableSchema sets a table schema.
Types ¶
type AggregateFunc ¶ added in v1.1.1
AggregateFunc represents an aggregator function.
type AggregateFunction ¶ added in v1.1.1
type AggregateFunction struct {
// contains filtered or unexported fields
}
AggregateFunction represents a base aggregator function.
func NewAggregateFunctionWith ¶ added in v1.1.1
func NewAggregateFunctionWith(name string, fn AggregateFunc) *AggregateFunction
NewAggregateFunctionWith returns a new base aggregator function with the specified name and aggregator.
func NewAvgFunction ¶ added in v1.1.1
func NewAvgFunction() *AggregateFunction
NewAvgFunction returns a new avg function.
func NewCountFunction ¶ added in v1.1.1
func NewCountFunction() *AggregateFunction
NewCountFunction returns a new count function.
func NewMaxFunction ¶ added in v1.1.1
func NewMaxFunction() *AggregateFunction
NewMaxFunction returns a new max function.
func NewMinFunction ¶ added in v1.1.1
func NewMinFunction() *AggregateFunction
NewMinFunction returns a new min function.
func NewSumFunction ¶ added in v1.1.1
func NewSumFunction() *AggregateFunction
NewSumFunction returns a new sum function.
func (*AggregateFunction) Execute ¶ added in v1.1.1
func (fn *AggregateFunction) Execute(args ...any) (any, error)
Execute returns the executed value with the specified arguments.
func (*AggregateFunction) Name ¶ added in v1.1.1
func (fn *AggregateFunction) Name() string
Name returns the name of the function.
func (*AggregateFunction) ResultSet ¶ added in v1.1.1
func (fn *AggregateFunction) ResultSet() AggregateResultSet
Aggregate returns the latest aggregated value.
func (*AggregateFunction) Type ¶ added in v1.1.1
func (fn *AggregateFunction) Type() FunctionType
Type returns the type of the function.
type AggregateResultSet ¶ added in v1.1.1
AggregateResultSet represents a result set of an aggregator function.
type AlterDatabase ¶
type AlterDatabase struct { *Database // contains filtered or unexported fields }
AlterDatabase is a "ALTER DATABASE" statement.
func NewAlterDatabaseWith ¶
func NewAlterDatabaseWith(name string, to string) *AlterDatabase
NewAlterDatabaseWith returns a new AlterDatabase statement instance with the specified options.
func (*AlterDatabase) RenameTo ¶ added in v0.9.2
func (stmt *AlterDatabase) RenameTo() *Database
RenameTo returns the "TO" database.
func (*AlterDatabase) StatementType ¶
func (stmt *AlterDatabase) StatementType() StatementType
StatementType returns the statement type.
func (*AlterDatabase) String ¶
func (stmt *AlterDatabase) String() string
String returns the statement string representation.
type AlterTable ¶
AlterTable is a "ALTER TABLE" statement.
func NewAlterTableWith ¶
func NewAlterTableWith(tblName string, opts ...AlterTableOption) *AlterTable
NewAlterTableWith returns a new AlterTable statement instance with the specified options.
func (*AlterTable) AddColumn ¶ added in v1.2.5
func (stmt *AlterTable) AddColumn() (*Column, bool)
AddColumn returns the add column.
func (*AlterTable) AddIndex ¶ added in v1.2.6
func (stmt *AlterTable) AddIndex() (*Index, bool)
AddIndex returns the add index.
func (*AlterTable) DropColumn ¶ added in v1.2.5
func (stmt *AlterTable) DropColumn() (*Column, bool)
DropColumn returns the drop column.
func (*AlterTable) RenameColumns ¶ added in v1.2.5
func (stmt *AlterTable) RenameColumns() (*Column, *Column, bool)
RenameColumns returns the rename columns.
func (*AlterTable) RenameTable ¶ added in v0.9.2
func (stmt *AlterTable) RenameTable() (*Table, bool)
RenameTable returns the rename table.
func (*AlterTable) StatementType ¶
func (stmt *AlterTable) StatementType() StatementType
StatementType returns the statement type.
func (*AlterTable) String ¶
func (stmt *AlterTable) String() string
String returns the statement string representation.
type AlterTableOption ¶ added in v0.9.2
type AlterTableOption = func(*AlterTable)
AlterTableOption represents an alter table option function.
type Argument ¶ added in v1.1.0
type Argument string
Argument represents am argument in a function.
func NewArgumentWith ¶ added in v1.1.0
NewArgument returns a new argument instance from the specified string.
func (Argument) IsAsterisk ¶ added in v1.1.1
IsAsterisk returns true whether the argument name is the asterisk.
func (Argument) IsName ¶ added in v1.1.1
IsName returns true whether the argument name is the specified one.
type ArgumentList ¶ added in v1.1.0
type ArgumentList []Argument
ArgumentList represens an argument array in a function.
func NewArguments ¶ added in v1.1.0
func NewArguments() ArgumentList
NewArguments returns an empty argument array instance.
func NewArgumentsWith ¶ added in v1.1.0
func NewArgumentsWith(args ...Argument) ArgumentList
NewArgumentsWith returns an argument array instance with the specified arguments.
func (ArgumentList) Arguments ¶ added in v1.1.0
func (arguments ArgumentList) Arguments() ArgumentList
Argument returns an argument array.
func (ArgumentList) String ¶ added in v1.1.0
func (arguments ArgumentList) String() string
String returns a string representation of the the argument list.
type ArithFunction ¶ added in v1.2.3
type ArithFunction struct {
// contains filtered or unexported fields
}
ArithFunction represents a base arithmetic function.
func NewAddFunction ¶ added in v1.2.3
func NewAddFunction(name string) *ArithFunction
NewAddFunction returns a new add function.
func NewArithFunctionWith ¶ added in v1.2.3
func NewArithFunctionWith(name string, fn ArithFunc) *ArithFunction
NewArithFunctionWith returns a new base arithmetic function with the specified name and arithmetic.
func NewDivFunction ¶ added in v1.2.3
func NewDivFunction(name string) *ArithFunction
NewDivFunction returns a new division function.
func NewModFunction ¶ added in v1.2.3
func NewModFunction(name string) *ArithFunction
NewModFunction returns a new mod function.
func NewMulFunction ¶ added in v1.2.3
func NewMulFunction(name string) *ArithFunction
NewMulFunction returns a new multiple function.
func NewSubFunction ¶ added in v1.2.3
func NewSubFunction(name string) *ArithFunction
NewSubFunction returns a new sub function.
func (*ArithFunction) Execute ¶ added in v1.2.3
func (fn *ArithFunction) Execute(args ...any) (any, error)
Execute returns the executed value with the specified arguments.
func (*ArithFunction) Name ¶ added in v1.2.3
func (fn *ArithFunction) Name() string
Name returns the name of the function.
func (*ArithFunction) Type ¶ added in v1.2.3
func (fn *ArithFunction) Type() FunctionType
Type returns the type of the function.
type Begin ¶ added in v1.2.0
type Begin struct { }
Begin represents a begin statement.
func (*Begin) StatementType ¶ added in v1.2.0
func (stmt *Begin) StatementType() StatementType
StatementType returns the statement type.
type BindParam ¶ added in v0.9.1
type BindParam struct {
// contains filtered or unexported fields
}
BindParam represents a bind param.
func NewBindParamWith ¶ added in v0.9.1
NewBindParam returns a bind param instance.
type BindParams ¶ added in v0.9.1
type BindParams []*BindParam
BindParams represens a bind param array.
func NewBindParams ¶ added in v0.9.1
func NewBindParams() BindParams
NewBindParams returns a bind param array instance.
type CastFunction ¶ added in v1.1.1
type CastFunction struct {
// contains filtered or unexported fields
}
CastFunction represents a base cast function.
func NewCastFunctionWith ¶ added in v1.1.1
func NewCastFunctionWith(name string, cast CastFunc) *CastFunction
NewCastFunctionWith returns a new base cast function with the specified name and cast.
func (*CastFunction) Execute ¶ added in v1.1.1
func (fn *CastFunction) Execute(args ...any) (any, error)
Execute returns the executed value with the specified arguments.
func (*CastFunction) Name ¶ added in v1.1.1
func (fn *CastFunction) Name() string
Name returns the name of the function.
func (*CastFunction) Type ¶ added in v1.1.1
func (fn *CastFunction) Type() FunctionType
Type returns the type of the function.
type CmpExpr ¶ added in v0.9.1
type CmpExpr struct {
// contains filtered or unexported fields
}
CmpExpr represents an comparison expression.
func NewCmpExprWith ¶ added in v1.2.4
func NewCmpExprWith(op CmpExprOperator, left *Column, right *Literal) *CmpExpr
NewCmpExprWith returns a new CompExpr instance with the specified parameters.
func NewEQWith ¶ added in v1.2.4
NewEQ returns a new CompExpr instance with the specified parameters.
func NewGEWith ¶ added in v1.2.4
NewGE returns a new CompExpr instance with the specified parameters.
func NewGTWith ¶ added in v1.2.4
NewGT returns a new CompExpr instance with the specified parameters.
func NewLEWith ¶ added in v1.2.4
NewLE returns a new CompExpr instance with the specified parameters.
func NewLTWith ¶ added in v1.2.4
NewLT returns a new CompExpr instance with the specified parameters.
func NewNEQWith ¶ added in v1.2.4
NewNEQ returns a new CompExpr instance with the specified parameters.
func (*CmpExpr) Operator ¶ added in v0.9.1
func (expr *CmpExpr) Operator() CmpExprOperator
Operator returns the operator.
type CmpExprOperator ¶ added in v0.9.1
type CmpExprOperator uint8
CmpExprOperator is an enum for CompExpr.Operator.
const ( EQ CmpExprOperator = iota NEQ LT GT LE GE IN NIN )
Constants for Enum Type - CompExprOperator.
func (CmpExprOperator) String ¶ added in v0.9.1
func (t CmpExprOperator) String() string
String returns the string representation.
type Column ¶
type Column struct { *DataDef *Literal *BindParam FunctionExecutor // contains filtered or unexported fields }
Column represents a column.
func NewColumnWithName ¶
NewColumn returns a column instance.
func NewColumnWithOptions ¶ added in v0.9.1
func NewColumnWithOptions(opts ...ColumnOption) *Column
NewColumn returns a column instance.
func (*Column) Constrains ¶ added in v1.1.0
func (col *Column) Constrains() ColumnConstraint
Constrains returns the column constrains.
func (*Column) DefinitionString ¶ added in v1.1.0
DefinitionString returns the definition string representation.
func (*Column) ExecuteUpdator ¶ added in v1.2.3
ExecuteUpdator executes the executor with the specified row.
func (*Column) Executor ¶ added in v1.2.3
func (col *Column) Executor() FunctionExecutor
Executor returns the executor.
func (*Column) IsName ¶ added in v0.9.1
IsName returns true whether the column name is the specified one.
func (*Column) SelectorString ¶ added in v1.1.0
SelectorString returns the selector string representation.
func (*Column) SetConstant ¶ added in v1.1.0
func (col *Column) SetConstant(c ColumnConstraint)
SetConstant sets a constant.
func (*Column) SetDef ¶ added in v0.9.1
SetDef sets the column definition to update the column value.
func (*Column) UpdatorString ¶ added in v1.2.3
UpdatorString returns the updator string representation.
type ColumnConstraint ¶ added in v1.1.0
type ColumnConstraint int
ColumnConstraint represents a column constraint.
const ( // ColumnConstraintNone represents no constraint. ColumnConstraintNone ColumnConstraint = 0x00 ColumnConstraintPrimaryKey ColumnConstraint = 0x01 ColumnConstraintNotNull ColumnConstraint = 0x02 ColumnConstraintUnique ColumnConstraint = 0x04 )
func (ColumnConstraint) IsPrimaryKey ¶ added in v1.1.0
func (c ColumnConstraint) IsPrimaryKey() bool
IsPrimaryKey returns true whether the column is a primary key.
func (ColumnConstraint) String ¶ added in v1.1.0
func (c ColumnConstraint) String() string
String returns the string representation.
type ColumnList ¶ added in v0.9.1
type ColumnList []*Column
ColumnList represens a column array.
func NewColumnsWith ¶
func NewColumnsWith(columns ...*Column) ColumnList
NewColumnsWith returns a column array instance with the specified columns.
func (ColumnList) ColumnAt ¶ added in v0.9.2
func (columns ColumnList) ColumnAt(n int) (*Column, error)
ColumnAt returns a column by the specified index.
func (ColumnList) ColumnByName ¶ added in v0.9.1
func (columns ColumnList) ColumnByName(name string) (*Column, error)
ColumnByName returns a column by the specified name.
func (ColumnList) Columns ¶ added in v0.9.1
func (columns ColumnList) Columns() ColumnList
Column returns a column array.
func (ColumnList) Copy ¶ added in v0.9.2
func (columns ColumnList) Copy() ColumnList
Copy returns a copy of the column list.
func (ColumnList) DefinitionString ¶ added in v1.1.0
func (columns ColumnList) DefinitionString() string
DefinitionString returns a string representation of the the column definitions.
func (ColumnList) IndexOfColumnByName ¶ added in v1.2.5
func (columns ColumnList) IndexOfColumnByName(name string) (int, error)
IndexOfColumnByName returns a column index by the specified name.
func (ColumnList) IsSelectAll ¶ added in v0.9.1
func (columns ColumnList) IsSelectAll() bool
IsSelectAll returns true if the column list is "*".
func (ColumnList) Len ¶ added in v1.2.5
func (columns ColumnList) Len() int
Len returns the length of the column array.
func (ColumnList) NameString ¶ added in v0.9.1
func (columns ColumnList) NameString() string
NameString returns a string representation of the the column names.
func (ColumnList) Names ¶ added in v0.9.1
func (columns ColumnList) Names() []string
Names returns a column name array.
func (ColumnList) Selectors ¶ added in v1.1.0
func (columns ColumnList) Selectors() SelectorList
Selectors returns a selector array.
func (ColumnList) SetSchema ¶ added in v0.9.1
func (columns ColumnList) SetSchema(schema *Schema) error
SetSchema sets a schema to update column values.
func (ColumnList) ValueString ¶ added in v0.9.1
func (columns ColumnList) ValueString() string
ValueString returns a string representation of the the column values.
type ColumnOption ¶ added in v0.9.1
type ColumnOption = func(*Column)
ColumnOption represents a column option function.
type Commit ¶ added in v0.9.2
type Commit struct { }
Commit is a "COMMIT" statement.
func NewCommit ¶ added in v0.9.2
func NewCommit() *Commit
NewCommitWith returns a new Commit statement instance with the specified parameters.
func (*Commit) StatementType ¶ added in v0.9.2
func (stmt *Commit) StatementType() StatementType
StatementType returns the statement type.
type Condition ¶ added in v0.9.1
type Condition struct {
// contains filtered or unexported fields
}
Condition represents a where condition.
func NewConditionWith ¶ added in v0.9.1
NewConditionWith returns a new where condition instance with the specified parameters.
type Copy ¶ added in v0.9.2
type Copy struct { *Table ColumnList // contains filtered or unexported fields }
Copy is a "COPY" statement.
func NewCopyWith ¶ added in v0.9.2
func NewCopyWith(tblName string, src string, opts ...CopyOption) *Copy
NewCopyWith returns a new Copy statement instance with the specified parameters.
func (*Copy) Format ¶ added in v1.2.4
func (stmt *Copy) Format() CopyFormat
func (*Copy) StatementType ¶ added in v0.9.2
func (stmt *Copy) StatementType() StatementType
StatementType returns the statement type.
type CopyFormat ¶ added in v1.2.4
type CopyFormat uint8
CopyFormat represents a copy format.
const ( // CopyFormatText represents a text format. CopyFormatText CopyFormat = iota // CopyFormatCSV represents a CSV format. CopyFormatCSV // CopyFormatBinary represents a binary format. CopyFormatBinary )
func (CopyFormat) String ¶ added in v1.2.4
func (fmt CopyFormat) String() string
String returns the string representation of the format.
type CopyOption ¶ added in v1.2.4
type CopyOption = func(*Copy)
CopyOption represents a copy option.
type CreateDatabase ¶
type CreateDatabase struct { *Database *IfNotExistsOpt }
CreateDatabase is a "CREATE DATABASE" statement.
func NewCreateDatabaseWith ¶
func NewCreateDatabaseWith(name string, ifne *IfNotExistsOpt) *CreateDatabase
NewCreateDatabaseWith returns a new CreateDatabase statement instance with the specified options.
func (*CreateDatabase) StatementType ¶
func (stmt *CreateDatabase) StatementType() StatementType
StatementType returns the statement type.
func (*CreateDatabase) String ¶
func (stmt *CreateDatabase) String() string
String returns the statement string representation.
type CreateIndex ¶
type CreateIndex struct { *Schema *IfNotExistsOpt }
CreateIndex is a "CREATE INDEX" statement.
func NewCreateIndexWith ¶
func NewCreateIndexWith(schema *Schema, ifne *IfNotExistsOpt) *CreateIndex
NewCreateIndexWith returns a new CreateIndex statement instance with the specified parameters.
func (*CreateIndex) StatementType ¶
func (stmt *CreateIndex) StatementType() StatementType
StatementType returns the statement type.
func (*CreateIndex) String ¶
func (stmt *CreateIndex) String() string
String returns the statement string representation.
type CreateTable ¶
type CreateTable struct { *IfNotExistsOpt // contains filtered or unexported fields }
CreateTable is a "CREATE TABLE" statement.
func NewCreateTableWith ¶
func NewCreateTableWith(schema *Schema, ifne *IfNotExistsOpt) *CreateTable
NewCreateTableWith returns a new CreateTable statement instance with the specified options.
func (*CreateTable) Schema ¶ added in v0.9.1
func (stmt *CreateTable) Schema() *Schema
Schema returns the schema.
func (*CreateTable) StatementType ¶
func (stmt *CreateTable) StatementType() StatementType
StatementType returns the statement type.
func (*CreateTable) String ¶
func (stmt *CreateTable) String() string
String returns the statement string representation.
func (*CreateTable) TableName ¶ added in v0.9.1
func (stmt *CreateTable) TableName() string
TableName returns the table name.
type DataDef ¶ added in v0.9.1
DataDef represents a data definition.
func NewDataFrom ¶
NewDataFrom returns the data type of the specified string.
func NewDataWith ¶
NewDataWith returns a new DataType instance with the specified type and length.
func (*DataDef) DataLength ¶ added in v0.9.1
DataLength returns the column data length.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents a database.
func NewDatabaseWith ¶
NewDatabaseWith returns a new Database instance with the specified name.
func (*Database) DatabaseName ¶ added in v0.9.1
DatabaseName returns the database name.
type Delete ¶
type Delete struct { *Condition // contains filtered or unexported fields }
Delete is a "DELETE" statement.
func NewDeleteWith ¶
func NewDeleteWith(tbl *Table, opts ...DeleteOption) *Delete
NewDeleteWith returns a new Delete statement instance with the specified parameters.
func (*Delete) StatementType ¶
func (stmt *Delete) StatementType() StatementType
StatementType returns the statement type.
type DeleteOption ¶ added in v1.2.2
type DeleteOption = func(*Delete)
DeleteOption represents a delete option function.
type DropDatabase ¶
type DropDatabase struct { *Database *IfExistsOpt }
DropDatabase is a "DROP DATABASE" statement.
func NewDropDatabaseWith ¶
func NewDropDatabaseWith(name string, ife *IfExistsOpt) *DropDatabase
NewDropDatabaseWith returns a new DropDatabase statement instance with the specified parameters.
func (*DropDatabase) StatementType ¶
func (stmt *DropDatabase) StatementType() StatementType
StatementType returns the statement type.
func (*DropDatabase) String ¶
func (stmt *DropDatabase) String() string
String returns the statement string representation.
type DropIndex ¶
type DropIndex struct { *Index *Schema *IfExistsOpt }
DropIndex is a "DROP INDEX" statement.
func NewDropIndexWith ¶
func NewDropIndexWith(schemaName string, idxName string, ife *IfExistsOpt) *DropIndex
NewDropIndexWith returns a new DropIndex statement instance with the specified parameters.
func (*DropIndex) StatementType ¶
func (stmt *DropIndex) StatementType() StatementType
StatementType returns the statement type.
type DropTable ¶
type DropTable struct { TableList *IfExistsOpt }
DropTable is a "DROP TABLE" statement.
func NewDropTableWith ¶
func NewDropTableWith(tbls TableList, ife *IfExistsOpt) *DropTable
NewDropTableWith returns a new DropTable statement instance with the specified parameters.
func (*DropTable) StatementType ¶
func (stmt *DropTable) StatementType() StatementType
StatementType returns the statement type.
type Expr ¶
type Expr interface { // String returns the index string representation. String() string }
Expr represents an expression.
type Function ¶ added in v1.1.0
type Function struct { ArgumentList // contains filtered or unexported fields }
Function represents a column.
func NewFunctionWith ¶ added in v1.1.0
NewFunctionWith returns a column instance.
func (*Function) Executor ¶ added in v1.1.1
func (fn *Function) Executor() (FunctionExecutor, error)
Executor returns the executor of the function.
func (*Function) IsName ¶ added in v1.1.0
IsName returns true whether the column name is the specified one.
func (*Function) IsSelectAll ¶ added in v1.1.1
IsSelectAll returns true if the argument list is "*".
func (*Function) SelectorString ¶ added in v1.1.0
SelectorString returns the selector string representation.
type FunctionExecutor ¶ added in v1.1.1
type FunctionExecutor interface { // Name returns the name of the function. Name() string // Type returns the type of the function. Type() FunctionType // Execute returns the executed value with the specified arguments. Execute(...any) (any, error) }
FunctionExecutor represents a function executor interface.
func GetFunctionExecutor ¶ added in v1.1.1
func GetFunctionExecutor(name string) (FunctionExecutor, error)
GetFunctionExecutor returns a function executor with the specified name.
type FunctionType ¶ added in v1.1.1
type FunctionType int
FunctionType represents a function type.
const ( MathFunctionType FunctionType = iota AggregateFunctionType CastFunctionType ArithFunctionType )
type GroupBy ¶ added in v1.1.1
type GroupBy struct {
// contains filtered or unexported fields
}
GroupBy represents an ORDER BY clause.
func NewGroupBy ¶ added in v1.1.1
func NewGroupBy() *GroupBy
NewGroupBy returns a new GroupBy instance.
func NewGroupByWith ¶ added in v1.1.1
NewGroupByWith returns a new GroupBy instance with the specified column name.
type IfExistsOpt ¶ added in v0.9.1
type IfExistsOpt struct {
// contains filtered or unexported fields
}
IfExistsOpt represents a IF EXISTS option.
func NewIfExistsWith ¶
func NewIfExistsWith(v bool) *IfExistsOpt
NewIfExistsWith returns a new IfExists option instance.
func (*IfExistsOpt) IfExists ¶ added in v0.9.1
func (opt *IfExistsOpt) IfExists() bool
IfExists returns the IF EXISTS option.
func (*IfExistsOpt) String ¶ added in v0.9.1
func (opt *IfExistsOpt) String() string
String returns the string representation.
type IfNotExistsOpt ¶ added in v0.9.1
type IfNotExistsOpt struct {
// contains filtered or unexported fields
}
IfNotExistsOpt represents a IF NOT EXISTS option.
func NewIfNotExistsWith ¶
func NewIfNotExistsWith(v bool) *IfNotExistsOpt
NewIfNotExistsWith returns a new IfNotExists option instance.
func (*IfNotExistsOpt) IfNotExists ¶ added in v0.9.1
func (opt *IfNotExistsOpt) IfNotExists() bool
IfNotExists returns the IF NOT EXISTS option.
func (*IfNotExistsOpt) String ¶ added in v0.9.1
func (opt *IfNotExistsOpt) String() string
String returns the string representation.
type Index ¶
type Index struct { ColumnList // contains filtered or unexported fields }
Index represents a index.
func NewIndexWith ¶
func NewIndexWith(name string, t IndexType, columns ColumnList) *Index
NewIndexWith returns a new index instance.
func NewPrimaryIndexWith ¶
func NewPrimaryIndexWith(columns ColumnList) *Index
NewPrimaryIndexWith returns a new primary index instance.
func NewSecondaryIndexWith ¶
func NewSecondaryIndexWith(name string, columns ColumnList) *Index
NewSecondaryIndexWith returns a new secondary index instance.
func (*Index) DefinitionString ¶ added in v1.1.0
DefinitionString returns the index definition string representation.
type IndexList ¶ added in v0.9.1
type IndexList []*Index
IndexList represents an index array.
func (IndexList) DefinitionString ¶ added in v1.1.0
DefinitionString returns the index definition string representation.
func (IndexList) IndexByName ¶ added in v1.2.5
IndexByName returns an index by the specified name.
func (IndexList) IndexOfIndexByName ¶ added in v1.2.5
IndexOfIndexByName returns an index index by the specified name.
type Insert ¶
type Insert struct { *Table ColumnList }
Insert is a "INSERT" statement.
func NewInsertWith ¶
func NewInsertWith(tbl *Table, columns ColumnList) *Insert
NewInsertWith returns a new Insert statement instance with the specified parameters.
func (*Insert) StatementType ¶
func (stmt *Insert) StatementType() StatementType
StatementType returns the statement type.
type Limit ¶ added in v1.0.0
type Limit struct {
// contains filtered or unexported fields
}
Limit represents a LIMIT clause.
func NewLimitWith ¶ added in v1.0.0
NewLimitWith returns a new Limit instance with the specified offset and limit.
type Literal ¶
type Literal struct {
// contains filtered or unexported fields
}
Literal represents a constant value.
func NewLiteral ¶ added in v1.2.3
func NewLiteral() *Literal
NewLiteral returns a new Literal instance.
func NewLiteralWith ¶
func NewLiteralWith(v any, opts ...LiteralOption) *Literal
NewLiteralWith returns a new Literal instance with the specified value.
func (*Literal) HasLiteral ¶ added in v1.2.3
HasLiteral returns true whether the literal has a value.
func (*Literal) SetType ¶ added in v0.9.1
func (lit *Literal) SetType(t LiteralType) *Literal
SetType sets a type.
func (*Literal) ValueString ¶ added in v0.9.1
ValueString returns the string representation.
func (*Literal) ValueType ¶ added in v0.9.1
func (lit *Literal) ValueType() LiteralType
ValueType returns the literal type.
type LiteralOption ¶ added in v0.9.1
type LiteralOption = func(*Literal)
LiteralOption represents a literal option function.
type MathFunction ¶ added in v1.1.1
type MathFunction struct {
// contains filtered or unexported fields
}
MathFunction represents a base math function.
func NewAbsFunction ¶ added in v1.1.1
func NewAbsFunction() *MathFunction
NewAbsFunction returns a new abs function.
func NewCeilFunction ¶ added in v1.1.1
func NewCeilFunction() *MathFunction
NewCeilFunction returns a new ceil function.
func NewFloorFunction ¶ added in v1.1.1
func NewFloorFunction() *MathFunction
NewFloorFunction returns a new floor function.
func NewMathFunctionWith ¶ added in v1.1.1
func NewMathFunctionWith(name string, fn MathFunc) *MathFunction
NewMathFunctionWith returns a new base math function with the specified name and math.
func (*MathFunction) Execute ¶ added in v1.1.1
func (fn *MathFunction) Execute(args ...any) (any, error)
Execute returns the executed value with the specified arguments.
func (*MathFunction) Name ¶ added in v1.1.1
func (fn *MathFunction) Name() string
Name returns the name of the function.
func (*MathFunction) Type ¶ added in v1.1.1
func (fn *MathFunction) Type() FunctionType
Type returns the type of the function.
type MathResultSet ¶ added in v1.1.1
MathResultSet represents a result set of an math function.
type Order ¶ added in v1.0.0
type Order struct {
// contains filtered or unexported fields
}
Order represents an ORDER BY clause.
func NewOrderWith ¶ added in v1.1.1
NewOrderWith returns a new order instance with the specified column and order.
type OrderBy ¶ added in v1.0.0
type OrderBy struct {
// contains filtered or unexported fields
}
OrderBy represents an ORDER BY clause.
func NewOrderBy ¶ added in v1.0.0
func NewOrderBy() *OrderBy
NewOrderBy returns a new OrderBy instance.
func NewOrderByWith ¶ added in v1.0.0
NewOrderByWith returns a new OrderBy instance with the specified orders.
type OrderType ¶
type OrderType uint8
OrderType represents an ordertype.
func NewOrderTypeWith ¶ added in v1.2.1
NewOrderTypeWith returns a new OrderType instance.
type Rollback ¶ added in v1.2.0
type Rollback struct { }
Rollback represents a rollback statement.
func NewRollback ¶ added in v1.2.0
func NewRollback() *Rollback
NewRollbackWith returns a new Rollback statement instance with the specified parameters.
func (*Rollback) StatementType ¶ added in v1.2.0
func (stmt *Rollback) StatementType() StatementType
StatementType returns the statement type.
type Schema ¶
type Schema struct { *Table ColumnList IndexList }
Schema represents a table schema.
func NewSchemaWith ¶
func NewSchemaWith(name string, opts ...SchemaOption) *Schema
NewSchemaWith returns a new schema statement instance with the parameters.
func (*Schema) DropColumn ¶ added in v1.2.5
DropColumn drops a column by the specified name.
func (*Schema) SchemaName ¶ added in v0.9.1
SchemaName returns the table name.
func (*Schema) SchemaTable ¶ added in v0.9.2
SchemaTable returns the table.
type SchemaOption ¶ added in v0.9.1
type SchemaOption = func(*Schema)
SchemaOption represents a schema option function.
type Select ¶
type Select struct { TableList SelectorList *Condition // contains filtered or unexported fields }
Select is a "SELECT" statement.
func NewSelectWith ¶
func NewSelectWith(selectors SelectorList, tbls TableList, w *Condition, opts ...SelectOption) *Select
NewSelectWith returns a new Select statement instance with the specified parameters.
func (*Select) StatementType ¶
func (stmt *Select) StatementType() StatementType
StatementType returns the statement type.
type SelectOption ¶ added in v1.0.0
type SelectOption = func(*Select)
SelectOption represents a select option function.
type Selector ¶ added in v1.1.0
type Selector interface { // Name returns the name of the selector. Name() string // SelectorString returns a string representation of the selector. SelectorString() string }
Selector represents a selector in a select query.
type SelectorList ¶ added in v1.1.0
type SelectorList []Selector
SelectorList represens a selector array.
func NewSelectors ¶ added in v1.1.0
func NewSelectors() SelectorList
NewSelectors returns a selector array instance.
func NewSelectorsWith ¶ added in v1.1.0
func NewSelectorsWith(selectors ...Selector) SelectorList
NewSelectorsWith returns a selector array instance with the specified selectors.
func NewSelectorsWithColums ¶ added in v1.1.0
func NewSelectorsWithColums(selectors ...*Column) SelectorList
NewSelectorsWithColums returns a selector array instance with the specified selectors.
func (SelectorList) AggregateFunctions ¶ added in v1.1.1
func (selectors SelectorList) AggregateFunctions() ([]FunctionExecutor, error)
AggregateFunctions returns an aggregate function array.
func (SelectorList) Columns ¶ added in v1.1.1
func (selectors SelectorList) Columns() []*Column
Column returns a column array.
func (SelectorList) FunctionByName ¶ added in v1.1.1
func (selectors SelectorList) FunctionByName(name string) (*Function, error)
FunctionByName returns a function with the specified name.
func (SelectorList) FunctionExecutorByName ¶ added in v1.1.1
func (selectors SelectorList) FunctionExecutorByName(name string) (FunctionExecutor, error)
FunctionExecutorByName returns a function executor with the specified name.
func (SelectorList) FunctionExecutors ¶ added in v1.1.1
func (selectors SelectorList) FunctionExecutors() ([]FunctionExecutor, error)
FunctionExecutors returns a function executor array.
func (SelectorList) FunctionExecutorsWithType ¶ added in v1.1.1
func (selectors SelectorList) FunctionExecutorsWithType(t FunctionType) ([]FunctionExecutor, error)
FunctionExecutorsWithType returns a function executor array with the specified type.
func (SelectorList) Functions ¶ added in v1.1.1
func (selectors SelectorList) Functions() []*Function
Functions returns a function array.
func (SelectorList) HasAggregateFunction ¶ added in v1.1.1
func (selectors SelectorList) HasAggregateFunction() bool
HasAggregateFunction returns true if the selector list has an aggregate function.
func (SelectorList) HasFunction ¶ added in v1.1.1
func (selectors SelectorList) HasFunction() bool
HasFunction returns true if the selector list has a function.
func (SelectorList) HasFunctionWithType ¶ added in v1.1.1
func (selectors SelectorList) HasFunctionWithType(t FunctionType) bool
HasFunctionWithType returns true if the selector list has a function with the specified type.
func (SelectorList) IsSelectAll ¶ added in v1.1.0
func (selectors SelectorList) IsSelectAll() bool
IsSelectAll returns true if the selector list is "*".
func (SelectorList) Len ¶ added in v1.2.5
func (selectors SelectorList) Len() int
Len returns the length of the selector array.
func (SelectorList) SelectorString ¶ added in v1.1.0
func (selectors SelectorList) SelectorString() string
SelectorString returns a string representation of the selector array.
func (SelectorList) Selectors ¶ added in v1.1.0
func (selectors SelectorList) Selectors() SelectorList
Selector returns a selector array.
type Statement ¶
type Statement interface { // StatementType returns the statement type. StatementType() StatementType // String returns the statement string representation. String() string }
Statement represents a statement interface.
type StatementList ¶
type StatementList = []Statement
StatementList represents a statement list.
func NewStatementList ¶
func NewStatementList() StatementList
NewStatementList returns a new statement list.
type StatementType ¶
type StatementType uint8
StatementType is a statement type.
func (StatementType) String ¶ added in v1.2.6
func (stmtType StatementType) String() string
StatementType returns the statement type.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a table.
func NewTableWith ¶
func NewTableWith(name string, opts ...TableOption) *Table
NewTableWith returns a new Table instance with the specified name.
func (*Table) IsSchemaName ¶ added in v1.2.4
IsSchemaName returns true whether the table is named.
func (*Table) IsTableName ¶ added in v1.2.4
IsTableName returns true whether the table is named.
func (*Table) SchemaName ¶ added in v1.2.4
SchemaName returns the table schema name.
type TableList ¶ added in v0.9.1
type TableList []*Table
TableList represens a column array.
func NewTablesWith ¶
NewTablesWith returns a column array instance with the specified columns.
func (TableList) HasSchemaTable ¶ added in v1.2.4
HasSchemaTable returns true whether the table array has the specified table schema.
func (TableList) HasTable ¶ added in v1.2.4
HasTable returns true whether the table array has the specified table name.
func (TableList) HasTableName ¶ added in v1.2.4
HasTableName returns true whether the table array has the specified table name.
type TableOption ¶ added in v1.2.4
type TableOption = func(*Table)
TableOption represents a table option function.
type Truncate ¶ added in v0.9.2
type Truncate struct {
TableList
}
Truncate is a "TRUNCATE" statement.
func NewTruncateWith ¶ added in v0.9.2
NewTruncateWith returns a new truncate statement instance with the specified parameters.
func (*Truncate) StatementType ¶ added in v0.9.2
func (stmt *Truncate) StatementType() StatementType
StatementType returns the statement type.
type Update ¶
type Update struct { ColumnList *Condition // contains filtered or unexported fields }
Update is a "UPDATE" statement.
func NewUpdateWith ¶
func NewUpdateWith(tbl *Table, columns ColumnList, w *Condition) *Update
NewUpdateWith returns a new Update statement instance with the specified parameters.
func (*Update) StatementType ¶
func (stmt *Update) StatementType() StatementType
StatementType returns the statement type.
type Vacuum ¶ added in v0.9.2
type Vacuum struct {
*Table
}
Vacuum is a "VACUUM" statement.
func NewVacuum ¶ added in v0.9.2
func NewVacuum() *Vacuum
NewVacuum returns a new vacuum statement instance.
func NewVacuumWith ¶ added in v0.9.2
NewVacuumWith returns a new vacuum statement instance with the specified parameters.
func (*Vacuum) StatementType ¶ added in v0.9.2
func (stmt *Vacuum) StatementType() StatementType
StatementType returns the statement type.
Source Files ¶
- alter_database.go
- alter_table.go
- argument.go
- arguments.go
- begin.go
- bind.go
- column.go
- column_const.go
- columns.go
- commit.go
- const.go
- copy.go
- create_database.go
- create_index.go
- create_table.go
- data.go
- database.go
- delete.go
- drop_database.go
- drop_index.go
- drop_table.go
- errors.go
- expr.go
- expr_cmp.go
- func.go
- func_aggr.go
- func_arith.go
- func_cast.go
- func_math.go
- funcs.go
- group.go
- index.go
- indexes.go
- insert.go
- limit.go
- literal.go
- options.go
- order.go
- rollback.go
- schema.go
- select.go
- selector.go
- selectors.go
- statement.go
- statement_type.go
- table.go
- tables.go
- truncate.go
- update.go
- vacuum.go
- where.go