Documentation
¶
Index ¶
- Constants
- Variables
- func ExecuteFunction(name string, args ...any) (any, error)
- func NewAlterDatabaseWith(name string, to string) *alterDatabaseStmt
- func NewBegin() *beginStmt
- func NewBindParamWith(name string) *bindParam
- func NewCommit() *commitStmt
- func NewCopyWith(tblName string, src string, opts ...CopyOption) *copyStmt
- func NewDropDatabaseWith(name string, ife *IfExistsOpt) *dropDatabaseStmt
- func NewDropTableWith(tbls TableList, ife *IfExistsOpt) *dropTableStmt
- func NewGroupBy() *groupBy
- func NewGroupByWith(column string) *groupBy
- func NewLimitWith(offset int, limit int) *limitParam
- func NewRollback() *rollbackStmt
- func NewSelectWith(selectors Selectors, tbls TableList, w Condition, opts ...SelectOption) *selectStmt
- func NewTruncateWith(tbls TableList) *truncateStmt
- func NewUseWith(name string) *useStmt
- func NewVacuum() *vacuumStmt
- func NewVacuumWith(tbl Table) *vacuumStmt
- func WithAlterTableAddColumn(column Column) func(*alterTableStmt)
- func WithAlterTableAddIndex(index Index) func(*alterTableStmt)
- func WithAlterTableDropColumn(column Column) func(*alterTableStmt)
- func WithAlterTableDropIndex(index Index) func(*alterTableStmt)
- func WithAlterTableRenameColumn(from Column, to Column) func(*alterTableStmt)
- func WithAlterTableRenameTo(tbl Table) func(*alterTableStmt)
- func WithAlterTableSchema(name string) func(*alterTableStmt)
- func WithColumnArguments(args []any) func(*column)
- func WithColumnData(data ColumnDef) 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(*copyStmt)
- func WithCopyFormat(fmt string) func(*copyStmt)
- func WithLiteralType(t LiteralType) func(*Literal)
- func WithSchemaColumns(columns Columns) func(*schema)
- func WithSchemaIndexes(idxes Indexes) func(*schema)
- func WithSelectGroupBy(name string) func(*selectStmt)
- func WithSelectLimit(offset int, limit int) func(*selectStmt)
- func WithSelectOrderBy(orderBy OrderBy) func(*selectStmt)
- func WithTableSchema(schema string) func(*table)
- type AggregateFunc
- type AggregateFunction
- type AggregateResultSet
- type AlterDatabase
- type AlterTable
- 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
- type ColumnDef
- type ColumnOption
- type Columns
- func (columns Columns) ColumnAt(n int) (Column, error)
- func (columns Columns) ColumnNames() []string
- func (columns Columns) Columns() Columns
- func (columns Columns) Copy() Columns
- func (columns Columns) DefinitionString() string
- func (columns Columns) IsAsterisk() bool
- func (columns Columns) Len() int
- func (columns Columns) LookupColumn(name string) (Column, error)
- func (columns Columns) LookupIndexOfColumn(name string) (int, error)
- func (columns Columns) NameString() string
- func (columns Columns) Names() []string
- func (columns Columns) Selectors() Selectors
- func (columns Columns) SetSchema(schema Schema) error
- func (columns Columns) ValueString() string
- type Commit
- type Condition
- type Constraint
- type Copy
- type CopyFormat
- type CopyOption
- type CreateDatabase
- type CreateIndex
- type CreateTable
- type DataType
- type Database
- type Delete
- type DeleteOption
- type DropDatabase
- type DropIndex
- type DropTable
- type Expr
- type Function
- type FunctionExecutor
- type FunctionOption
- type FunctionType
- type GroupBy
- type IfExistsOpt
- type IfNotExistsOpt
- type Index
- type IndexType
- type Indexes
- type Insert
- type Limit
- type Literal
- func (lit *Literal) HasValue() bool
- func (lit *Literal) IsPlaceHolder() bool
- func (lit *Literal) SetValue(v any) *Literal
- func (lit *Literal) SetValueType(t LiteralType) *Literal
- func (lit *Literal) String() string
- func (lit *Literal) Value() any
- func (lit *Literal) ValueString() string
- func (lit *Literal) ValueType() LiteralType
- 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 Selectors
- func (selectors Selectors) AggregateFunctions() ([]FunctionExecutor, error)
- func (selectors Selectors) Columns() []Column
- func (selectors Selectors) FunctionExecutors() ([]FunctionExecutor, error)
- func (selectors Selectors) FunctionExecutorsForType(t FunctionType) ([]FunctionExecutor, error)
- func (selectors Selectors) Functions() []Function
- func (selectors Selectors) HasAggregateFunction() bool
- func (selectors Selectors) HasFunction() bool
- func (selectors Selectors) HasFunctionWithType(t FunctionType) bool
- func (selectors Selectors) IsAsterisk() bool
- func (selectors Selectors) Len() int
- func (selectors Selectors) LookupFunction(name string) (Function, error)
- func (selectors Selectors) LookupFunctionExecutor(name string) (FunctionExecutor, error)
- func (selectors Selectors) SelectorNames() []string
- func (selectors Selectors) SelectorString() string
- func (selectors Selectors) Selectors() Selectors
- type Statement
- type StatementList
- type StatementType
- type Table
- type TableList
- type TableOption
- type Truncate
- type Update
- type Use
- type Vacuum
Constants ¶
const ( UnknownData = iota BigIntData BinaryData BitData BlobData BooleanData CharData CharacterData ClobData DateData DateTimeData 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 UseStatement )
const (
// Asterisk is a asterisk string.
Asterisk = "*"
)
const GroupByNone = ""
GroupByNone represents an empty GROUP 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 NewAlterDatabaseWith ¶
NewAlterDatabaseWith returns a new alterDatabase statement instance with the specified options.
func NewBindParamWith ¶ added in v0.9.1
func NewBindParamWith(name string) *bindParam
NewBindParam returns a bind param instance.
func NewCommit ¶ added in v0.9.2
func NewCommit() *commitStmt
NewCommitWith returns a new commitStmt statement instance with the specified parameters.
func NewCopyWith ¶ added in v0.9.2
func NewCopyWith(tblName string, src string, opts ...CopyOption) *copyStmt
NewCopyWith returns a new copyStmt statement instance with the specified parameters.
func NewDropDatabaseWith ¶
func NewDropDatabaseWith(name string, ife *IfExistsOpt) *dropDatabaseStmt
NewDropDatabaseWith returns a new dropDatabase statement instance with the specified parameters.
func NewDropTableWith ¶
func NewDropTableWith(tbls TableList, ife *IfExistsOpt) *dropTableStmt
NewDropTableWith returns a new dropTable statement instance with the specified parameters.
func NewGroupBy ¶ added in v1.1.1
func NewGroupBy() *groupBy
NewGroupBy returns a new groupBy instance.
func NewGroupByWith ¶ added in v1.1.1
func NewGroupByWith(column string) *groupBy
NewGroupByWith returns a new groupBy instance with the specified column name.
func NewLimitWith ¶ added in v1.0.0
NewLimitWith returns a new limitParam instance with the specified offset and limit.
func NewRollback ¶ added in v1.2.0
func NewRollback() *rollbackStmt
NewRollbackWith returns a new rollbackStmt statement instance with the specified parameters.
func NewSelectWith ¶
func NewSelectWith(selectors Selectors, tbls TableList, w Condition, opts ...SelectOption) *selectStmt
NewSelectWith returns a new selectStmt statement instance with the specified parameters.
func NewTruncateWith ¶ added in v0.9.2
func NewTruncateWith(tbls TableList) *truncateStmt
NewTruncateWith returns a new truncate statement instance with the specified parameters.
func NewUseWith ¶ added in v1.3.5
func NewUseWith(name string) *useStmt
func NewVacuum ¶ added in v0.9.2
func NewVacuum() *vacuumStmt
NewVacuum returns a new vacuum statement instance.
func NewVacuumWith ¶ added in v0.9.2
func NewVacuumWith(tbl Table) *vacuumStmt
NewVacuumWith returns a new vacuum statement instance with the specified parameters.
func WithAlterTableAddColumn ¶ added in v0.9.2
func WithAlterTableAddColumn(column Column) func(*alterTableStmt)
WithAlterTableAddColumn sets an add column.
func WithAlterTableAddIndex ¶ added in v1.2.6
func WithAlterTableAddIndex(index Index) func(*alterTableStmt)
WithAlterTableAddIndex sets an add index.
func WithAlterTableDropColumn ¶ added in v0.9.2
func WithAlterTableDropColumn(column Column) func(*alterTableStmt)
WithAlterTableDropColumn sets a drop column.
func WithAlterTableDropIndex ¶ added in v1.3.2
func WithAlterTableDropIndex(index Index) func(*alterTableStmt)
WithAlterTableDropColumn sets a drop index.
func WithAlterTableRenameColumn ¶ added in v0.9.2
WithAlterTableRenameColumn sets a rename column.
func WithAlterTableRenameTo ¶ added in v0.9.2
func WithAlterTableRenameTo(tbl Table) func(*alterTableStmt)
WithAlterTableRenameTo sets a rename table.
func WithAlterTableSchema ¶ added in v0.9.2
func WithAlterTableSchema(name string) func(*alterTableStmt)
WithAlterTableSchema sets a schema.
func WithColumnArguments ¶ added in v1.2.3
func WithColumnArguments(args []any) func(*column)
WithColumnArguments sets column arguments.
func WithColumnData ¶ added in v0.9.1
func WithColumnData(data ColumnDef) func(*column)
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
func WithColumnLiteral(l *Literal) func(*column)
WithColumnLiteral sets a column data.
func WithColumnName ¶ added in v0.9.1
func WithColumnName(name string) func(*column)
WithColumnName sets a column name.
func WithCopyColumns ¶ added in v1.2.4
func WithCopyColumns(columns ...Column) func(*copyStmt)
WithCopyColumns returns a copy option to set the columns.
func WithCopyFormat ¶ added in v1.2.4
func WithCopyFormat(fmt string) func(*copyStmt)
WithCopyFormat returns a copy option to set the format.
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 Columns) func(*schema)
WithSchemaColumns returns a schema option to set the columns.
func WithSchemaIndexes ¶ added in v0.9.1
func WithSchemaIndexes(idxes Indexes) func(*schema)
WithSchemaIndexes returns a schema option to set the indexes.
func WithSelectGroupBy ¶ added in v1.1.1
func WithSelectGroupBy(name string) func(*selectStmt)
WithSelectOrderBy sets order by options.
func WithSelectLimit ¶ added in v1.0.0
WithSelectLimit sets order by options.
func WithSelectOrderBy ¶ added in v1.0.0
func WithSelectOrderBy(orderBy OrderBy) func(*selectStmt)
WithSelectOrderBy sets order by options.
func WithTableSchema ¶ added in v1.2.4
func WithTableSchema(schema string) func(*table)
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 interface { Statement // DatabaseName returns the database name. DatabaseName() string // RenameTo returns the "TO" database. RenameTo() Database }
AlterDatabase represents a "ALTER DATABASE" statement interface.
type AlterTable ¶
type AlterTable interface { Statement // TableName returns the table name. TableName() string // RenameTo returns the rename table. RenameTo() (Table, bool) // RenameColumns returns the rename columns. AddColumn() (Column, bool) // DropColumn returns the drop column. DropColumn() (Column, bool) // RenameColumns returns the rename columns. RenameColumns() (Column, Column, bool) // AddIndex returns the add index. AddIndex() (Index, bool) // DropIndex returns the drop index. DropIndex() (Index, bool) }
AlterTable represents a "ALTER TABLE" statement interface.
func NewAlterTableFrom ¶ added in v1.4.2
func NewAlterTableFrom(stmt Statement) (AlterTable, error)
NewAlterTableFrom convert the specified statement to an AlterTable.
func NewAlterTableWith ¶
func NewAlterTableWith(tblName string, opts ...AlterTableOption) AlterTable
NewAlterTableWith returns a new alterTable statement instance with the specified options.
type AlterTableOption ¶ added in v0.9.2
type AlterTableOption = func(*alterTableStmt)
AlterTableOption represents an alter table option function.
type AndExpr ¶
type AndExpr struct {
// contains filtered or unexported fields
}
AndExpr represents an AND expression.
func NewAndExpr ¶ added in v1.5.0
NewAndExpr returns a new AndExpr.
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 interface { Statement }
Begin represents a "BEGIN" statement interface.
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 interface { // Name returns the column name. Name() string // IsName returns true whether the column name is the specified one. IsName(string) bool // Definition returns the column definition. Definition() ColumnDef // Constraint returns the column constrains. Constraint() Constraint // DataType returns the column data type. DataType() DataType // DataTypeSize returns the column data type size. DataTypeSize() int // HasValue returns true whether the column has a value. HasValue() bool // SetValue sets a value. SetValue(any) error // Value returns the column value. Value() any // ValueType returns the column value type. ValueType() LiteralType // ValueString returns the column value string. ValueString() string // IsPlaceHolder returns true whether the column is a place holder. IsPlaceHolder() bool // IsFunction returns true whether the column is a function. IsFunction() (Function, bool) // Arguments returns the executor arguments. Arguments() []any // Copy returns a copy of the column. Copy() Column // String returns the string representation. String() string }
Column represents a column interface.
func NewColumnWithName ¶
NewColumn returns a column instance.
func NewColumnWithOptions ¶ added in v0.9.1
func NewColumnWithOptions(opts ...ColumnOption) Column
NewColumn returns a column instance.
type ColumnDef ¶ added in v1.4.0
type ColumnDef interface { // Constraint returns the column constrains. Constraint() Constraint // DataType returns the column data type. DataType() DataType // DataTypeSize returns the column data type size. DataTypeSize() int // String returns the string representation. String() string }
ColumnDef represents a data definition interface.
func NewDataDef ¶ added in v1.4.0
NewDataDef returns a new DataType instance with the specified type and length.
func NewDataDefFrom ¶ added in v1.4.0
NewDataDefFrom returns the data type of the specified string.
func NewUnknownDataDef ¶ added in v1.4.0
func NewUnknownDataDef() ColumnDef
NewUnknownDataDef returns a new unknown data type instance.
type ColumnOption ¶ added in v0.9.1
type ColumnOption = func(*column)
ColumnOption represents a column option function.
type Columns ¶
type Columns []Column
Columns represens a column array.
func NewColumnsWith ¶
NewColumnsWith returns a column array instance with the specified columns.
func (Columns) ColumnNames ¶ added in v1.4.0
ColumnNames returns a column name array.
func (Columns) DefinitionString ¶ added in v1.4.0
DefinitionString returns a string representation of the the column definitions.
func (Columns) IsAsterisk ¶ added in v1.4.0
IsAsterisk returns true if the column list is "*".
func (Columns) LookupColumn ¶ added in v1.4.0
LookupColumn returns a column by the specified name.
func (Columns) LookupIndexOfColumn ¶ added in v1.4.0
LookupIndexOfColumn returns the index of the column by the specified name.
func (Columns) NameString ¶
NameString returns a string representation of the the column names.
func (Columns) ValueString ¶
ValueString returns a string representation of the the column values.
type Commit ¶ added in v0.9.2
type Commit interface { Statement }
Commit represents a "COMMIT" statement interface.
type Condition ¶ added in v0.9.1
type Condition interface { // HasConditions returns true if the condition has conditions. HasConditions() bool // Expr returns the top expression. Expr() Expr // String returns the string representation. String() string }
Condition represents a where condition interface.
func NewCondition ¶ added in v1.4.0
func NewCondition() Condition
NewCondition returns a new where condition instance.
func NewConditionWith ¶ added in v0.9.1
NewConditionWith returns a new where condition instance with the specified parameters.
type Constraint ¶ added in v1.4.0
type Constraint int
Constraint represents a column constraint.
const ( // ConstraintNone represents no constraint. ConstraintNone Constraint = 0x00 PrimaryKeyConstraint Constraint = 0x01 NotNullConstraint Constraint = 0x02 UniqueConstraint Constraint = 0x04 )
func (Constraint) IsNotNull ¶ added in v1.5.0
func (c Constraint) IsNotNull() bool
IsNotNull returns true whether the column is not null.
func (Constraint) IsPrimaryKey ¶ added in v1.4.0
func (c Constraint) IsPrimaryKey() bool
IsPrimaryKey returns true whether the column is a primary key.
func (Constraint) IsUnique ¶ added in v1.5.0
func (c Constraint) IsUnique() bool
IsUnique returns true whether the column is unique.
func (Constraint) String ¶ added in v1.4.0
func (c Constraint) String() string
String returns the string representation.
type Copy ¶ added in v0.9.2
type Copy interface { Statement // TableName returns the table name. TableName() string // Columns returns the column list. Columns() Columns }
Copy represents a "COPY" statement interface.
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(*copyStmt)
CopyOption represents a copy option.
type CreateDatabase ¶
type CreateDatabase interface { Statement // DatabaseName returns the database name. DatabaseName() string // IfNotExists returns true if the "IF NOT EXISTS" option is set. IfNotExists() bool }
CreateDatabase represents a "CREATE DATABASE" statement interface.
func NewCreateDatabaseWith ¶
func NewCreateDatabaseWith(name string, ifne *IfNotExistsOpt) CreateDatabase
NewCreateDatabaseWith returns a new createDatabase statement instance with the specified options.
type CreateIndex ¶
type CreateIndex interface { Statement // TableName returns the table name. TableName() string // Index returns the index. Index() Index // IfNotExists returns true if the "IF NOT EXISTS" option is set. IfNotExists() bool }
CreateIndex is a "CREATE INDEX" statement interface.
func NewCreateIndexWith ¶
func NewCreateIndexWith(schema Schema, ifne *IfNotExistsOpt) CreateIndex
NewCreateIndexWith returns a new createIndex statement instance with the specified parameters.
type CreateTable ¶
type CreateTable interface { Statement // TableName returns the table name. TableName() string // Schema returns the schema. Schema() Schema // IfNotExists returns true if the "IF NOT EXISTS" option is set. IfNotExists() bool }
CreateTable represents a "CREATE TABLE" statement interface.
func NewCreateTableWith ¶
func NewCreateTableWith(schema Schema, ifne *IfNotExistsOpt) CreateTable
NewCreateTableWith returns a new createTable statement instance with the specified options.
type DataType ¶
type DataType uint8
DataType represents a data type.
func NewDataTypeFrom ¶ added in v1.5.0
NewDataTypeFrom create a data type from the specified value.
type Database ¶
type Database interface {
DatabaseName() string
}
Database represents a database interface.
func NewDatabaseWith ¶
NewDatabaseWith returns a new database instance with the specified name.
type Delete ¶
type Delete interface { Statement // Table returns the table. TableName() string // HasConditions returns true if the statement has conditions. HasConditions() bool // Where returns the condition. Where() Condition }
Delete represents a "DELETE" statement interface.
func NewDeleteWith ¶
func NewDeleteWith(tbl Table, w Condition, opts ...DeleteOption) Delete
NewDeleteWith returns a new deleteStmt statement instance with the specified parameters.
type DeleteOption ¶ added in v1.2.2
type DeleteOption = func(*deleteStmt)
DeleteOption represents a delete option function.
type DropDatabase ¶
type DropDatabase interface { Statement // DatabaseName returns the database name. DatabaseName() string // IfExists returns true if the "IF EXISTS" option is set. IfExists() bool }
DropDatabase represents a "DROP DATABASE" statement interface.
type DropIndex ¶
type DropIndex interface { Statement // TableName returns the table name. TableName() string // Indexreturns the index. Index() Index // IndexName returns the index name. IndexName() string // IfExists returns true if the "IF EXISTS" option is set. IfExists() bool }
DropIndex is a "DROP INDEX" statement interface.
func NewDropIndexWith ¶
func NewDropIndexWith(schemaName string, idxName string, ife *IfExistsOpt) DropIndex
NewDropIndexWith returns a new dropIndex statement instance with the specified parameters.
type DropTable ¶
type DropTable interface { Statement // Tables returns the table list. Tables() TableList // TableNames returns the table names. TableNames() []string // IfExists returns true if the "IF EXISTS" option is set. IfExists() bool }
DropTable represents a "DROP TABLE" statement interface.
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 interface { // Name returns the function name. Name() string // IsName returns true whether the function name is the specified one. IsName(string) bool // Arguments returns the argument list. Arguments() ArgumentList // IsAsterisk returns true if the argument list is "*". IsAsterisk() bool // Executor returns the executor of the function. Executor() (FunctionExecutor, error) // Execute executes the executor with the specified row. Execute(col Column, row map[string]any) (any, error) // String returns a string representation of the function. String() string }
Function represents a .
func NewFunctionWith ¶ added in v1.1.0
func NewFunctionWith(opts ...FunctionOption) Function
NewFunctionWith returns a function instance.
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 FunctionOption ¶ added in v1.4.0
type FunctionOption = func(*function)
FunctionOption represents a function option function.
func WithFunctionArguments ¶ added in v1.4.0
func WithFunctionArguments(args ...Argument) FunctionOption
WithFunctionArguments sets the function arguments.
func WithFunctionExecutor ¶ added in v1.4.0
func WithFunctionExecutor(executor FunctionExecutor) FunctionOption
WithFunctionExecutor sets the function executor.
func WithFunctionName ¶ added in v1.4.0
func WithFunctionName(name string) FunctionOption
WithFunctionName sets the function 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 interface { // ColumnName returns the column name. ColumnName() string // String returns the string representation. String() string }
GroupBy represents an GROUP interface.
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 interface { // Name returns the index name. Name() string // Type returns the index type. Type() IndexType // String returns the index string representation. Columns() Columns // DefinitionString returns the index definition string representation. DefinitionString() string }
Index represents a index interface.
func NewIndexWith ¶
NewIndexWith returns a new index instance.
func NewPrimaryIndexWith ¶
NewPrimaryIndexWith returns a new primary index instance.
func NewSecondaryIndexWith ¶
NewSecondaryIndexWith returns a new secondary index instance.
type Indexes ¶
type Indexes []Index
Indexes represents an index array.
func (Indexes) DefinitionString ¶ added in v1.4.0
DefinitionString returns the index definition string representation.
func (Indexes) IndexNames ¶ added in v1.4.0
IndexNames returns an index name array.
func (Indexes) LookupIndex ¶ added in v1.4.0
LookupIndex returns an index by the specified name.
type Insert ¶
type Insert interface { Statement // TableName returns the table name. TableName() string // Columns returns the columns. Columns() Columns }
Insert represents a "INSERT" statement interface.
func NewInsertWith ¶
NewInsertWith returns a new insert statement instance with the specified parameters.
type Limit ¶ added in v1.0.0
type Limit interface { // Offset returns the offset. Offset() int // Limit returns the limit. Limit() int // String returns the string representation. String() string }
Limit represents a LIMIT interface.
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) IsPlaceHolder ¶ added in v1.5.0
IsPlaceHolder returns true whether the literal is a place holder.
func (*Literal) SetValueType ¶ added in v1.4.0
func (lit *Literal) SetValueType(t LiteralType) *Literal
SetValueType sets a literal 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 OrExpr ¶
type OrExpr struct {
// contains filtered or unexported fields
}
OrExpr represents an OR expression.
type Order ¶ added in v1.0.0
type Order interface { // ColumnName returns the column name. ColumnName() string // Type returns the order type. Type() OrderType // IsNone returns true whether the order is none. IsNone() bool // IsAsc returns true whether the order is asc. IsAsc() bool // IsDesc returns true whether the order is desc. IsDesc() bool // String returns the string representation. String() string }
Order represents an ORDER BY interface.
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
OrderBy represents an ORDER BY interface.
func NewOrderBy ¶ added in v1.0.0
func NewOrderBy() OrderBy
NewOrderBy returns a new orderByParam instance.
func NewOrderByWith ¶ added in v1.0.0
NewOrderByWith returns a new orderByParam 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 interface { Statement }
Rollback represents a "ROLLBACK" statement interface.
type Schema ¶
type Schema interface { // FullTableName returns the full table name. FullTableName() string // SchemaName returns the schema name. SchemaName() string // TableName returns the table name. TableName() string // Columns returns the all columns. Columns() Columns // LookupColumn returns a column by the specified name. LookupColumn(string) (Column, error) // Indexes returns the all indexes. Indexes() Indexes // LookupIndex returns an index by the specified name. LookupIndex(string) (Index, error) // Alter alters the schema. Alter(AlterTable) error // AddColumn adds a column. AddColumn(Column) error // DropColumn drops a column by the specified name. DropColumn(string) error // AddIndex adds an index. AddIndex(Index) error // DropIndex drops an index by the specified name. DropIndex(string) error // Selectors returns the all selectors from the columns. Selectors() Selectors }
Schema represents a table schema interface.
func NewSchemaWith ¶
func NewSchemaWith(name string, opts ...SchemaOption) Schema
NewSchemaWith returns a new schema statement instance with the parameters.
type SchemaOption ¶ added in v0.9.1
type SchemaOption = func(*schema)
SchemaOption represents a schema option function.
type Select ¶
type Select interface { Statement // IsAsterisk returns true if the statement is a "SELECT *". IsAsterisk() bool // Selectors returns the selectors. Selectors() Selectors // From returns the source table list. From() TableList // Limit returns the limit clause. Limit() Limit // GroupBy returns the group by clause. GroupBy() GroupBy // OrderBy returns the order by clause. OrderBy() OrderBy // Where returns the condition. Where() Condition }
Select represents a "SELECT" statement interface.
type SelectOption ¶ added in v1.0.0
type SelectOption = func(*selectStmt)
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 }
Selector represents a selector in a select query.
type Selectors ¶ added in v1.4.0
type Selectors []Selector
Selectors represens a selector array.
func NewSelectors ¶ added in v1.1.0
func NewSelectors() Selectors
NewSelectors returns a selector array instance.
func NewSelectorsWith ¶ added in v1.1.0
NewSelectorsWith returns a selector array instance with the specified selectors.
func NewSelectorsWithColums ¶ added in v1.1.0
NewSelectorsWithColums returns a selector array instance with the specified selectors.
func (Selectors) AggregateFunctions ¶ added in v1.4.0
func (selectors Selectors) AggregateFunctions() ([]FunctionExecutor, error)
AggregateFunctions returns an aggregate function array.
func (Selectors) FunctionExecutors ¶ added in v1.4.0
func (selectors Selectors) FunctionExecutors() ([]FunctionExecutor, error)
FunctionExecutors returns a function executor array.
func (Selectors) FunctionExecutorsForType ¶ added in v1.4.0
func (selectors Selectors) FunctionExecutorsForType(t FunctionType) ([]FunctionExecutor, error)
FunctionExecutorsForType returns a function executor array with the specified type.
func (Selectors) HasAggregateFunction ¶ added in v1.4.0
HasAggregateFunction returns true if the selector list has an aggregate function.
func (Selectors) HasFunction ¶ added in v1.4.0
HasFunction returns true if the selector list has a function.
func (Selectors) HasFunctionWithType ¶ added in v1.4.0
func (selectors Selectors) HasFunctionWithType(t FunctionType) bool
HasFunctionWithType returns true if the selector list has a function with the specified type.
func (Selectors) IsAsterisk ¶ added in v1.4.0
IsAsterisk returns true if the selector list is "*".
func (Selectors) LookupFunction ¶ added in v1.4.0
LookupFunction returns a function with the specified name.
func (Selectors) LookupFunctionExecutor ¶ added in v1.4.0
func (selectors Selectors) LookupFunctionExecutor(name string) (FunctionExecutor, error)
LookupFunctionExecutor returns a function executor with the specified name.
func (Selectors) SelectorNames ¶ added in v1.4.1
SelectorNames returns a name array.
func (Selectors) SelectorString ¶ added in v1.4.0
SelectorString returns a string representation of the 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 interface { // FullTableName returns the full name of the table including schema and table name. FullTableName() string // IsFullTableName returns true if the provided name matches the full name of the table, IsFullTableName(name string) bool // SchemaName returns the table schema name. SchemaName() string // IsSchemaName returns true whether the table is named. IsSchemaName(name string) bool // TableName returns the table name for embedded use. TableName() string // IsTableName returns true whether the table is named. IsTableName(name string) bool }
Table represents a table interface.
func NewTableWith ¶
func NewTableWith(name string, opts ...TableOption) Table
NewTableWith returns a new table instance with the specified 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.
func (TableList) TableNames ¶ added in v1.4.0
TableNames returns the table names.
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 interface { Statement // Tables returns the table list. Tables() TableList // TableNames returns the table names. TableNames() []string }
Truncate represents a "TRUNCATE" statement interface.
type Update ¶
type Update interface { Statement // Table returns the table. TableName() string // Columns returns the columns. Columns() Columns // Where returns the condition. Where() Condition }
Update represents a "UPDATE" statement interface.
Source Files
¶
- alter_database.go
- alter_table.go
- alter_table_from.go
- argument.go
- arguments.go
- begin.go
- bind.go
- column.go
- column_def.go
- columns.go
- commit.go
- const.go
- constraint.go
- copy.go
- create_database.go
- create_index.go
- create_table.go
- data_type.go
- database.go
- delete.go
- drop_database.go
- drop_index.go
- drop_table.go
- errors.go
- expr.go
- expr_and.go
- expr_cmp.go
- expr_or.go
- func.go
- func_aggr.go
- func_arith.go
- func_cast.go
- func_math.go
- funcs.go
- group.go
- index.go
- index_type.go
- indexes.go
- insert.go
- limit.go
- literal.go
- options.go
- order.go
- order_type.go
- rollback.go
- schema.go
- select.go
- selector.go
- selectors.go
- statement.go
- statement_type.go
- table.go
- tables.go
- truncate.go
- update.go
- use.go
- vacuum.go
- where.go