Documentation
¶
Index ¶
- Constants
- Variables
- 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 NewErrStatementInvalid(stmt Statement) error
- func NewErrStatementNotSupported(stmt Statement) error
- func NewGroupBy() *groupBy
- func NewGroupByWith(column string) *groupBy
- func NewLimitWith(offset uint, limit uint) *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 []string) func(*column)
- func WithColumnData(data ColumnDef) func(*column)
- func WithColumnFunction(fn Function) func(*column)
- func WithColumnFunctionExecutor(executor 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 uint, limit uint) func(*selectStmt)
- func WithSelectOrderBy(orderBy OrderBy) func(*selectStmt)
- func WithTableSchema(schema string) func(*table)
- type Aggregator
- type AggregatorResultSet
- type AggregatorSet
- type AlterDatabase
- type AlterTable
- type AlterTableOption
- type AndExpr
- type Argument
- type Arguments
- type Begin
- type BindParam
- type BindParams
- 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 ColumnHelper
- 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 DefinitionStringer
- 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 IndexType
- type Indexes
- type Insert
- type Limit
- type Literal
- func (lit *Literal) Equal(v any) bool
- func (lit *Literal) HasValue() bool
- func (lit *Literal) IsAsterisk() 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 OrExpr
- type Order
- type OrderBy
- type OrderType
- type Rollback
- type Schema
- type SchemaOption
- type Select
- type SelectHelper
- type SelectOption
- type Selector
- type SelectorHelper
- type Selectors
- func (selectors Selectors) Aggregators() (AggregatorSet, error)
- func (selectors Selectors) Columns() []Column
- func (selectors Selectors) Executors() ([]FunctionExecutor, error)
- func (selectors Selectors) ExecutorsForType(t FunctionType) ([]FunctionExecutor, error)
- func (selectors Selectors) Functions() []Function
- func (selectors Selectors) HasAggregator() bool
- func (selectors Selectors) HasExecutor() 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) LookupExecutor(name string) (FunctionExecutor, error)
- func (selectors Selectors) LookupFunction(name string) (Function, error)
- func (selectors Selectors) Names() []string
- func (selectors Selectors) Selectors() Selectors
- func (selectors Selectors) String() string
- type Statement
- type StatementList
- type StatementType
- type Table
- type TableList
- type TableOption
- type Truncate
- type Update
- type UpdatorStringer
- type Use
- type Vacuum
Constants ¶
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 ErrNotSet = errors.New("not set")
ErrNotSet is returned when the value is not set.
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 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 NewErrStatementInvalid ¶ added in v1.5.2
NewErrStatementInvalid returns a new error for invalid statements.
func NewErrStatementNotSupported ¶ added in v1.5.2
NewErrStatementNotSupported returns a new error for unsupported statements.
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 []string) 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 Function) func(*column)
WithColumnFunction sets a column function.
func WithColumnFunctionExecutor ¶ added in v1.5.2
func WithColumnFunctionExecutor(executor FunctionExecutor) func(*column)
WithColumnFunctionExecutor 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 Aggregator ¶ added in v1.5.2
type Aggregator = fn.Aggregator
type AggregatorResultSet ¶ added in v1.5.2
type AggregatorSet ¶ added in v1.5.2
type AggregatorSet = fn.AggregatorSet
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 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 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 // IsFunction returns true whether the column is a function. IsFunction() bool // Function returns the function if the column is a function. Function() (Function, bool) // Arguments returns the executor arguments. Arguments() Arguments // Copy returns a copy of the column. Copy() Column // DefinitionString returns the definition string representation. DefinitionString() string // String returns the string representation. String() string // ColumnHelper provides additional methods for columns in a query. ColumnHelper }
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 NewDataDefFromStrings ¶ added in v1.5.1
func NewUnknownDataDef ¶ added in v1.4.0
func NewUnknownDataDef() ColumnDef
NewUnknownDataDef returns a new unknown data type instance.
type ColumnHelper ¶ added in v1.5.2
type ColumnHelper interface { // ValueString returns the column value string. ValueString() string // IsAsterisk returns true if the column is an asterisk. IsAsterisk() bool // IsPlaceHolder returns true whether the column is a place holder. IsPlaceHolder() bool }
ColumnHelper provides additional methods for columns in a query.
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.
const ( UnknownData DataType = iota BigIntType BinaryType BitType BlobType BooleanType CharType CharacterType ClobType DateType DateTimeType DecimalType DoubleType DoublePrecisionType FloatType IntType IntegerType LongBlobType LongTextType MediumBlobType MediumIntType MediumTextType NumericType RealType SetType SmallIntType TextType TimeType TimeStampType TinyBlobType TinyIntType TinyTextType VarBinaryType VarCharType VarCharacterType YearType // PostgreSQL // https://www.postgresql.org/docs/current/datatype.html SerialType BigSerialType SmallSerialType )
func NewDataTypeForFunction ¶ added in v1.5.2
NewDataTypeForFunction creates a data type for the specified function.
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 DefinitionStringer ¶ added in v1.5.2
type DefinitionStringer interface {
DefinitionString() string
}
DefinitionStringer represents a definition stringer interface.
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 FunctionExecutor ¶ added in v1.1.1
Type aliases for the fn package.
type FunctionType ¶ added in v1.1.1
type FunctionType = fn.FunctionType
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 name of the target table. TableName() string // Deprecated: Columns returns the columns for a single row of values. Columns() Columns // Values returns the columns for multiple rows of values. Values() []Columns }
Insert represents an "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() uint // Limit returns the limit. Limit() uint // 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) Equal ¶ added in v1.5.2
Equal returns true whether the literal value is equal to the specified value.
func (*Literal) IsAsterisk ¶ added in v1.5.2
IsAsterisk returns true whether the literal is an asterisk.
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 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 // 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 // SelectHelper is an interface for "SELECT" statement helpers. SelectHelper }
Select represents a "SELECT" statement interface.
type SelectHelper ¶ added in v1.5.2
type SelectHelper interface { // HasAggregator returns true if the statement has an aggregate function. HasAggregator() bool // HasExecutor returns true if the statement has an executor. HasExecutor() bool }
SelectHelper is an interface for "SELECT" statement helpers.
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 // IsFunction returns true whether the column is a function. IsFunction() bool // Function returns the function if the column is a function. Function() (Function, bool) // Arguments returns the executor arguments. Arguments() Arguments // String returns the string representation of the selector. String() string // SelectorHelper provides additional methods for selectors. SelectorHelper }
Selector represents a selector in a select query.
type SelectorHelper ¶ added in v1.5.2
type SelectorHelper interface { // IsAsterisk returns true if the selector is an asterisk. IsAsterisk() bool }
SelectorHelper provides additional methods for selectors.
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) Aggregators ¶ added in v1.5.2
func (selectors Selectors) Aggregators() (AggregatorSet, error)
AggregateFunctions returns an aggregate function array.
func (Selectors) Executors ¶ added in v1.5.2
func (selectors Selectors) Executors() ([]FunctionExecutor, error)
Executors returns a function executor array.
func (Selectors) ExecutorsForType ¶ added in v1.5.2
func (selectors Selectors) ExecutorsForType(t FunctionType) ([]FunctionExecutor, error)
ExecutorsForType returns a function executor array with the specified type.
func (Selectors) HasAggregator ¶ added in v1.5.2
HasAggregator returns true if the selector list has an aggregate function.
func (Selectors) HasExecutor ¶ added in v1.5.2
HasExecutor returns true if the selector list has a function executor.
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) LookupExecutor ¶ added in v1.5.2
func (selectors Selectors) LookupExecutor(name string) (FunctionExecutor, error)
LookupExecutor returns a function executor with the specified name.
func (Selectors) LookupFunction ¶ added in v1.4.0
LookupFunction returns a function with the specified name.
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.
type UpdatorStringer ¶ added in v1.5.2
type UpdatorStringer interface {
UpdatorString() string
}
UpdatorStringer represents a updator stringer interface.
Source Files
¶
- alter_database.go
- alter_table.go
- alter_table_from.go
- begin.go
- bind.go
- column.go
- column_def.go
- column_helper.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
- 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
- select_helper.go
- selector.go
- selector_helper.go
- selectors.go
- selectors_helper.go
- statement.go
- statement_type.go
- table.go
- tables.go
- truncate.go
- update.go
- use.go
- vacuum.go
- where.go