Documentation ¶
Index ¶
- Variables
- func AlterTable(conn conn, table string) ialtertable.Stmt
- func Avg(conn conn, columns ...string) iselect.Stmt
- func Count(conn conn, columns ...string) iselect.Stmt
- func CreateDB(conn conn, dbName string) icreatedb.Stmt
- func CreateIndex(conn conn, idx string) icreateindex.Stmt
- func CreateTable(conn conn, table string) icreatetable.Stmt
- func Delete(conn conn) idelete.Stmt
- func DropDB(conn conn, dbName string) idropdb.Stmt
- func DropTable(conn conn, table string) idroptable.Stmt
- func Insert(conn conn, table string, columns ...string) iinsert.Stmt
- func Max(conn conn, columns ...string) iselect.Stmt
- func Min(conn conn, columns ...string) iselect.Stmt
- func RawStmt(conn conn, raw string, values ...interface{}) iraw.Stmt
- func Select(conn conn, columns ...string) iselect.Stmt
- func Sum(conn conn, columns ...string) iselect.Stmt
- func Update(conn conn, table string) iupdate.Stmt
- type AlterTableStmt
- func (s *AlterTableStmt) AddColumn(column, typ string) ialtertable.AddColumn
- func (s *AlterTableStmt) AddCons(key string) ialtertable.AddCons
- func (s *AlterTableStmt) Default(value interface{}) ialtertable.Default
- func (s *AlterTableStmt) DropColumn(column string) ialtertable.DropColumn
- func (s *AlterTableStmt) Foreign(columns ...string) ialtertable.Foreign
- func (s *AlterTableStmt) Migrate() error
- func (s *AlterTableStmt) NotNull() ialtertable.NotNull
- func (s *AlterTableStmt) Primary(columns ...string) ialtertable.Primary
- func (s *AlterTableStmt) RawClause(raw string, values ...interface{}) ialtertable.RawClause
- func (s *AlterTableStmt) Ref(table string, columns ...string) ialtertable.Ref
- func (s *AlterTableStmt) Rename(table string) ialtertable.Rename
- func (s *AlterTableStmt) RenameColumn(column, dest string) ialtertable.RenameColumn
- func (s *AlterTableStmt) SQL() string
- func (s *AlterTableStmt) Unique(columns ...string) ialtertable.Unique
- type CreateDBStmt
- type CreateIndexStmt
- type CreateTableStmt
- func (s *CreateTableStmt) Column(column, typ string) icreatetable.Column
- func (s *CreateTableStmt) Cons(key string) icreatetable.Cons
- func (s *CreateTableStmt) Default(value interface{}) icreatetable.Default
- func (s *CreateTableStmt) Foreign(columns ...string) icreatetable.Foreign
- func (s *CreateTableStmt) Migrate() error
- func (s *CreateTableStmt) Model(model interface{}) icreatetable.Model
- func (s *CreateTableStmt) NotNull() icreatetable.NotNull
- func (s *CreateTableStmt) Primary(columns ...string) icreatetable.Primary
- func (s *CreateTableStmt) RawClause(raw string, values ...interface{}) icreatetable.RawClause
- func (s *CreateTableStmt) Ref(table string, columns ...string) icreatetable.Ref
- func (s *CreateTableStmt) SQL() string
- func (s *CreateTableStmt) Unique(columns ...string) icreatetable.Unique
- type DB
- type DeleteStmt
- func (s *DeleteStmt) And(expr string, values ...interface{}) idelete.And
- func (s *DeleteStmt) Clauses() []interfaces.Clause
- func (s *DeleteStmt) Cmd() interfaces.Clause
- func (s *DeleteStmt) CompareWith(targetStmt interfaces.Stmt) error
- func (s *DeleteStmt) Exec() error
- func (s *DeleteStmt) From(tables ...string) idelete.From
- func (s *DeleteStmt) Or(expr string, values ...interface{}) idelete.Or
- func (s *DeleteStmt) RawClause(raw string, values ...interface{}) idelete.RawClause
- func (s *DeleteStmt) SQL() string
- func (s *DeleteStmt) String() string
- func (s *DeleteStmt) Where(expr string, values ...interface{}) idelete.Where
- type DropDBStmt
- type DropTableStmt
- type InsertStmt
- func (s *InsertStmt) Clauses() []interfaces.Clause
- func (s *InsertStmt) Cmd() interfaces.Clause
- func (s *InsertStmt) CompareWith(targetStmt interfaces.Stmt) error
- func (s *InsertStmt) Exec() error
- func (s *InsertStmt) Model(model interface{}) iinsert.Model
- func (s *InsertStmt) RawClause(raw string, values ...interface{}) iinsert.RawClause
- func (s *InsertStmt) SQL() string
- func (s *InsertStmt) Select(stmt interfaces.Stmt) iinsert.Select
- func (s *InsertStmt) String() string
- func (s *InsertStmt) Values(values ...interface{}) iinsert.Values
- type Mock
- type MockDB
- type MockTx
- type SelectStmt
- func (s *SelectStmt) And(expr string, values ...interface{}) iselect.And
- func (s *SelectStmt) Clauses() []interfaces.Clause
- func (s *SelectStmt) Cmd() interfaces.Clause
- func (s *SelectStmt) CompareWith(targetStmt interfaces.Stmt) error
- func (s *SelectStmt) From(tables ...string) iselect.From
- func (s *SelectStmt) GroupBy(columns ...string) iselect.GroupBy
- func (s *SelectStmt) Having(expr string, values ...interface{}) iselect.Having
- func (s *SelectStmt) Join(table string) iselect.Join
- func (s *SelectStmt) LeftJoin(table string) iselect.Join
- func (s *SelectStmt) Limit(limit int) iselect.Limit
- func (s *SelectStmt) Offset(offset int) iselect.Offset
- func (s *SelectStmt) On(expr string, values ...interface{}) iselect.On
- func (s *SelectStmt) Or(expr string, values ...interface{}) iselect.Or
- func (s *SelectStmt) OrderBy(columns ...string) iselect.OrderBy
- func (s *SelectStmt) Query(model interface{}) error
- func (s *SelectStmt) RawClause(raw string, values ...interface{}) iselect.RawClause
- func (s *SelectStmt) RightJoin(table string) iselect.Join
- func (s *SelectStmt) SQL() string
- func (s *SelectStmt) String() string
- func (s *SelectStmt) Union(stmt interfaces.Stmt) iselect.Union
- func (s *SelectStmt) UnionAll(stmt interfaces.Stmt) iselect.Union
- func (s *SelectStmt) Where(expr string, values ...interface{}) iselect.Where
- type Tx
- type UpdateStmt
- func (s *UpdateStmt) And(expr string, values ...interface{}) iupdate.And
- func (s *UpdateStmt) Clauses() []interfaces.Clause
- func (s *UpdateStmt) Cmd() interfaces.Clause
- func (s *UpdateStmt) CompareWith(targetStmt interfaces.Stmt) error
- func (s *UpdateStmt) Exec() error
- func (s *UpdateStmt) Model(model interface{}, columns ...string) iupdate.Model
- func (s *UpdateStmt) Or(expr string, values ...interface{}) iupdate.Or
- func (s *UpdateStmt) RawClause(raw string, values ...interface{}) iupdate.RawClause
- func (s *UpdateStmt) SQL() string
- func (s *UpdateStmt) Set(column string, value interface{}) iupdate.Set
- func (s *UpdateStmt) String() string
- func (s *UpdateStmt) Where(expr string, values ...interface{}) iupdate.Where
Constants ¶
This section is empty.
Variables ¶
var ( Int = reflect.TypeOf(int(0)) Int8 = reflect.TypeOf(int8(0)) Int16 = reflect.TypeOf(int16(0)) Int32 = reflect.TypeOf(int32(0)) Int64 = reflect.TypeOf(int64(0)) Uint8 = reflect.TypeOf(uint8(0)) Uint16 = reflect.TypeOf(uint16(0)) Uint32 = reflect.TypeOf(uint32(0)) Uint64 = reflect.TypeOf(uint64(0)) Float32 = reflect.TypeOf(float32(0)) Float64 = reflect.TypeOf(float64(0)) Bool = reflect.TypeOf(false) String = reflect.TypeOf("") NullInt32 = reflect.TypeOf(sql.NullInt32{}) NullInt64 = reflect.TypeOf(sql.NullInt64{}) NullFloat64 = reflect.TypeOf(sql.NullFloat64{}) NullBool = reflect.TypeOf(sql.NullBool{}) NullString = reflect.TypeOf(sql.NullString{}) NullTime = reflect.TypeOf(sql.NullTime{}) RawBytes = reflect.TypeOf(sql.RawBytes{}) )
Types.
Functions ¶
func AlterTable ¶
func AlterTable(conn conn, table string) ialtertable.Stmt
AlterTable calls ALTER TABLE command.
func CreateIndex ¶
func CreateIndex(conn conn, idx string) icreateindex.Stmt
CreateIndex calls CREATE INDEX command.
func CreateTable ¶
func CreateTable(conn conn, table string) icreatetable.Stmt
CreateTable calls CREATE TABLE command.
func DropTable ¶
func DropTable(conn conn, table string) idroptable.Stmt
DropTable calls DROP TABLE command.
Types ¶
type AlterTableStmt ¶
type AlterTableStmt struct {
// contains filtered or unexported fields
}
AlterTableStmt is ALTER TABLE statement.
func (*AlterTableStmt) AddColumn ¶
func (s *AlterTableStmt) AddColumn(column, typ string) ialtertable.AddColumn
AddColumn calls ADD COLUMN clause.
func (*AlterTableStmt) AddCons ¶
func (s *AlterTableStmt) AddCons(key string) ialtertable.AddCons
AddCons calls ADD CONSTRAINT clause.
func (*AlterTableStmt) Default ¶
func (s *AlterTableStmt) Default(value interface{}) ialtertable.Default
Default calls DEFAULT option.
func (*AlterTableStmt) DropColumn ¶
func (s *AlterTableStmt) DropColumn(column string) ialtertable.DropColumn
DropColumn calls DROP COLUMN clause.
func (*AlterTableStmt) Foreign ¶
func (s *AlterTableStmt) Foreign(columns ...string) ialtertable.Foreign
Foreign calls FOREIGN KEY keyword.
func (*AlterTableStmt) Migrate ¶
func (s *AlterTableStmt) Migrate() error
Migrate executes database migration.
func (*AlterTableStmt) NotNull ¶
func (s *AlterTableStmt) NotNull() ialtertable.NotNull
NotNull calls NOT NULL option.
func (*AlterTableStmt) Primary ¶
func (s *AlterTableStmt) Primary(columns ...string) ialtertable.Primary
Primary calls PRIMARY KEY keyword.
func (*AlterTableStmt) RawClause ¶
func (s *AlterTableStmt) RawClause(raw string, values ...interface{}) ialtertable.RawClause
RawClause calls the raw string clause.
func (*AlterTableStmt) Ref ¶
func (s *AlterTableStmt) Ref(table string, columns ...string) ialtertable.Ref
Ref calls REFERENCES keyword.
func (*AlterTableStmt) Rename ¶
func (s *AlterTableStmt) Rename(table string) ialtertable.Rename
Rename calls RENAME TO clause.
func (*AlterTableStmt) RenameColumn ¶
func (s *AlterTableStmt) RenameColumn(column, dest string) ialtertable.RenameColumn
RenameColumn calls RENAME COLUMN clause.
func (*AlterTableStmt) SQL ¶
func (s *AlterTableStmt) SQL() string
SQL returns the built SQL string.
func (*AlterTableStmt) Unique ¶
func (s *AlterTableStmt) Unique(columns ...string) ialtertable.Unique
Unique calls UNIQUE keyword.
type CreateDBStmt ¶
type CreateDBStmt struct {
// contains filtered or unexported fields
}
CreateDBStmt is CREATE DATABASE statement.
func (*CreateDBStmt) Migrate ¶
func (s *CreateDBStmt) Migrate() error
Migrate executes database migration.
type CreateIndexStmt ¶
type CreateIndexStmt struct {
// contains filtered or unexported fields
}
CreateIndexStmt is CREATE INDEX statement.
func (*CreateIndexStmt) Migrate ¶
func (s *CreateIndexStmt) Migrate() error
Migrate executes database migration.
func (*CreateIndexStmt) On ¶
func (s *CreateIndexStmt) On(table string, columns ...string) icreateindex.On
On calls ON clause.
func (*CreateIndexStmt) RawClause ¶
func (s *CreateIndexStmt) RawClause(raw string, values ...interface{}) icreateindex.RawClause
RawClause calls the raw string clause.
func (*CreateIndexStmt) SQL ¶
func (s *CreateIndexStmt) SQL() string
SQL returns the built SQL string.
type CreateTableStmt ¶
type CreateTableStmt struct {
// contains filtered or unexported fields
}
CreateTableStmt is CREATE TABLE statement.
func (*CreateTableStmt) Column ¶
func (s *CreateTableStmt) Column(column, typ string) icreatetable.Column
Column calls table column definition.
func (*CreateTableStmt) Cons ¶
func (s *CreateTableStmt) Cons(key string) icreatetable.Cons
Cons calls CONSTRAINT option.
func (*CreateTableStmt) Default ¶
func (s *CreateTableStmt) Default(value interface{}) icreatetable.Default
Default calls DEFAULT option.
func (*CreateTableStmt) Foreign ¶
func (s *CreateTableStmt) Foreign(columns ...string) icreatetable.Foreign
Foreign calls FOREIGN KEY keyword.
func (*CreateTableStmt) Migrate ¶
func (s *CreateTableStmt) Migrate() error
Migrate executes database migration.
func (*CreateTableStmt) Model ¶
func (s *CreateTableStmt) Model(model interface{}) icreatetable.Model
Model sets model to CreateTableStmt.
func (*CreateTableStmt) NotNull ¶
func (s *CreateTableStmt) NotNull() icreatetable.NotNull
NotNull calls NOT NULL option.
func (*CreateTableStmt) Primary ¶
func (s *CreateTableStmt) Primary(columns ...string) icreatetable.Primary
Primary calls PRIMARY KEY keyword.
func (*CreateTableStmt) RawClause ¶
func (s *CreateTableStmt) RawClause(raw string, values ...interface{}) icreatetable.RawClause
RawClause calls the raw string clause.
func (*CreateTableStmt) Ref ¶
func (s *CreateTableStmt) Ref(table string, columns ...string) icreatetable.Ref
Ref calls REFERENCES keyword.
func (*CreateTableStmt) SQL ¶
func (s *CreateTableStmt) SQL() string
SQL returns the built SQL string.
func (*CreateTableStmt) Unique ¶
func (s *CreateTableStmt) Unique(columns ...string) icreatetable.Unique
Unique calls UNIQUE keyword.
type DB ¶
type DB interface { SetConnMaxLifetime(n time.Duration) error SetMaxIdleConns(n int) error SetMaxOpenConns(n int) error Close() error Begin() (Tx, error) // contains filtered or unexported methods }
DB is the interface of database.
type DeleteStmt ¶
type DeleteStmt struct {
// contains filtered or unexported fields
}
DeleteStmt is DELETE statement.
func (*DeleteStmt) And ¶
func (s *DeleteStmt) And(expr string, values ...interface{}) idelete.And
And calls AND clause.
func (*DeleteStmt) Clauses ¶
func (s *DeleteStmt) Clauses() []interfaces.Clause
Clauses returns the called clauses.
func (*DeleteStmt) Cmd ¶
func (s *DeleteStmt) Cmd() interfaces.Clause
Cmd returns the command clause.
func (*DeleteStmt) CompareWith ¶
func (s *DeleteStmt) CompareWith(targetStmt interfaces.Stmt) error
CompareWith compares the statements and returns error if the statements is not same. In this case, same means that stmt.cmd and stmt.called is corresponding.
func (*DeleteStmt) Exec ¶
func (s *DeleteStmt) Exec() error
Exec executed SQL statement without mapping to model. If type of conn is gsorm.MockDB, compare statements between called and expected.
func (*DeleteStmt) From ¶
func (s *DeleteStmt) From(tables ...string) idelete.From
From calls FROM clause.
func (*DeleteStmt) Or ¶
func (s *DeleteStmt) Or(expr string, values ...interface{}) idelete.Or
Or calls OR clause.
func (*DeleteStmt) RawClause ¶
func (s *DeleteStmt) RawClause(raw string, values ...interface{}) idelete.RawClause
RawClause calls the raw string clause.
type DropDBStmt ¶
type DropDBStmt struct {
// contains filtered or unexported fields
}
DropDBStmt is DROP DATABASE statement.
func (*DropDBStmt) Migrate ¶
func (s *DropDBStmt) Migrate() error
Migrate executes database migration.
type DropTableStmt ¶
type DropTableStmt struct {
// contains filtered or unexported fields
}
DropTableStmt is DROP TABLE statement.
func (*DropTableStmt) Migrate ¶
func (s *DropTableStmt) Migrate() error
Migrate executes database migration.
func (*DropTableStmt) RawClause ¶
func (s *DropTableStmt) RawClause(raw string, value ...interface{}) idroptable.RawClause
RawClause calls the raw string clause.
type InsertStmt ¶
type InsertStmt struct {
// contains filtered or unexported fields
}
InsertStmt is INSERT statement.
func (*InsertStmt) Clauses ¶
func (s *InsertStmt) Clauses() []interfaces.Clause
Clauses returns the called clauses.
func (*InsertStmt) Cmd ¶
func (s *InsertStmt) Cmd() interfaces.Clause
Cmd returns the command clause.
func (*InsertStmt) CompareWith ¶
func (s *InsertStmt) CompareWith(targetStmt interfaces.Stmt) error
CompareWith compares the statements and returns error if the statements is not same. In this case, same means that stmt.cmd and stmt.called is corresponding.
func (*InsertStmt) Exec ¶
func (s *InsertStmt) Exec() error
Exec executed SQL statement without mapping to model. If type of conn is gsorm.MockDB, compare statements between called and expected.
func (*InsertStmt) Model ¶
func (s *InsertStmt) Model(model interface{}) iinsert.Model
Model sets model to InsertStmt.
func (*InsertStmt) RawClause ¶
func (s *InsertStmt) RawClause(raw string, values ...interface{}) iinsert.RawClause
RawClause calls the raw string clause.
func (*InsertStmt) Select ¶
func (s *InsertStmt) Select(stmt interfaces.Stmt) iinsert.Select
Select calls SELECT statement.
func (*InsertStmt) String ¶
func (s *InsertStmt) String() string
String returns the method calls as string.
func (*InsertStmt) Values ¶
func (s *InsertStmt) Values(values ...interface{}) iinsert.Values
Values calls VALUES clause.
type Mock ¶
type Mock interface { Complete() error Expect(s interfaces.Stmt) ExpectWithReturn(s interfaces.Stmt, v interface{}) // contains filtered or unexported methods }
Mock is mock database connection pool.
type SelectStmt ¶
type SelectStmt struct {
// contains filtered or unexported fields
}
SelectStmt is SELECT statement.
func (*SelectStmt) And ¶
func (s *SelectStmt) And(expr string, values ...interface{}) iselect.And
And calls AND clause.
func (*SelectStmt) Clauses ¶
func (s *SelectStmt) Clauses() []interfaces.Clause
Clauses returns the called clauses.
func (*SelectStmt) Cmd ¶
func (s *SelectStmt) Cmd() interfaces.Clause
Cmd returns the command clause.
func (*SelectStmt) CompareWith ¶
func (s *SelectStmt) CompareWith(targetStmt interfaces.Stmt) error
CompareWith compares the statements and returns error if the statements is not same. In this case, same means that stmt.cmd and stmt.called is corresponding.
func (*SelectStmt) From ¶
func (s *SelectStmt) From(tables ...string) iselect.From
From calls FROM clause.
func (*SelectStmt) GroupBy ¶
func (s *SelectStmt) GroupBy(columns ...string) iselect.GroupBy
GroupBy calls GROUP BY clause.
func (*SelectStmt) Having ¶
func (s *SelectStmt) Having(expr string, values ...interface{}) iselect.Having
Having calls HAVING clause.
func (*SelectStmt) Join ¶
func (s *SelectStmt) Join(table string) iselect.Join
Join calls (INNER) JOIN clause.
func (*SelectStmt) LeftJoin ¶
func (s *SelectStmt) LeftJoin(table string) iselect.Join
LeftJoin calls (INNER) JOIN clause.
func (*SelectStmt) Limit ¶
func (s *SelectStmt) Limit(limit int) iselect.Limit
Limit calls LIMIT clause.
func (*SelectStmt) Offset ¶
func (s *SelectStmt) Offset(offset int) iselect.Offset
Offset calls OFFSET clause.
func (*SelectStmt) On ¶
func (s *SelectStmt) On(expr string, values ...interface{}) iselect.On
On calls ON clause.
func (*SelectStmt) Or ¶
func (s *SelectStmt) Or(expr string, values ...interface{}) iselect.Or
Or calls OR clause.
func (*SelectStmt) OrderBy ¶
func (s *SelectStmt) OrderBy(columns ...string) iselect.OrderBy
OrderBy calls ORDER BY clause.
func (*SelectStmt) Query ¶
func (s *SelectStmt) Query(model interface{}) error
Query executes SQL statement with mapping to model. If type of (*SelectStmt).conn is gsorm.MockDB, compare statements between called and expected. Then, it maps expected values to model.
func (*SelectStmt) RawClause ¶
func (s *SelectStmt) RawClause(raw string, values ...interface{}) iselect.RawClause
RawClause calls the raw string clause.
func (*SelectStmt) RightJoin ¶
func (s *SelectStmt) RightJoin(table string) iselect.Join
RightJoin calls (INNER) JOIN clause.
func (*SelectStmt) String ¶
func (s *SelectStmt) String() string
String returns the method calls as string.
func (*SelectStmt) Union ¶
func (s *SelectStmt) Union(stmt interfaces.Stmt) iselect.Union
Union calls UNION clause.
func (*SelectStmt) UnionAll ¶
func (s *SelectStmt) UnionAll(stmt interfaces.Stmt) iselect.Union
UnionAll calls UNION ALL clause.
type UpdateStmt ¶
type UpdateStmt struct {
// contains filtered or unexported fields
}
UpdateStmt is UPDATE statement..
func (*UpdateStmt) And ¶
func (s *UpdateStmt) And(expr string, values ...interface{}) iupdate.And
And calls AND clause.
func (*UpdateStmt) Clauses ¶
func (s *UpdateStmt) Clauses() []interfaces.Clause
Clauses returns the called clauses.
func (*UpdateStmt) Cmd ¶
func (s *UpdateStmt) Cmd() interfaces.Clause
Cmd returns the command clause.
func (*UpdateStmt) CompareWith ¶
func (s *UpdateStmt) CompareWith(targetStmt interfaces.Stmt) error
CompareWith compares the statements and returns error if the statements is not same. In this case, same means that stmt.cmd and stmt.called is corresponding.
func (*UpdateStmt) Exec ¶
func (s *UpdateStmt) Exec() error
Exec executes SQL statement without mapping to model. If type of conn is gsorm.MockDB, compare statements between called and expected.
func (*UpdateStmt) Model ¶
func (s *UpdateStmt) Model(model interface{}, columns ...string) iupdate.Model
Model sets model to UpdateStmt.
func (*UpdateStmt) Or ¶
func (s *UpdateStmt) Or(expr string, values ...interface{}) iupdate.Or
Or calls OR clause.
func (*UpdateStmt) RawClause ¶
func (s *UpdateStmt) RawClause(raw string, values ...interface{}) iupdate.RawClause
RawClause calls the raw string clause.
func (*UpdateStmt) Set ¶
func (s *UpdateStmt) Set(column string, value interface{}) iupdate.Set
Set calls SET clause.