query

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Index

Constants

View Source
const (
	UnknownData = iota
	BigIntData
	BinaryData
	BitData
	BlobData
	BooleanData
	CharData
	CharacterData
	ClobData
	DateData
	DecimalData
	DoubleData
	FloatData
	IntData
	IntegerData
	LongBlobData
	LongTextData
	MediumBlobData
	MediumIntData
	MediumTextData
	NumericData
	RealData
	SetData
	SmallIntData
	TextData
	TimeData
	TimeStampData
	TinyBlobData
	TinyIntData
	TinyTextData
	VarBinaryData
	VarCharData
	VarCharacterData
	YearData
)
View Source
const (
	CreateDatabaseStatement = iota
	CreateTableStatement
	CreateIndexStatement
	InsertStatement
	SelectStatement
	UpdateStatement
	DeleteStatement
	DropDatabaseStatement
	DropTableStatement
	DropIndexStatement
	AlterDatabaseStatement
	AlterTableStatement
	AlterIndexStatement
)

Variables

View Source
var ErrInvalidDataType = errors.New("invalid data type")

ErrInvalidDataType is returned when the data type is invalid.

View Source
var NullLiteral = NewLiteralWith(nil)

NullLiteral represents a null value.

Functions

This section is empty.

Types

type AlterDatabase

type AlterDatabase struct {
	*Database
}

AlterDatabase is a "ALTER DATABASE" statement.

func NewAlterDatabaseWith

func NewAlterDatabaseWith(name string) *AlterDatabase

NewAlterDatabaseWith returns a new AlterDatabase statement instance with the specified options.

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

type AlterTable struct {
	*Schema
	*Table
}

AlterTable is a "ALTER TABLE" statement.

func NewAlterTableWith

func NewAlterTableWith(schemaName string, tblName string) *AlterTable

NewAlterTableWith returns a new AlterTable statement instance with the specified options.

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 AndExpr

type AndExpr struct {
	Left  Expr
	Right Expr
}

AndExpr represents an AND expression.

type Column

type Column struct {
	*Data
	*Literal
	// contains filtered or unexported fields
}

Column represents a column.

func NewColumnWith

func NewColumnWith(name string, t *Data, l *Literal) *Column

NewColumn returns a column instance.

func NewColumnWithName

func NewColumnWithName(name string) *Column

NewColumn returns a column instance.

func (*Column) DefString

func (col *Column) DefString() string

String returns the string representation.

func (*Column) Name

func (col *Column) Name() string

Name returns the column name.

func (*Column) String

func (col *Column) String() string

String returns the string representation.

type Columns

type Columns []*Column

Columns represens a column array.

func NewColumns

func NewColumns() Columns

NewColumns returns a column array instance.

func NewColumnsWith

func NewColumnsWith(columns ...*Column) Columns

NewColumnsWith returns a column array instance with the specified columns.

func (Columns) Columns

func (colums Columns) Columns() Columns

Column returns a column array.

func (Columns) DefString

func (colums Columns) DefString() string

DefString returns a string representation of the the colum definitions.

func (Columns) NameString

func (colums Columns) NameString() string

NameString returns a string representation of the the colum names.

func (Columns) Names

func (colums Columns) Names() []string

Names returns a column name array.

func (Columns) ValueString

func (colums Columns) ValueString() string

ValueString returns a string representation of the the colum values.

type CompExpr

type CompExpr struct {
	Operator CompExprOperator
	Left     *Column
	Right    *Literal
}

CompExpr represents an comparsion expression.

func NewCompExpr

func NewCompExpr(op CompExprOperator, left *Column, right *Literal) *CompExpr

NewCompExpr returns a new CompExpr instance with the specified parameters.

func (*CompExpr) String

func (expr *CompExpr) String() string

String returns the index string representation.

type CompExprOperator

type CompExprOperator uint8

CompExprOperator is an enum for CompExpr.Operator

const (
	EqualOp CompExprOperator = iota
	NotEqualOp
	LessThanOp
	GreaterThanOp
	LessEqualOp
	GreaterEqualOp
	InOp
	NotInOp
)

Constants for Enum Type - CompExprOperator

func (CompExprOperator) String

func (t CompExprOperator) String() string

String returns the string representation.

type CreateDatabase

type CreateDatabase struct {
	*Database
	*IfNotExists
}

CreateDatabase is a "CREATE DATABASE" statement.

func NewCreateDatabaseWith

func NewCreateDatabaseWith(name string, ifne *IfNotExists) *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
	*IfNotExists
}

CreateIndex is a "CREATE INDEX" statement.

func NewCreateIndexWith

func NewCreateIndexWith(schema *Schema, ifne *IfNotExists) *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 {
	*Schema
	*IfNotExists
}

CreateTable is a "CREATE TABLE" statement.

func NewCreateTableWith

func NewCreateTableWith(schema *Schema, ifne *IfNotExists) *CreateTable

NewCreateTableWith returns a new CreateTable statement instance with the specified options.

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.

type Data

type Data struct {
	Type   DataType
	Length int
}

Data represents a data type.

func NewDataFrom

func NewDataFrom(s string, l int) (*Data, error)

NewDataFrom returns the data type of the specified string.

func NewDataWith

func NewDataWith(t DataType, l int) *Data

NewDataWith returns a new DataType instance with the specified type and length.

func (*Data) DataLength

func (da *Data) DataLength() int

DataLength returns the column data length.

func (*Data) DataType

func (da *Data) DataType() DataType

DataType returns the column data type.

func (*Data) String

func (da *Data) String() string

String returns the string representation.

type DataType

type DataType int

DataType represents a data type.

func (DataType) String

func (t DataType) String() string

String returns the string representation.

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database represents a database.

func NewDatabaseWith

func NewDatabaseWith(name string) *Database

NewDatabaseWith returns a new Database instance with the specified name.

func (*Database) Database

func (db *Database) Database() *Database

Database returns the database.

func (*Database) Name

func (db *Database) Name() string

Name returns the database name.

func (*Database) String

func (db *Database) String() string

String returns the string representation.

type Delete

type Delete struct {
	*Table
	*Where
}

Delete is a "DELETE" statement.

func NewDeleteWith

func NewDeleteWith(tbl *Table, w *Where) *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.

func (*Delete) String

func (stmt *Delete) String() string

String returns the statement string representation.

type DropDatabase

type DropDatabase struct {
	*Database
	*IfExists
}

DropDatabase is a "DROP DATABASE" statement.

func NewDropDatabaseWith

func NewDropDatabaseWith(name string, ife *IfExists) *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
	*IfExists
}

DropIndex is a "DROP INDEX" statement.

func NewDropIndexWith

func NewDropIndexWith(schemaName string, idxName string, ife *IfExists) *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.

func (*DropIndex) String

func (stmt *DropIndex) String() string

String returns the statement string representation.

type DropTable

type DropTable struct {
	*Schema
	*Table
	*IfExists
}

DropTable is a "DROP TABLE" statement.

func NewDropTableWith

func NewDropTableWith(schemaName string, tblName string, ife *IfExists) *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.

func (*DropTable) String

func (stmt *DropTable) String() string

String returns the statement string representation.

type Expr

type Expr interface {
	// String returns the index string representation.
	String() string
}

Expr represents an expression.

type IfExists

type IfExists struct {
	// contains filtered or unexported fields
}

IfExists represents a IF EXISTS option.

func NewIfExistsWith

func NewIfExistsWith(v bool) *IfExists

NewIfExistsWith returns a new IfExists option instance.

func (*IfExists) Enabled

func (opt *IfExists) Enabled() bool

Enabled returns true whether the option is enabled.

func (*IfExists) IfExists

func (opt *IfExists) IfExists() bool

IfExists returns the IF EXISTS option.

func (*IfExists) String

func (opt *IfExists) String() string

String returns the string representation.

type IfNotExists

type IfNotExists struct {
	// contains filtered or unexported fields
}

IfNotExists represents a IF NOT EXISTS option.

func NewIfNotExistsWith

func NewIfNotExistsWith(v bool) *IfNotExists

NewIfNotExistsWith returns a new IfNotExists option instance.

func (*IfNotExists) Enabled

func (opt *IfNotExists) Enabled() bool

Enabled returns true whether the option is enabled.

func (*IfNotExists) IfNotExists

func (opt *IfNotExists) IfNotExists() bool

IfNotExists returns the IF NOT EXISTS option.

func (*IfNotExists) String

func (opt *IfNotExists) String() string

String returns the string representation.

type Index

type Index struct {
	Columns
	// contains filtered or unexported fields
}

Index represents a index.

func NewIndexWith

func NewIndexWith(name string, t IndexType, colums Columns) *Index

NewIndexWith returns a new index instance.

func NewPrimaryIndexWith

func NewPrimaryIndexWith(colums Columns) *Index

NewPrimaryIndexWith returns a new primary index instance.

func NewSecondaryIndexWith

func NewSecondaryIndexWith(name string, colums Columns) *Index

NewSecondaryIndexWith returns a new secondary index instance.

func (*Index) DefString

func (idx *Index) DefString() string

DefString returns the index definition string representation.

func (*Index) Name

func (idx *Index) Name() string

Name returns the index name.

func (*Index) String

func (idx *Index) String() string

String returns the index string representation.

func (*Index) Type

func (idx *Index) Type() IndexType

Type returns the index type.

type IndexType

type IndexType int

IndexType represents a index type.

const (
	UnknownIndex   IndexType = 0
	PrimaryIndex   IndexType = 1
	SecondaryIndex IndexType = 2
)

func (IndexType) String

func (t IndexType) String() string

String returns the string representation.

type Indexes

type Indexes []*Index

Indexes represents an index array.

func NewIndexes

func NewIndexes() Indexes

NewIndexes returns a new Indexes instance.

func (Indexes) DefString

func (indexes Indexes) DefString() string

DefString returns the index definition string representation.

func (Indexes) Indexes

func (indexes Indexes) Indexes() Indexes

Indexes returns an index array.

type Insert

type Insert struct {
	*Table
	Columns
}

Insert is a "INSERT" statement.

func NewInsertWith

func NewInsertWith(tbl *Table, colums Columns) *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.

func (*Insert) String

func (stmt *Insert) String() string

String returns the statement string representation.

type Literal

type Literal struct {
	// contains filtered or unexported fields
}

Literal represents a constant value.

func NewLiteralWith

func NewLiteralWith(v any) *Literal

NewLiteralWith returns a new Literal instance with the specified value.

func (*Literal) Literal

func (lit *Literal) Literal() *Literal

Literal returns the literal.

func (*Literal) String

func (lit *Literal) String() string

String returns the string representation.

func (*Literal) Value

func (lit *Literal) Value() any

Value returns the literal value.

type OrExpr

type OrExpr struct {
	Left  Expr
	Right Expr
}

OrExpr represents an OR expression.

type OrderType

type OrderType int

OrderType represents an ordertype.

const (
	// OrderTypeNone represents none order.
	OrderTypeNone OrderType = iota
	// OrderTypeAsc represents asc order.
	OrderTypeAsc
	// OrderTypeDesc represents desc order.
	OrderTypeDesc
)

func (OrderType) String

func (t OrderType) String() string

String returns the string representation.

type Schema

type Schema struct {
	*Table
	Columns
	Indexes
}

Schema represents a table schema.

func NewSchemaWith

func NewSchemaWith(name string, colums Columns, indexes Indexes) *Schema

NewSchemaWith returns a new schema statement instance with the parameters.

func (*Schema) Schema

func (schema *Schema) Schema() *Schema

Schema returns the schema.

func (*Schema) String

func (schema *Schema) String() string

String returns the statement string representation.

type Select

type Select struct {
	Tables
	Columns
	*Where
}

Select is a "SELECT" statement.

func NewSelectWith

func NewSelectWith(colums Columns, tbls Tables, w *Where) *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.

func (*Select) String

func (stmt *Select) String() string

String returns the statement string representation.

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 int

StatementType is a statement type.

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table represents a table.

func NewTableWith

func NewTableWith(name string) *Table

NewTableWith returns a new Table instance with the specified name.

func (*Table) Name

func (tbl *Table) Name() string

Name returns the table name.

func (*Table) String

func (tbl *Table) String() string

String returns the string representation.

func (*Table) Table

func (tbl *Table) Table() *Table

Table returns the table.

type Tables

type Tables []*Table

Tables represens a column array.

func NewTables

func NewTables() Tables

NewTables returns a column array instance.

func NewTablesWith

func NewTablesWith(columns ...*Table) Tables

NewTablesWith returns a column array instance with the specified columns.

func (Tables) String

func (colums Tables) String() string

String returns a string representation.

func (Tables) Tables

func (colums Tables) Tables() Tables

Table returns a column array.

type Update

type Update struct {
	*Table
	Columns
	*Where
}

Update is a "UPDATE" statement.

func NewUpdateWith

func NewUpdateWith(tbl *Table, colums Columns, w *Where) *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.

func (*Update) String

func (stmt *Update) String() string

String returns the statement string representation.

type Where

type Where struct {
	// contains filtered or unexported fields
}

Where represents a where condition.

func NewWhereWith

func NewWhereWith(expr Expr) *Where

NewWhereWith returns a new where condition instance with the specified parameters.

func (*Where) Expr

func (w *Where) Expr() Expr

Expr returns the top expression.

func (*Where) String

func (w *Where) String() string

String returns the string representation.

func (*Where) Where

func (w *Where) Where() *Where

Where returns the table.

Jump to

Keyboard shortcuts

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